X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=tests%2Fprocesses.py;h=bda62750442501445fae1883f9a8a2b280aa18f8;hb=6b329a28bb4aec8d1846f5cc5402ed6fca5eb3da;hp=87b0b09809398ab1a5aa59af78bf1ac11d8bf1e4;hpb=982d712cbf12acde21ce448e0d1ed28468f1c90e;p=plomtask diff --git a/tests/processes.py b/tests/processes.py index 87b0b09..bda6275 100644 --- a/tests/processes.py +++ b/tests/processes.py @@ -2,7 +2,7 @@ from unittest import TestCase from typing import Any from tests.utils import TestCaseWithDB, TestCaseWithServer -from plomtask.processes import Process +from plomtask.processes import Process, ProcessStep from plomtask.exceptions import NotFoundException, BadFormatException @@ -39,17 +39,6 @@ class TestsWithDB(TestCaseWithDB): self.assertEqual(p.id_, Process.by_id(self.db_conn, 5, create=False).id_) - def test_Process_versioned_attributes(self) -> None: - """Test behavior of VersionedAttributes on saving (with .title).""" - p = Process(None) - p.save_without_steps(self.db_conn) - p.title.set('named') - p_loaded = Process.by_id(self.db_conn, p.id_) - self.assertNotEqual(p.title.history, p_loaded.title.history) - p.save_without_steps(self.db_conn) - p_loaded = Process.by_id(self.db_conn, p.id_) - self.assertEqual(p.title.history, p_loaded.title.history) - def test_Process_steps(self) -> None: """Test addition, nesting, and non-recursion of ProcessSteps""" p_1 = Process(1) @@ -128,6 +117,38 @@ class TestsWithDB(TestCaseWithDB): self.assertEqual({p_1.id_, p_2.id_}, set(p.id_ for p in Process.all(self.db_conn))) + def test_ProcessStep_singularity(self) -> None: + """Test pointers made for single object keep pointing to it.""" + p_1 = Process(None) + p_1.save_without_steps(self.db_conn) + p_2 = Process(None) + p_2.save_without_steps(self.db_conn) + assert p_2.id_ is not None + step = p_1.add_step(self.db_conn, None, p_2.id_, None) + assert step.id_ is not None + step_retrieved = ProcessStep.by_id(self.db_conn, step.id_) + step.parent_step_id = 99 + self.assertEqual(step.parent_step_id, step_retrieved.parent_step_id) + + def test_Process_singularity(self) -> None: + """Test pointers made for single object keep pointing to it.""" + p_1 = Process(None) + p_1.save_without_steps(self.db_conn) + p_2 = Process(None) + p_2.save_without_steps(self.db_conn) + assert p_2.id_ is not None + p_1.add_step(self.db_conn, None, p_2.id_, None) + p_retrieved = Process.by_id(self.db_conn, p_1.id_) + self.assertEqual(p_1.explicit_steps, p_retrieved.explicit_steps) + + def test_Process_versioned_attributes_singularity(self) -> None: + """Test behavior of VersionedAttributes on saving (with .title).""" + p = Process(None) + p.save_without_steps(self.db_conn) + p.title.set('named') + p_loaded = Process.by_id(self.db_conn, p.id_) + self.assertEqual(p.title.history, p_loaded.title.history) + class TestsWithServer(TestCaseWithServer): """Module tests against our HTTP server/handler (and database)."""