X-Git-Url: https://plomlompom.com/repos/foo.html?a=blobdiff_plain;ds=inline;f=tests%2Fprocesses.py;h=5c3e70364d32b679a339b9ac9ed591ad3295e365;hb=bdb93117ce0f2b08b7b70cf43ac086afa4689c0f;hp=34f6427e4d06152a17f035672061757cce203cac;hpb=c5449a0b00f8865b1129ed56bdd16f1cc055bc87;p=plomtask
diff --git a/tests/processes.py b/tests/processes.py
index 34f6427..5c3e703 100644
--- a/tests/processes.py
+++ b/tests/processes.py
@@ -9,7 +9,6 @@ from plomtask.todos import Todo
class TestsSansDB(TestCaseSansDB):
"""Module tests not requiring DB setup."""
checked_class = Process
- do_id_test = True
versioned_defaults_to_test = {'title': 'UNNAMED', 'description': '',
'effort': 1.0}
@@ -17,7 +16,6 @@ class TestsSansDB(TestCaseSansDB):
class TestsSansDBProcessStep(TestCaseSansDB):
"""Module tests not requiring DB setup."""
checked_class = ProcessStep
- do_id_test = True
default_init_args = [2, 3, 4]
@@ -58,17 +56,15 @@ class TestsWithDB(TestCaseWithDB):
def test_Process_conditions_saving(self) -> None:
"""Test .save/.save_core."""
p, set1, set2, set3 = self.p_of_conditions()
+ assert p.id_ is not None
r = Process.by_id(self.db_conn, p.id_)
self.assertEqual(sorted(r.conditions), sorted(set1))
self.assertEqual(sorted(r.enables), sorted(set2))
self.assertEqual(sorted(r.disables), sorted(set3))
- def test_Process_from_table_row(self) -> None:
- """Test .from_table_row() properly reads in class from DB"""
- self.check_from_table_row()
- self.check_versioned_from_table_row('title', str)
- self.check_versioned_from_table_row('description', str)
- self.check_versioned_from_table_row('effort', float)
+ def test_from_table_row(self) -> None:
+ """Test .from_table_row() properly reads in class from DB."""
+ super().test_from_table_row()
p, set1, set2, set3 = self.p_of_conditions()
p.save(self.db_conn)
assert isinstance(p.id_, int)
@@ -182,25 +178,9 @@ class TestsWithDB(TestCaseWithDB):
method(self.db_conn, [c1.id_, c2.id_])
self.assertEqual(getattr(p, target), [c1, c2])
- def test_Process_by_id(self) -> None:
- """Test .by_id(), including creation"""
- self.check_by_id()
-
- def test_Process_all(self) -> None:
- """Test .all()."""
- self.check_all()
-
- def test_Process_singularity(self) -> None:
- """Test pointers made for single object keep pointing to it."""
- self.check_singularity('conditions', [Condition(None)])
-
- def test_Process_versioned_attributes_singularity(self) -> None:
- """Test behavior of VersionedAttributes on saving (with .title)."""
- self.check_versioned_singularity()
-
- def test_Process_removal(self) -> None:
+ def test_remove(self) -> None:
"""Test removal of Processes and ProcessSteps."""
- self.check_remove()
+ super().test_remove()
p1, p2, p3 = self.three_processes()
assert isinstance(p1.id_, int)
assert isinstance(p2.id_, int)
@@ -212,13 +192,15 @@ class TestsWithDB(TestCaseWithDB):
p1.remove(self.db_conn)
p2.set_steps(self.db_conn, [])
with self.assertRaises(NotFoundException):
+ assert step_id is not None
ProcessStep.by_id(self.db_conn, step_id)
p1.remove(self.db_conn)
step = ProcessStep(None, p2.id_, p3.id_, None)
- step_id = step.id_
p2.set_steps(self.db_conn, [step])
+ step_id = step.id_
p2.remove(self.db_conn)
with self.assertRaises(NotFoundException):
+ assert step_id is not None
ProcessStep.by_id(self.db_conn, step_id)
todo = Todo(None, p3, False, '2024-01-01')
todo.save(self.db_conn)
@@ -231,33 +213,25 @@ class TestsWithDB(TestCaseWithDB):
class TestsWithDBForProcessStep(TestCaseWithDB):
"""Module tests requiring DB setup."""
checked_class = ProcessStep
- default_init_kwargs = {'owner_id': 2, 'step_process_id': 3,
- 'parent_step_id': 4}
+ default_init_kwargs = {'owner_id': 1, 'step_process_id': 2,
+ 'parent_step_id': 3}
def setUp(self) -> None:
super().setUp()
- p = Process(1)
- p.save(self.db_conn)
- p = Process(2)
- p.save(self.db_conn)
+ self.p1 = Process(1)
+ self.p1.save(self.db_conn)
- def test_saving_and_caching(self) -> None:
- """Test storage and initialization of instances and attributes."""
- self.check_saving_and_caching(id_=1, **self.default_init_kwargs)
-
- def test_ProcessStep_remove(self) -> None:
+ def test_remove(self) -> None:
"""Test .remove and unsetting of owner's .explicit_steps entry."""
- p1 = Process(None)
- p2 = Process(None)
- p1.save(self.db_conn)
+ p2 = Process(2)
p2.save(self.db_conn)
- assert isinstance(p1.id_, int)
+ assert isinstance(self.p1.id_, int)
assert isinstance(p2.id_, int)
- step = ProcessStep(None, p1.id_, p2.id_, None)
- p1.set_steps(self.db_conn, [step])
+ step = ProcessStep(None, self.p1.id_, p2.id_, None)
+ self.p1.set_steps(self.db_conn, [step])
step.remove(self.db_conn)
- self.assertEqual(p1.explicit_steps, [])
- self.check_storage([])
+ self.assertEqual(self.p1.explicit_steps, [])
+ self.check_identity_with_cache_and_db([])
class TestsWithServer(TestCaseWithServer):
@@ -279,7 +253,8 @@ class TestsWithServer(TestCaseWithServer):
form_data = {'title': 'foo', 'description': 'foo', 'effort': 1.0}
self.post_process(2, form_data | {'condition': []})
self.check_post(form_data | {'condition': [1]}, '/process?id=', 404)
- self.check_post({'title': 'foo', 'description': 'foo'},
+ self.check_post({'title': 'foo', 'description': 'foo',
+ 'is_active': False},
'/condition', 302, '/condition?id=1')
self.post_process(3, form_data | {'condition': [1]})
self.post_process(4, form_data | {'disables': [1]})
@@ -311,6 +286,7 @@ class TestsWithServer(TestCaseWithServer):
self.post_process(1, form_data_1)
retrieved_process = Process.by_id(self.db_conn, 1)
self.assertEqual(retrieved_process.explicit_steps, [])
+ assert retrieved_step_id is not None
with self.assertRaises(NotFoundException):
ProcessStep.by_id(self.db_conn, retrieved_step_id)
# post new first (top_level) step of process 3 to process 1