home · contact · privacy
Extend Todo tests to also run ID checking from TestCaseSansDB.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 17 Jun 2024 12:15:11 +0000 (14:15 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 17 Jun 2024 12:15:11 +0000 (14:15 +0200)
tests/todos.py

index 9317c398b255c51b14046f888b3de4a24b70238d..b73f5d7fcb7b0a2c53256593e8e9867e86d2b89e 100644 (file)
@@ -1,5 +1,5 @@
 """Test Todos module."""
 """Test Todos module."""
-from tests.utils import TestCaseWithDB, TestCaseWithServer
+from tests.utils import TestCaseSansDB, TestCaseWithDB, TestCaseWithServer
 from plomtask.todos import Todo, TodoNode
 from plomtask.processes import Process, ProcessStep
 from plomtask.conditions import Condition
 from plomtask.todos import Todo, TodoNode
 from plomtask.processes import Process, ProcessStep
 from plomtask.conditions import Condition
@@ -7,11 +7,19 @@ from plomtask.exceptions import (NotFoundException, BadFormatException,
                                  HandledException)
 
 
                                  HandledException)
 
 
-class TestsWithDB(TestCaseWithDB):
-    """Tests requiring DB, but not server setup."""
+class TestsWithDB(TestCaseWithDB, TestCaseSansDB):
+    """Tests requiring DB, but not server setup.
+
+    NB: We subclass TestCaseSansDB too, to pull in its .test_id_setting, which
+    for Todo wouldn't run without a DB being set up due to the need for
+    Processes with set IDs.
+    """
     checked_class = Todo
     default_init_kwargs = {'process': None, 'is_done': False,
                            'date': '2024-01-01'}
     checked_class = Todo
     default_init_kwargs = {'process': None, 'is_done': False,
                            'date': '2024-01-01'}
+    # solely used for TestCaseSansDB.test_id_setting
+    default_init_args = [None, False, '2024-01-01']
+    do_id_test = True
 
     def setUp(self) -> None:
         super().setUp()
 
     def setUp(self) -> None:
         super().setUp()
@@ -24,6 +32,7 @@ class TestsWithDB(TestCaseWithDB):
         self.cond2 = Condition(None)
         self.cond2.save(self.db_conn)
         self.default_init_kwargs['process'] = self.proc
         self.cond2 = Condition(None)
         self.cond2.save(self.db_conn)
         self.default_init_kwargs['process'] = self.proc
+        self.default_init_args[0] = self.proc
 
     def test_Todo_init(self) -> None:
         """Test creation of Todo and what they default to."""
 
     def test_Todo_init(self) -> None:
         """Test creation of Todo and what they default to."""