Skip to content

Commit 6467b59

Browse files
committed
Remove name from core (used as wizard.name)
1 parent 9d6c3dd commit 6467b59

4 files changed

Lines changed: 39 additions & 57 deletions

File tree

‎paths_cli/tests/wizard/test_core.py‎

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@
1010
make_mock_wizard, make_mock_retry_wizard
1111
)
1212

13-
def test_name():
14-
wizard = make_mock_wizard('foo')
15-
cv = CoordinateFunctionCV(lambda s: s.xyz[0][0])
16-
assert not cv.is_named
17-
result = name(wizard, cv, obj_type="CV", store_name="cvs")
18-
assert result is cv
19-
assert result.is_named
20-
assert result.name == 'foo'
13+
# def test_name():
14+
# wizard = make_mock_wizard('foo')
15+
# cv = CoordinateFunctionCV(lambda s: s.xyz[0][0])
16+
# assert not cv.is_named
17+
# result = name(wizard, cv, obj_type="CV", store_name="cvs")
18+
# assert result is cv
19+
# assert result.is_named
20+
# assert result.name == 'foo'
2121

22-
def test_name_exists():
23-
wizard = make_mock_retry_wizard(['foo', 'bar'])
24-
wizard.cvs['foo'] = 'placeholder'
25-
cv = CoordinateFunctionCV(lambda s: s.xyz[0][0])
26-
assert not cv.is_named
27-
result = name(wizard, cv, obj_type="CV", store_name="cvs")
28-
assert result is cv
29-
assert result.is_named
30-
assert result.name == 'bar'
31-
assert wizard.console.input.call_count == 2
22+
# def test_name_exists():
23+
# wizard = make_mock_retry_wizard(['foo', 'bar'])
24+
# wizard.cvs['foo'] = 'placeholder'
25+
# cv = CoordinateFunctionCV(lambda s: s.xyz[0][0])
26+
# assert not cv.is_named
27+
# result = name(wizard, cv, obj_type="CV", store_name="cvs")
28+
# assert result is cv
29+
# assert result.is_named
30+
# assert result.name == 'bar'
31+
# assert wizard.console.input.call_count == 2
3232

3333
@pytest.mark.parametrize('req,expected', [
3434
(('foo', 2, 2), '2'), (('foo', 2, float('inf')), 'at least 2'),

‎paths_cli/tests/wizard/test_wizard.py‎

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
import mock
33
from paths_cli.tests.wizard.mock_wizard import (
4-
MockConsole
4+
MockConsole, make_mock_wizard, make_mock_retry_wizard
55
)
66
import pathlib
77

@@ -120,10 +120,25 @@ def test_exception(self):
120120
assert "RuntimeError: baz" in console.log_text
121121

122122
def test_name(self):
123-
# why does that exist? cf core.name
124-
# actually, it looks like we never use core.name; remove that and
125-
# move its test here?
126-
pass
123+
wizard = make_mock_wizard('foo')
124+
cv = CoordinateFunctionCV(lambda s: s.xyz[0][0])
125+
assert not cv.is_named
126+
result = wizard.name(cv, obj_type="CV", store_name="cvs")
127+
assert result is cv
128+
assert result.is_named
129+
assert result.name == 'foo'
130+
131+
def test_name_exists(self):
132+
wizard = make_mock_retry_wizard(['foo', 'bar'])
133+
wizard.cvs['foo'] = 'placeholder'
134+
cv = CoordinateFunctionCV(lambda s: s.xyz[0][0])
135+
assert not cv.is_named
136+
result = wizard.name(cv, obj_type="CV", store_name="cvs")
137+
assert result is cv
138+
assert result.is_named
139+
assert result.name == 'bar'
140+
assert wizard.console.input.call_count == 2
141+
127142

128143
@pytest.mark.parametrize('named', [True, False])
129144
def test_register(self, named):

‎paths_cli/wizard/core.py‎

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,6 @@
66

77
WizardSay = namedtuple("WizardSay", ['msg', 'mode'])
88

9-
def name(wizard, obj, obj_type, store_name, default=None):
10-
wizard.say(f"Now let's name your {obj_type}.")
11-
name = None
12-
while name is None:
13-
name = wizard.ask("What do you want to call it?")
14-
if name in getattr(wizard, store_name):
15-
wizard.bad_input(f"Sorry, you already have {a_an(obj_type)} "
16-
f"{obj_type} named {name}. Please try another "
17-
"name.")
18-
name = None
19-
20-
obj = obj.named(name)
21-
22-
wizard.say(f"'{name}' is a good name for {a_an(obj_type)} {obj_type}. "
23-
+ name_joke(name, obj_type))
24-
return obj
25-
26-
def abort_retry_quit(wizard, obj_type):
27-
a_an = a_an(obj_type)
28-
retry = wizard.ask(f"Do you want to try again to make {a_an} "
29-
f"{obj_type}, do you want to continue without, or "
30-
f"do you want to quit?",
31-
options=["[R]etry", "[C]ontinue", "[Q]uit"])
32-
if retry == 'q':
33-
exit()
34-
elif retry == 'r':
35-
return
36-
elif retry == 'c':
37-
return "continue"
38-
else:
39-
raise ImpossibleError()
40-
41-
429
def interpret_req(req):
4310
_, min_, max_ = req
4411
string = ""

‎paths_cli/wizard/tps.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def tps_scheme(wizard, network=None):
1111
network = get_missing_object(wizard, wizard.networks, 'network',
1212
tps_network)
1313

14-
shooting_strategy = shooting(wizard, network)
14+
shooting_strategy = shooting(wizard, network=network)
1515

1616
if not isinstance(shooting_strategy, paths.MoveStrategy):
1717
# this means we got a fixed scheme and can't do strategies

0 commit comments

Comments
 (0)