X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=tests%2Fconditions.py;h=6538e87019bfa7bffa0d8fccb22f8981500943d1;hb=23012cd370777b60a25839788d131173d2abee91;hp=3b95de1f3fe7e89cc30a14f149983d14ad690962;hpb=2c3365447f36c26f2f55cc2a1b42a1e3ad0a8db9;p=plomtask diff --git a/tests/conditions.py b/tests/conditions.py index 3b95de1..6538e87 100644 --- a/tests/conditions.py +++ b/tests/conditions.py @@ -1,7 +1,8 @@ """Test Conditions module.""" from tests.utils import TestCaseWithDB, TestCaseWithServer from plomtask.conditions import Condition -from plomtask.exceptions import NotFoundException +from plomtask.processes import Process +from plomtask.exceptions import NotFoundException, HandledException class TestsWithDB(TestCaseWithDB): @@ -36,6 +37,22 @@ class TestsWithDB(TestCaseWithDB): condition_retrieved = Condition.by_id(self.db_conn, 1) self.assertEqual(True, condition_retrieved.is_active) + def test_Condition_removal(self) -> None: + """Test removal of Condition.""" + cond = Condition(None, False) + cond.save(self.db_conn) + assert isinstance(cond.id_, int) + proc = Process(None) + proc.save(self.db_conn) + proc.set_conditions(self.db_conn, [cond.id_], 'conditions') + proc.save(self.db_conn) + with self.assertRaises(HandledException): + cond.remove(self.db_conn) + proc.set_conditions(self.db_conn, [], 'conditions') + proc.save(self.db_conn) + cond.remove(self.db_conn) + self.assertEqual(Condition.all(self.db_conn), []) + class TestsWithServer(TestCaseWithServer): """Module tests against our HTTP server/handler (and database)."""