+ @classmethod
+ def GET_condition_dict(cls, cond: dict[str, object]) -> dict[str, object]:
+ """Return JSON of GET /condition to expect."""
+ return {'is_new': False,
+ 'enabled_processes': [],
+ 'disabled_processes': [],
+ 'enabling_processes': [],
+ 'disabling_processes': [],
+ 'condition': cond['id'],
+ '_library': {'Condition': cls.as_refs([cond])}}
+
+ @classmethod
+ def GET_conditions_dict(cls, conds: list[dict[str, object]]
+ ) -> dict[str, object]:
+ """Return JSON of GET /conditions to expect."""
+ library = {'Condition': cls.as_refs(conds)} if conds else {}
+ d: dict[str, object] = {'conditions': cls.as_id_list(conds),
+ 'sort_by': 'title',
+ 'pattern': '',
+ '_library': library}
+ return d
+
+ def test_fail_POST_condition(self) -> None:
+ """Test malformed/illegal POST /condition requests."""
+ # check invalid POST payloads
+ url = '/condition'
+ self.check_post({}, url, 400)
+ self.check_post({'title': ''}, url, 400)
+ self.check_post({'title': '', 'description': ''}, url, 400)
+ self.check_post({'title': '', 'is_active': False}, url, 400)
+ self.check_post({'description': '', 'is_active': False}, url, 400)
+ # check valid POST payload on bad paths
+ valid_payload = {'title': '', 'description': '', 'is_active': False}
+ self.check_post(valid_payload, '/condition?id=foo', 400)
+