77from paths_cli .tests .wizard .mock_wizard import mock_wizard
88
99from paths_cli .wizard .cvs import (
10- _get_topology , _get_atom_indices , distance , angle , dihedral , rmsd ,
11- coordinate , cvs , SUPPORTED_CVS
10+ TOPOLOGY_CV_PREREQ , _get_atom_indices , MDTRAJ_DISTANCE , MDTRAJ_ANGLE ,
11+ MDTRAJ_DIHEDRAL , COORDINATE_CV
1212)
1313
1414import openpathsampling as paths
1717from openpathsampling .tests .test_helpers import make_1d_traj
1818
1919@pytest .mark .parametrize ('n_engines' , [0 , 1 , 2 ])
20- def test_get_topology (ad_engine , n_engines ):
20+ def test_TOPOLOGY_CV_PREREQ (ad_engine , n_engines ):
2121 inputs = {0 : [], 1 : [], 2 : ['1' ]}[n_engines ]
2222 wizard = mock_wizard (inputs )
2323 engines = [ad_engine , paths .engines .NoEngine (None ).named ('foo' )]
@@ -27,9 +27,10 @@ def mock_register(obj, obj_type, store_name):
2727 wizard .register = mock_register
2828
2929 mock_engines = mock .Mock (return_value = ad_engine )
30- patch_loc = 'paths_cli.wizard.engines.engines '
30+ patch_loc = 'paths_cli.wizard.cvs.TOPOLOGY_CV_PREREQ.create_func '
3131 with mock .patch (patch_loc , new = mock_engines ):
32- topology = _get_topology (wizard )
32+ topology_result = TOPOLOGY_CV_PREREQ (wizard )
33+ topology = topology_result ['topology' ][0 ]
3334 assert isinstance (topology , paths .engines .MDTrajTopology )
3435
3536@pytest .mark .parametrize ('inputs' , [
@@ -58,37 +59,31 @@ def test_distance(ad_openmm, ad_engine):
5859 md = pytest .importorskip ('mdtraj' )
5960 wizard = mock_wizard (['0, 1' ])
6061 md_func = partial (md .compute_distances , atom_pairs = [[0 , 1 ]])
61- _mdtraj_function_test (wizard , distance , md_func , ad_openmm , ad_engine )
62+ _mdtraj_function_test (wizard , MDTRAJ_DISTANCE , md_func , ad_openmm ,
63+ ad_engine )
6264
6365def test_angle (ad_openmm , ad_engine ):
6466 md = pytest .importorskip ('mdtraj' )
6567 wizard = mock_wizard (['0, 1, 2' ])
6668 md_func = partial (md .compute_angles , angle_indices = [[0 , 1 , 2 ]])
67- _mdtraj_function_test (wizard , angle , md_func , ad_openmm , ad_engine )
69+ _mdtraj_function_test (wizard , MDTRAJ_ANGLE , md_func , ad_openmm , ad_engine )
6870
6971def test_dihedral (ad_openmm , ad_engine ):
7072 md = pytest .importorskip ('mdtraj' )
7173 wizard = mock_wizard (['0, 1, 2, 3' ])
7274 md_func = partial (md .compute_dihedrals , indices = [[0 , 1 , 2 , 3 ]])
73- _mdtraj_function_test (wizard , dihedral , md_func , ad_openmm , ad_engine )
75+ _mdtraj_function_test (wizard , MDTRAJ_DIHEDRAL , md_func , ad_openmm ,
76+ ad_engine )
7477
7578@pytest .mark .parametrize ('inputs' , [
7679 (['0' , 'x' ]), ('foo' , '0' , 'x' ), (['0' , 'q' , 'x' ])
7780])
7881def test_coordinate (inputs ):
7982 wizard = mock_wizard (inputs )
80- cv = coordinate (wizard )
83+ cv = COORDINATE_CV (wizard )
8184 traj = make_1d_traj ([5.0 ])
8285 assert cv (traj [0 ]) == 5.0
8386 if 'foo' in inputs :
8487 assert "I can't make an atom index" in wizard .console .log_text
8588 if 'q' in inputs :
8689 assert "Please select one of" in wizard .console .log_text
87-
88- @pytest .mark .parametrize ('inputs' , [(['foo' , 'Distance' ]), (['Distance' ])])
89- def test_cvs (inputs ):
90- wizard = mock_wizard (inputs )
91- say_hello = mock .Mock (return_value = "hello" )
92- with mock .patch .dict (SUPPORTED_CVS , {'Distance' : say_hello }):
93- assert cvs (wizard ) == "hello"
94- assert wizard .console .input_call_count == len (inputs )
0 commit comments