Skip to content

Commit 94cd34e

Browse files
committed
Tests for two_state_tps.py
1 parent d2050e4 commit 94cd34e

5 files changed

Lines changed: 37 additions & 13 deletions

File tree

‎paths_cli/tests/wizard/conftest.py‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,12 @@ def toy_engine():
6868
topology=topology
6969
).named('toy-engine')
7070
return engine
71+
72+
73+
@pytest.fixture
74+
def tps_network():
75+
cv = paths.CoordinateFunctionCV('x', lambda s: s.xyz[0][0])
76+
state_A = paths.CVDefinedVolume(cv, float("-inf"), 0).named("A")
77+
state_B = paths.CVDefinedVolume(cv, 0, float("inf")).named("B")
78+
network = paths.TPSNetwork(state_A, state_B).named('tps-network')
79+
return network

‎paths_cli/tests/wizard/test_tps.py‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@
1010

1111
from paths_cli.wizard.tps import tps_scheme
1212

13-
14-
15-
@pytest.fixture
16-
def tps_network():
17-
cv = paths.CoordinateFunctionCV('x', lambda s: s.xyz[0][0])
18-
state_A = paths.CVDefinedVolume(cv, float("-inf"), 0).named("A")
19-
state_B = paths.CVDefinedVolume(cv, 0, float("inf")).named("B")
20-
network = paths.TPSNetwork(state_A, state_B).named('tps-network')
21-
return network
22-
2313
@pytest.mark.parametrize('as_scheme', [False, True])
2414
def test_tps_scheme(tps_network, toy_engine, as_scheme):
2515
wizard = mock_wizard([])
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import pytest
2+
import mock
3+
4+
from paths_cli.tests.wizard.mock_wizard import mock_wizard
5+
6+
from paths_cli.wizard.two_state_tps import two_state_tps
7+
8+
def mock_tps_scheme(wizard, network):
9+
wizard.say(str(network.__class__))
10+
return "this would be a scheme"
11+
12+
@mock.patch('paths_cli.wizard.two_state_tps.tps_scheme',
13+
new=mock_tps_scheme)
14+
def test_two_state_tps(tps_network):
15+
wizard = mock_wizard([])
16+
state_A = tps_network.initial_states[0]
17+
state_B = tps_network.final_states[0]
18+
with mock.patch('paths_cli.wizard.two_state_tps.volumes',
19+
new=mock.Mock(side_effect=[state_A, state_B])):
20+
scheme = two_state_tps(wizard)
21+
assert scheme == "this would be a scheme"
22+
assert "network.TPSNetwork" in wizard.console.log_text
23+
24+
25+

‎paths_cli/wizard/core.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import random
2-
from paths_cli.wizard.joke import name_joke
32
from paths_cli.wizard.tools import a_an
43

54
from collections import namedtuple
65

6+
WIZARD_STORE_NAMES = ['engines', 'cvs', 'states', 'networks', 'schemes']
77
WizardSay = namedtuple("WizardSay", ['msg', 'mode'])
88

99
def interpret_req(req):

‎paths_cli/wizard/two_state_tps.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
from paths_cli.wizard.volumes import volumes
2+
from paths_cli.wizard.tps import tps_scheme
13
from paths_cli.wizard.steps import (
24
SINGLE_ENGINE_STEP, CVS_STEP, WizardStep
35
)
4-
from paths_cli.wizard.volumes import volumes
5-
from paths_cli.wizard.tps import tps_scheme
66
from paths_cli.wizard.wizard import Wizard
77

88
def two_state_tps(wizard, fixed_length=False):

0 commit comments

Comments
 (0)