From: Christian Heller Date: Sun, 28 Apr 2024 23:22:17 +0000 (+0200) Subject: Minor tests refactoring. X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/%7B%7Bprefix%7D%7D/copy_structured?a=commitdiff_plain;h=8c0cbef8f467d125ba7c987b3eb1f5bef7d38120;p=plomtask Minor tests refactoring. --- diff --git a/tests/conditions.py b/tests/conditions.py index db6c745..40d7c48 100644 --- a/tests/conditions.py +++ b/tests/conditions.py @@ -70,8 +70,7 @@ class TestsWithServer(TestCaseWithServer): def test_do_GET(self) -> None: """Test /condition and /conditions response codes.""" - self.check_get('/condition', 200) - self.check_get('/condition?id=', 200) - self.check_get('/condition?id=0', 500) - self.check_get('/condition?id=FOO', 400) + form_data = {'title': 'foo', 'description': 'foo'} + self.check_post(form_data, '/condition', 302, '/condition?id=1') + self.check_get_defaults('/condition') self.check_get('/conditions', 200) diff --git a/tests/processes.py b/tests/processes.py index c6f4926..06ed257 100644 --- a/tests/processes.py +++ b/tests/processes.py @@ -222,8 +222,7 @@ class TestsWithServer(TestCaseWithServer): def test_do_GET(self) -> None: """Test /process and /processes response codes.""" - self.check_get('/process', 200) - self.check_get('/process?id=', 200) - self.check_get('/process?id=0', 500) - self.check_get('/process?id=FOO', 400) + form_data = {'title': 'foo', 'description': 'foo', 'effort': 1.1} + self.check_post(form_data, '/process?id=', 302, '/process?id=1') + self.check_get_defaults('/process') self.check_get('/processes', 200) diff --git a/tests/utils.py b/tests/utils.py index 34f429e..545a2ba 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -76,3 +76,11 @@ class TestCaseWithServer(TestCaseWithDB): self.check_redirect(redirect_location) else: self.assertEqual(self.conn.getresponse().status, expected_code) + + def check_get_defaults(self, path: str) -> None: + """Some standard model paths to test.""" + self.check_get(path, 200) + self.check_get(f'{path}?id=', 200) + self.check_get(f'{path}?id=foo', 400) + self.check_get(f'/{path}?id=0', 500) + self.check_get(f'{path}?id=1', 200)