- def test_do_POST_condition(self) -> None:
- """Test POST /condition and its effect on the database."""
-
- def check(path: str, expected: dict[str, object]) -> None:
- self.conn.request('GET', path)
- response = self.conn.getresponse()
- self.assertEqual(response.status, 200)
- retrieved = json_loads(response.read().decode())
- self.blank_history_keys_in(retrieved)
- self.assertEqual(expected, retrieved)
+ @staticmethod
+ def cond_as_dict(id_: int = 1,
+ is_active: bool = False,
+ titles: None | list[str] = None,
+ descriptions: None | list[str] = None
+ ) -> dict[str, object]:
+ """Return JSON of Condition to expect."""
+ d = {'id': id_,
+ 'is_active': is_active,
+ 'title': {'history': {}, 'parent_id': id_},
+ 'description': {'history': {}, 'parent_id': id_}}
+ titles = titles if titles else []
+ descriptions = descriptions if descriptions else []
+ for i, title in enumerate(titles):
+ assert isinstance(d['title'], dict)
+ d['title']['history'][f'[{i}]'] = title
+ for i, description in enumerate(descriptions):
+ assert isinstance(d['description'], dict)
+ d['description']['history'][f'[{i}]'] = description
+ return d
+
+ @staticmethod
+ def proc_as_dict(id_: int = 1,
+ title: str = 'A',
+ enables: None | list[dict[str, object]] = None,
+ disables: None | list[dict[str, object]] = None,
+ conditions: None | list[dict[str, object]] = None,
+ blockers: None | list[dict[str, object]] = None
+ ) -> dict[str, object]:
+ """Return JSON of Process to expect."""
+ # pylint: disable=too-many-arguments
+ d = {'id': id_,
+ 'calendarize': False,
+ 'suppressed_steps': [],
+ 'explicit_steps': [],
+ 'title': {'history': {'[0]': title}, 'parent_id': id_},
+ 'effort': {'history': {'[0]': 1.0}, 'parent_id': id_},
+ 'description': {'history': {'[0]': ''}, 'parent_id': id_},
+ 'conditions': conditions if conditions else [],
+ 'disables': disables if disables else [],
+ 'enables': enables if enables else [],
+ 'blockers': blockers if blockers else []}
+ return d