Skip to content

Commit

Permalink
Added stability checks for GufeTokenizable keys where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
dotsdl committed Oct 5, 2022
1 parent 2fc5b01 commit d2a7f02
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 3 deletions.
1 change: 1 addition & 0 deletions gufe/tests/test_chemicalsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def test_sorting(solvated_complex, solvated_ligand):
class TestChemicalSystem(GufeTokenizableTestsMixin):

cls = ChemicalSystem
key = "ChemicalSystem-e1cb9ce41e88ee474cf5b962c9388159"

@pytest.fixture
def instance(self, solv_comp, toluene_ligand_comp):
Expand Down
11 changes: 10 additions & 1 deletion gufe/tests/test_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from gufe import AlchemicalNetwork, ChemicalSystem, Transformation

from .test_protocol import DummyProtocol, DummyProtocolResult
from .test_tokenization import GufeTokenizableTestsMixin


@pytest.fixture
Expand Down Expand Up @@ -70,7 +71,15 @@ def benzene_variants_star_map(
)


class TestAlchemicalNetwork:
class TestAlchemicalNetwork(GufeTokenizableTestsMixin):

cls = AlchemicalNetwork
key = "AlchemicalNetwork-1229d9766b685039f7581c3207f68b22"

@pytest.fixture
def instance(self, benzene_variants_star_map):
return benzene_variants_star_map

def test_init(self, benzene_variants_star_map):
alnet = benzene_variants_star_map

Expand Down
1 change: 1 addition & 0 deletions gufe/tests/test_proteincomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def assert_same_pdb_lines(in_file_path, out_file_path):
class TestProteinComponent(GufeTokenizableTestsMixin):

cls = ProteinComponent
key = "ProteinComponent-d8c07b1d44e93c4cae31c9deadf1fec4"

@pytest.fixture
def instance(self, PDB_181L_path):
Expand Down
14 changes: 14 additions & 0 deletions gufe/tests/test_protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def _create(
class TestProtocol(GufeTokenizableTestsMixin):

cls = DummyProtocol
key = "DummyProtocol-5660965464c9afdaac0ac4486a9566b3"

@pytest.fixture
def instance(self):
Expand Down Expand Up @@ -298,8 +299,14 @@ def test_graph(self, instance):
for neighbor in instance.graph.neighbors(node):
assert neighbor in node.dependencies

def test_key_stable(self, instance):
# for the DAG system, keys for `ProtocolUnit`s are based on UUIDs,
# so keys aren't stable up through `ProtocolDAG`s
pass

class TestProtocolDAG(ProtocolDAGTestsMixin):
cls = ProtocolDAG
key = "..."

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

class TestProtocolDAGResult(ProtocolDAGTestsMixin):
cls = ProtocolDAGResult
key = "..."

@pytest.fixture
def instance(self, protocol_dag):
Expand Down Expand Up @@ -354,6 +362,7 @@ def test_protocol_unit_failures(self, instance: ProtocolDAGResult):

class TestProtocolDAGResultFailure(ProtocolDAGTestsMixin):
cls = ProtocolDAGResult
key = "..."

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

class TestProtocolUnit(GufeTokenizableTestsMixin):
cls = SimulationUnit
key = "..."

@pytest.fixture
def instance(self, vacuum_ligand, solvated_ligand):
Expand All @@ -399,6 +409,10 @@ def instance(self, vacuum_ligand, solvated_ligand):

return SimulationUnit(name=f"simulation", initialization=alpha)

def test_key_stable(self, instance):
# for the DAG system, keys for `ProtocolUnit`s are based on UUIDs,
# so keys aren't stable up through `ProtocolDAG`s
pass

class NoDepUnit(ProtocolUnit):
@staticmethod
Expand Down
1 change: 1 addition & 0 deletions gufe/tests/test_smallmoleculecomponent.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def test_ensure_ofe_version():
class TestSmallMoleculeComponent(GufeTokenizableTestsMixin):

cls = SmallMoleculeComponent
key = "SmallMoleculeComponent-3a1b343b46ec93300bc74d83c133637a"

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

cls = SolventComponent
key = "SolventComponent-187d235ef3c2035d8505083c8ad7d0a0"

@pytest.fixture
def instance(self):
Expand Down
6 changes: 6 additions & 0 deletions gufe/tests/test_tokenization.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class GufeTokenizableTestsMixin(abc.ABC):

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

@pytest.fixture
def instance(self):
Expand Down Expand Up @@ -126,10 +127,14 @@ def test_to_shallow_dict_roundtrip(self, instance):
# include `np.nan`s
#assert ser == reser

def test_key_stable(self, instance):
assert self.key == instance.key


class TestGufeTokenizable(GufeTokenizableTestsMixin):

cls = Container
key = "Container-262ecded6cd03a619b99d667ded94c9e"

@pytest.fixture
def instance(self):
Expand Down Expand Up @@ -206,6 +211,7 @@ def test_notequal_different_type(self):
assert l1 != l2



class Outer:
class Inner:
pass
Expand Down
21 changes: 19 additions & 2 deletions gufe/tests/test_transformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from gufe.protocols.protocoldag import execute

from .test_protocol import DummyProtocol, DummyProtocolResult
from .test_tokenization import GufeTokenizableTestsMixin


@pytest.fixture
Expand All @@ -24,7 +25,15 @@ def complex_equilibrium(solvated_complex):
return NonTransformation(solvated_complex, protocol=DummyProtocol(settings=None))


class TestTransformation:
class TestTransformation(GufeTokenizableTestsMixin):

cls = Transformation
key = "Transformation-432a08368b0d8779397177ec25058543"

@pytest.fixture
def instance(self, absolute_transformation):
return absolute_transformation

def test_init(self, absolute_transformation, solvated_ligand, solvated_complex):
tnf = absolute_transformation

Expand Down Expand Up @@ -72,7 +81,15 @@ def test_dict_roundtrip(self):
...


class TestNonTransformation:
class TestNonTransformation(GufeTokenizableTestsMixin):

cls = NonTransformation
key = "NonTransformation-7e7a724f1b41d03f0f00dcc876172bad"

@pytest.fixture
def instance(self, complex_equilibrium):
return complex_equilibrium

def test_init(self, complex_equilibrium, solvated_complex):

ntnf = complex_equilibrium
Expand Down

0 comments on commit d2a7f02

Please sign in to comment.