Skip to content

Commit

Permalink
Merge pull request #374 from OpenFreeEnergy/remove-testsuite-keys
Browse files Browse the repository at this point in the history
Removed all hardcoded gufe keys from GufeTokenizable tests in test suite
  • Loading branch information
dotsdl authored Nov 1, 2024
2 parents 4e13ab8 + 70e220e commit 7142e80
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 27 deletions.
3 changes: 1 addition & 2 deletions gufe/tests/test_alchemicalnetwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
class TestAlchemicalNetwork(GufeTokenizableTestsMixin):

cls = AlchemicalNetwork
key = "AlchemicalNetwork-a6869a43fc26ab0b159dfee489616109"
repr = "<AlchemicalNetwork-a6869a43fc26ab0b159dfee489616109>"
repr = None

@pytest.fixture
def instance(self, benzene_variants_star_map):
Expand Down
1 change: 0 additions & 1 deletion gufe/tests/test_chemicalsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def test_sorting(solvated_complex, solvated_ligand):
class TestChemicalSystem(GufeTokenizableTestsMixin):

cls = ChemicalSystem
key = "ChemicalSystem-92176395ceb86ecd7787ce2585b24218"
repr = "ChemicalSystem(name=, components={'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)})"

@pytest.fixture
Expand Down
3 changes: 1 addition & 2 deletions gufe/tests/test_ligand_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ def network_container(

class TestLigandNetwork(GufeTokenizableTestsMixin):
cls = LigandNetwork
key = "LigandNetwork-c597016564f85a3c42445bd1dabd91b3"
repr = "<LigandNetwork-c597016564f85a3c42445bd1dabd91b3>"
repr = None

@pytest.fixture
def instance(self, simple_network):
Expand Down
1 change: 0 additions & 1 deletion gufe/tests/test_ligandatommapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@ def test_too_small_B(self, molA, molB):
class TestLigandAtomMapping(GufeTokenizableTestsMixin):
cls = LigandAtomMapping
repr = "LigandAtomMapping(componentA=SmallMoleculeComponent(name=), componentB=SmallMoleculeComponent(name=), componentA_to_componentB={0: 0, 1: 1}, annotations={'foo': 'bar'})"
key = "LigandAtomMapping-2c0aae226e3f69d2d1cf429abaefdb5b"

@pytest.fixture
def instance(self, annotated_simple_mapping):
Expand Down
1 change: 0 additions & 1 deletion gufe/tests/test_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def componentB_unique(self):

class TestMappingAbstractClass(GufeTokenizableTestsMixin):
cls = ExampleMapping
key = 'ExampleMapping-ea9e102cdfddb0e243bde58074dd729c'
repr = None

@pytest.fixture
Expand Down
1 change: 0 additions & 1 deletion gufe/tests/test_proteincomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def assert_topology_equal(ref_top, top):
class TestProteinComponent(GufeTokenizableTestsMixin):

cls = ProteinComponent
key = "ProteinComponent-089f72c9fa2c9c18d53308038eeab5c9"
repr = "ProteinComponent(name=Steve)"

@pytest.fixture
Expand Down
8 changes: 2 additions & 6 deletions gufe/tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ def _create(
class TestProtocol(GufeTokenizableTestsMixin):

cls = DummyProtocol
key = "DummyProtocol-d01baed9cf2500c393bd6ddb35ee38aa"
repr = "<DummyProtocol-d01baed9cf2500c393bd6ddb35ee38aa>"
repr = None

@pytest.fixture
def instance(self):
return DummyProtocol(settings=DummyProtocol.default_settings())
Expand Down Expand Up @@ -374,7 +374,6 @@ def test_key_stable(self, instance):

class TestProtocolDAG(ProtocolDAGTestsMixin):
cls = ProtocolDAG
key = None
repr = None

@pytest.fixture
Expand All @@ -384,7 +383,6 @@ def instance(self, protocol_dag):

class TestProtocolDAGResult(ProtocolDAGTestsMixin):
cls = ProtocolDAGResult
key = None
repr = None

@pytest.fixture
Expand Down Expand Up @@ -436,7 +434,6 @@ def test_protocol_unit_successes(self, instance: ProtocolDAGResult):

class TestProtocolDAGResultFailure(ProtocolDAGTestsMixin):
cls = ProtocolDAGResult
key = None
repr = None

@pytest.fixture
Expand Down Expand Up @@ -466,7 +463,6 @@ def test_protocol_unit_failure_traceback(self, instance: ProtocolDAGResult):

class TestProtocolUnit(GufeTokenizableTestsMixin):
cls = SimulationUnit
key = None
repr = None

@pytest.fixture
Expand Down
3 changes: 1 addition & 2 deletions gufe/tests/test_protocolresult.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ def get_uncertainty(self):

class TestProtocolResult(GufeTokenizableTestsMixin):
cls = DummyProtocolResult
key = 'DummyProtocolResult-b7b854b39c1e37feabec58b4000680a0'
repr = f'<{key}>'
repr = None

@pytest.fixture
def instance(self):
Expand Down
4 changes: 0 additions & 4 deletions gufe/tests/test_serialization_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,21 +176,18 @@ class TestKeyAdded(MigrationTester):
cls = KeyAdded
input_dict = _SERIALIZED_OLD
kwargs = {"foo": "foo", "bar": "bar", "qux": 10}
key = "KeyAdded-43d61e49c793a863b8b4f96b0e0b2876"


class TestKeyRemoved(MigrationTester):
cls = KeyRemoved
input_dict = _SERIALIZED_OLD
kwargs = {"foo": "foo"}
key = "KeyRemoved-93a689cdf75976b83507e4d1ded1ad7b"


class TestKeyRenamed(MigrationTester):
cls = KeyRenamed
input_dict = _SERIALIZED_OLD
kwargs = {"foo": "foo", "baz": "bar"}
key = "KeyRenamed-55860190714f16df7b9b6aab47346619"


# for some reason, we'll move the child from belonging to the son to
Expand Down Expand Up @@ -256,7 +253,6 @@ class TestNestedKeyMoved(MigrationTester):
kwargs = {
'settings': {'son': {}, 'daughter': {'daughter_child': 10}}
}
key = "Grandparent-0e2ea10e853d7ac730e7b2ae477a3801"

@pytest.fixture
def instance(self):
Expand Down
1 change: 0 additions & 1 deletion gufe/tests/test_smallmoleculecomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def test_ensure_ofe_name(internal, rdkit_name, name, expected, recwarn):
class TestSmallMoleculeComponent(GufeTokenizableTestsMixin):

cls = SmallMoleculeComponent
key = "SmallMoleculeComponent-82d90fcdcbe76a4155b0ea42b9080ff2"
repr = "SmallMoleculeComponent(name=ethane)"

@pytest.fixture
Expand Down
1 change: 0 additions & 1 deletion gufe/tests/test_solvents.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def test_bad_inputs(pos, neg):
class TestSolventComponent(GufeTokenizableTestsMixin):

cls = SolventComponent
key = "SolventComponent-26b4034ad9dbd9f908dfc298ea8d449f"
repr = "SolventComponent(name=O, Na+, Cl-)"

@pytest.fixture
Expand Down
11 changes: 8 additions & 3 deletions gufe/tests/test_tokenization.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class GufeTokenizableTestsMixin(abc.ABC):

# set this to the `GufeTokenizable` subclass you are testing
cls: type[GufeTokenizable]
key: Optional[str]
repr: Optional[str]

@pytest.fixture
Expand Down Expand Up @@ -141,7 +140,14 @@ def test_to_shallow_dict_roundtrip(self, instance):
#assert ser == reser

def test_key_stable(self, instance):
assert self.key == instance.key
"""Check that generating the instance from a dict representation yields
the same key (and the same instance).
"""
instance_ = GufeTokenizable.from_dict(instance.to_dict())

assert instance_.key == instance.key
assert instance_ is instance

def test_repr(self, instance):
if self.repr is None:
Expand All @@ -154,7 +160,6 @@ def test_repr(self, instance):
class TestGufeTokenizable(GufeTokenizableTestsMixin):

cls = Container
key = "Container-3fcec08974fbbd0371fed8a185628b70"
repr = "Container(Leaf(Leaf(foo, 2), 2), [Leaf(foo, 2), 0], {'leaf': Leaf(foo, 2), 'a': 'b'})"

@pytest.fixture
Expand Down
2 changes: 0 additions & 2 deletions gufe/tests/test_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def complex_equilibrium(solvated_complex):

class TestTransformation(GufeTokenizableTestsMixin):
cls = Transformation
key = "Transformation-3e001d3eaa6eb0cb1a77f6460f3f6f29"
repr = "Transformation(stateA=ChemicalSystem(name=, components={'ligand': SmallMoleculeComponent(name=toluene), 'solvent': SolventComponent(name=O, K+, Cl-)}), stateB=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), protocol=<DummyProtocol-d01baed9cf2500c393bd6ddb35ee38aa>)"

@pytest.fixture
Expand Down Expand Up @@ -141,7 +140,6 @@ def test_deprecation_warning_on_dict_mapping(self, solvated_ligand, solvated_com
class TestNonTransformation(GufeTokenizableTestsMixin):

cls = NonTransformation
key = "NonTransformation-5fe8c396da48515ad75acc7cb5d02607"
repr = "NonTransformation(stateA=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), stateB=ChemicalSystem(name=, components={'protein': ProteinComponent(name=), 'solvent': SolventComponent(name=O, K+, Cl-), 'ligand': SmallMoleculeComponent(name=toluene)}), protocol=<DummyProtocol-d01baed9cf2500c393bd6ddb35ee38aa>)"

@pytest.fixture
Expand Down

0 comments on commit 7142e80

Please sign in to comment.