X-Git-Url: https://plomlompom.com/repos/feed.xml?a=blobdiff_plain;f=tests%2Futils.py;h=ed4101a6c32a52d1e26fadb99c35fd8c44d2178a;hb=b56761522f6ec874fde1eb9d4d69d8093fe70227;hp=f473c180ba565355a3b6ac0a03acb85d2fa307de;hpb=32314e4c0a7e268eeeee5ffc3604c68ce09d3ce7;p=plomtask diff --git a/tests/utils.py b/tests/utils.py index f473c18..ed4101a 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -327,6 +327,33 @@ class TestCaseWithServer(TestCaseWithDB): self.server_thread.join() super().tearDown() + @staticmethod + def proc_as_dict(id_: int = 1, + title: str = 'A', + description: str = '', + effort: float = 1.0, + 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: description}, + 'effort': {0: effort} + }, + 'conditions': conditions if conditions else [], + 'disables': disables if disables else [], + 'enables': enables if enables else [], + 'blockers': blockers if blockers else []} + return d + def check_redirect(self, target: str) -> None: """Check that self.conn answers with a 302 redirect to target.""" response = self.conn.getresponse()