From 8c0cbef8f467d125ba7c987b3eb1f5bef7d38120 Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 29 Apr 2024 01:22:17 +0200
Subject: [PATCH] Minor tests refactoring.

---
 tests/conditions.py | 7 +++----
 tests/processes.py  | 7 +++----
 tests/utils.py      | 8 ++++++++
 3 files changed, 14 insertions(+), 8 deletions(-)

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)
-- 
2.30.2