Skip to content

Commit 934040a

Browse files
committed
looks like all tests pass with full coverage
1 parent 93e5f9e commit 934040a

5 files changed

Lines changed: 23 additions & 15 deletions

File tree

‎paths_cli/tests/wizard/test_plugin_classes.py‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def test_call(self):
110110

111111
def test_call_with_prereq(self):
112112
# ensure that prerequisites get run if they are provided
113-
def prereq(wizard):
113+
def prereq(wizard, context):
114114
wizard.say("Running prereq")
115115
return {'prereq': ['results']}
116116

@@ -258,8 +258,9 @@ def setup(self):
258258
self.plugin_format = WizardObjectPlugin(
259259
name="bar",
260260
category="foo",
261-
builder=(lambda wizard, context:
262-
"bar_obj baz={baz}".format(**context)),
261+
prerequisite=lambda wizard, context: {'baz': context['baz']},
262+
builder=(lambda wizard, prereq:
263+
"bar_obj baz={baz}".format(**prereq)),
263264
)
264265

265266
@pytest.mark.parametrize('input_type', ['method', 'None'])

‎paths_cli/tests/wizard/test_volumes.py‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
from paths_cli.wizard.volumes import (
77
INTERSECTION_VOLUME_PLUGIN, UNION_VOLUME_PLUGIN, NEGATED_VOLUME_PLUGIN,
8-
CV_DEFINED_VOLUME_PLUGIN, VOLUMES_PLUGIN, volume_intro, _VOL_DESC
8+
CV_DEFINED_VOLUME_PLUGIN, VOLUMES_PLUGIN, volume_intro, _VOL_DESC,
9+
volume_ask
910
)
1011

1112

@@ -100,6 +101,19 @@ def test_negated_volume(volume_setup):
100101
assert not vol(traj[0])
101102
assert vol(traj[1])
102103

104+
@pytest.mark.parametrize('depth', [0, 1, None])
105+
def test_volume_ask(depth):
106+
context = {0: {'depth': 0},
107+
1: {'depth': 1},
108+
None: {}}[depth]
109+
wiz = mock_wizard([])
110+
result = volume_ask(wiz, context)
111+
if depth == 1:
112+
assert result == "What describes this volume?"
113+
else:
114+
assert result == "What describes this state?"
115+
116+
103117
@pytest.mark.parametrize('periodic', [True, False])
104118
def test_cv_defined_volume(periodic):
105119
if periodic:

‎paths_cli/wizard/parameters.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def select_single_existing(self, wizard):
151151
self.create_func)
152152
return self.load_func(obj)
153153

154-
def __call__(self, wizard):
154+
def __call__(self, wizard, context=None):
155155
n_existing = len(getattr(wizard, self.store_name))
156156
if n_existing == self.n_required:
157157
# early return in this case (return silently)

‎paths_cli/wizard/plugin_classes.py‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,11 @@ def __call__(self, wizard, context=None):
145145
wizard.say(self.intro)
146146

147147
if self.prerequisite is not None:
148-
prereqs = self.prerequisite(wizard)
148+
prereqs = self.prerequisite(wizard, context)
149149
else:
150150
prereqs = {}
151151

152-
context.update(prereqs)
153-
result = self.builder(wizard, context)
152+
result = self.builder(wizard, prereqs)
154153
summary = self.get_summary(wizard, context, result)
155154
for line in summary:
156155
wizard.say(line)

‎paths_cli/wizard/volumes.py‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,16 @@
1010
from functools import partial
1111

1212
def _binary_func_volume(wizard, context, op):
13-
def summarize(volname):
14-
def inner(wizard, context, result):
15-
return f"The {volname} volume is:\n {str(result)}"
16-
1713
as_state = context.get('depth', 0) == 0
1814
wizard.say("Let's make the first constituent volume:")
1915
new_context = volume_set_context(wizard, context, selected=None)
2016
new_context['part'] = 1
21-
new_context['summarize'] = summarize("first")
2217
vol1 = VOLUMES_PLUGIN(wizard, new_context)
2318
wizard.say("Let's make the second constituent volume:")
2419
new_context['part'] = 2
25-
new_context['summarize'] = summarize("second")
2620
vol2 = VOLUMES_PLUGIN(wizard, new_context)
21+
wizard.say("Now we'll combine those two constituent volumes...")
2722
vol = op(vol1, vol2)
28-
# wizard.say(f"Created a volume:\n{vol}")
2923
return vol
3024

3125
_LAMBDA_STR = ("What is the {minmax} allowed value for "

0 commit comments

Comments
 (0)