- @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': [],
- '_versioned': {
- 'title': {0: title},
- 'description': {0: ''},
- 'effort': {0: 1.0}
- },
- 'conditions': conditions if conditions else [],
- 'disables': disables if disables else [],
- 'enables': enables if enables else [],
- 'blockers': blockers if blockers else []}
- return d
-
- def test_do_POST_condition(self) -> None:
- """Test POST /condition and its effect on GET /condition[s]."""
- # check empty POST fails
- self.check_post({}, '/condition', 400)
+ 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)
+
+ def test_POST_condition(self) -> None:
+ """Test (valid) POST /condition and its effect on GET /condition[s]."""