class TestsSansDB(TestCaseSansDB):
"""Tests requiring no DB setup."""
checked_class = Condition
-
- def test_Condition_id_setting(self) -> None:
- """Test .id_ being set and its legal range being enforced."""
- self.check_id_setting()
-
- def test_Condition_versioned_defaults(self) -> None:
- """Test defaults of VersionedAttributes."""
- self.check_versioned_defaults({
- 'title': 'UNNAMED',
- 'description': ''})
+ do_id_test = True
+ versioned_defaults_to_test = {'title': 'UNNAMED', 'description': ''}
class TestsWithDB(TestCaseWithDB):
class TestsSansDB(TestCaseSansDB):
"""Module tests not requiring DB setup."""
checked_class = Process
-
- def test_Process_id_setting(self) -> None:
- """Test .id_ being set and its legal range being enforced."""
- self.check_id_setting()
-
- def test_Process_versioned_defaults(self) -> None:
- """Test defaults of VersionedAttributes."""
- self.check_versioned_defaults({
- 'title': 'UNNAMED',
- 'description': '',
- 'effort': 1.0})
+ do_id_test = True
+ versioned_defaults_to_test = {'title': 'UNNAMED', 'description': '',
+ 'effort': 1.0}
class TestsSansDBProcessStep(TestCaseSansDB):
"""Module tests not requiring DB setup."""
checked_class = ProcessStep
-
- def test_ProcessStep_id_setting(self) -> None:
- """Test .id_ being set and its legal range being enforced."""
- self.check_id_setting(2, 3, 4)
+ do_id_test = True
+ default_init_args = [2, 3, 4]
class TestsWithDB(TestCaseWithDB):
class TestCaseSansDB(TestCase):
"""Tests requiring no DB setup."""
checked_class: Any
+ do_id_test: bool = False
+ default_init_args: list[Any] = []
+ versioned_defaults_to_test: dict[str, str | float] = {}
- def check_id_setting(self, *args: Any) -> None:
+ def test_id_setting(self) -> None:
"""Test .id_ being set and its legal range being enforced."""
+ if not self.do_id_test:
+ return
with self.assertRaises(HandledException):
- self.checked_class(0, *args)
- obj = self.checked_class(5, *args)
+ self.checked_class(0, *self.default_init_args)
+ obj = self.checked_class(5, *self.default_init_args)
self.assertEqual(obj.id_, 5)
- def check_versioned_defaults(self, attrs: dict[str, Any]) -> None:
+ def test_versioned_defaults(self) -> None:
"""Test defaults of VersionedAttributes."""
- obj = self.checked_class(None)
- for k, v in attrs.items():
+ if len(self.versioned_defaults_to_test) == 0:
+ return
+ obj = self.checked_class(1, *self.default_init_args)
+ for k, v in self.versioned_defaults_to_test.items():
self.assertEqual(getattr(obj, k).newest, v)