home · contact · privacy
Minor tests refactoring.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 28 Apr 2024 23:22:17 +0000 (01:22 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 28 Apr 2024 23:22:17 +0000 (01:22 +0200)
tests/conditions.py
tests/processes.py
tests/utils.py

index db6c745da7a0fd6c4b7afbe9ac740f45fbf2572e..40d7c486fe7b05f2ed7f447e2cf58cd435546ebb 100644 (file)
@@ -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)
index c6f49265f9fdd8a9fc1d0930e36584a1a3285f59..06ed257689b0601e814a074c454cabe6ea0b6c98 100644 (file)
@@ -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)
index 34f429e9d1fcc6355cdb9d7eae8f60c9e125b2d5..545a2ba2881372e2bcd479ecd4e8cd2d7da2ed8c 100644 (file)
@@ -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)