[Chore] Linted Files (#150)

Co-authored-by: Tim Lorsbach <tim@lorsba.ch>
Reviewed-on: enviPath/enviPy#150
This commit is contained in:
2025-10-09 07:25:13 +13:00
parent 22f0bbe10b
commit afeb56622c
50 changed files with 5616 additions and 4408 deletions

View File

@ -10,127 +10,127 @@ class ReactionTest(TestCase):
@classmethod
def setUpClass(cls):
super(ReactionTest, cls).setUpClass()
cls.user = User.objects.get(username='anonymous')
cls.package = PackageManager.create_package(cls.user, 'Anon Test Package', 'No Desc')
cls.user = User.objects.get(username="anonymous")
cls.package = PackageManager.create_package(cls.user, "Anon Test Package", "No Desc")
def test_smoke(self):
educt = Compound.create(
self.package,
smiles='C(CCl)Cl',
name='1,2-Dichloroethane',
description='Eawag BBD compound c0001'
smiles="C(CCl)Cl",
name="1,2-Dichloroethane",
description="Eawag BBD compound c0001",
).default_structure
product = Compound.create(
self.package,
smiles='C(CO)Cl',
name='2-Chloroethanol',
description='Eawag BBD compound c0005'
smiles="C(CO)Cl",
name="2-Chloroethanol",
description="Eawag BBD compound c0005",
).default_structure
r = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
name="Eawag BBD reaction r0001",
educts=[educt],
products=[product],
multi_step=False
multi_step=False,
)
self.assertEqual(r.smirks(), 'C(CCl)Cl>>C(CO)Cl')
self.assertEqual(r.name, 'Eawag BBD reaction r0001')
self.assertEqual(r.description, 'no description')
self.assertEqual(r.smirks(), "C(CCl)Cl>>C(CO)Cl")
self.assertEqual(r.name, "Eawag BBD reaction r0001")
self.assertEqual(r.description, "no description")
def test_string_educts_and_products(self):
r = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
educts=['C(CCl)Cl'],
products=['C(CO)Cl'],
multi_step=False
name="Eawag BBD reaction r0001",
educts=["C(CCl)Cl"],
products=["C(CO)Cl"],
multi_step=False,
)
self.assertEqual(r.smirks(), 'C(CCl)Cl>>C(CO)Cl')
self.assertEqual(r.smirks(), "C(CCl)Cl>>C(CO)Cl")
def test_missing_smiles(self):
educt = Compound.create(
self.package,
smiles='C(CCl)Cl',
name='1,2-Dichloroethane',
description='Eawag BBD compound c0001'
smiles="C(CCl)Cl",
name="1,2-Dichloroethane",
description="Eawag BBD compound c0001",
).default_structure
product = Compound.create(
self.package,
smiles='C(CO)Cl',
name='2-Chloroethanol',
description='Eawag BBD compound c0005'
smiles="C(CO)Cl",
name="2-Chloroethanol",
description="Eawag BBD compound c0005",
).default_structure
with self.assertRaises(ValueError):
_ = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
name="Eawag BBD reaction r0001",
educts=[educt],
products=[],
multi_step=False
multi_step=False,
)
with self.assertRaises(ValueError):
_ = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
name="Eawag BBD reaction r0001",
educts=[],
products=[product],
multi_step=False
multi_step=False,
)
with self.assertRaises(ValueError):
_ = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
name="Eawag BBD reaction r0001",
educts=[],
products=[],
multi_step=False
multi_step=False,
)
def test_empty_name_and_description_are_ignored(self):
r = Reaction.create(
package=self.package,
name='',
description='',
educts=['C(CCl)Cl'],
products=['C(CO)Cl'],
name="",
description="",
educts=["C(CCl)Cl"],
products=["C(CO)Cl"],
multi_step=False,
)
self.assertEqual(r.name, 'no name')
self.assertEqual(r.description, 'no description')
self.assertEqual(r.name, "no name")
self.assertEqual(r.description, "no description")
def test_deduplication(self):
rule = Rule.create(
package=self.package,
rule_type='SimpleAmbitRule',
name='bt0022-2833',
description='Dihalomethyl derivative + Halomethyl derivative > 1-Halo-1-methylalcohol derivative + 1-Methylalcohol derivative',
smirks='[H:5][C:1]([#6:6])([#1,#9,#17,#35,#53:4])[#9,#17,#35,#53]>>[H:5][C:1]([#6:6])([#8])[#1,#9,#17,#35,#53:4]',
rule_type="SimpleAmbitRule",
name="bt0022-2833",
description="Dihalomethyl derivative + Halomethyl derivative > 1-Halo-1-methylalcohol derivative + 1-Methylalcohol derivative",
smirks="[H:5][C:1]([#6:6])([#1,#9,#17,#35,#53:4])[#9,#17,#35,#53]>>[H:5][C:1]([#6:6])([#8])[#1,#9,#17,#35,#53:4]",
)
r1 = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
educts=['C(CCl)Cl'],
products=['C(CO)Cl'],
name="Eawag BBD reaction r0001",
educts=["C(CCl)Cl"],
products=["C(CO)Cl"],
rules=[rule],
multi_step=False
multi_step=False,
)
r2 = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
educts=['C(CCl)Cl'],
products=['C(CO)Cl'],
name="Eawag BBD reaction r0001",
educts=["C(CCl)Cl"],
products=["C(CO)Cl"],
rules=[rule],
multi_step=False
multi_step=False,
)
# Check if create detects that this Compound already exist
@ -141,18 +141,18 @@ class ReactionTest(TestCase):
def test_deduplication_without_rules(self):
r1 = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
educts=['C(CCl)Cl'],
products=['C(CO)Cl'],
multi_step=False
name="Eawag BBD reaction r0001",
educts=["C(CCl)Cl"],
products=["C(CO)Cl"],
multi_step=False,
)
r2 = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
educts=['C(CCl)Cl'],
products=['C(CO)Cl'],
multi_step=False
name="Eawag BBD reaction r0001",
educts=["C(CCl)Cl"],
products=["C(CO)Cl"],
multi_step=False,
)
# Check if create detects that this Compound already exist
@ -164,19 +164,19 @@ class ReactionTest(TestCase):
with self.assertRaises(ValueError):
_ = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
educts=['ASDF'],
products=['C(CO)Cl'],
multi_step=False
name="Eawag BBD reaction r0001",
educts=["ASDF"],
products=["C(CO)Cl"],
multi_step=False,
)
def test_delete(self):
r = Reaction.create(
package=self.package,
name='Eawag BBD reaction r0001',
educts=['C(CCl)Cl'],
products=['C(CO)Cl'],
multi_step=False
name="Eawag BBD reaction r0001",
educts=["C(CCl)Cl"],
products=["C(CO)Cl"],
multi_step=False,
)
r.delete()