home · contact · privacy
Fix HTTP exception codes.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 27 Mar 2024 00:39:44 +0000 (01:39 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 27 Mar 2024 00:39:44 +0000 (01:39 +0100)
plomtask/exceptions.py
tests/days.py
tests/processes.py

index 379ae9feb751b99eb45e083d992f5509b6059a43..2e479d9cb144f8e25aafccdc09a75e20d75de6f3 100644 (file)
@@ -6,12 +6,12 @@ to merit its own module at this point.
 
 class HandledException(Exception):
     """To identify Exceptions based on expected (if faulty) user behavior."""
-    http_code = 400
+    http_code = 500
 
 
 class BadFormatException(HandledException):
     """To identify Exceptions on malformed inputs."""
-    http_code = 401
+    http_code = 400
 
 
 class NotFoundException(HandledException):
index 61a27edbb0d266b892182c241d769ae36a5846b4..06e4302d71aaba58867e961506806a792c1fe807 100644 (file)
@@ -97,7 +97,7 @@ class TestsWithServer(TestCaseWithServer):
         self.conn.request('GET', '/day?date=3000-01-01')
         self.assertEqual(self.conn.getresponse().status, 200)
         self.conn.request('GET', '/day?date=FOO')
-        self.assertEqual(self.conn.getresponse().status, 401)
+        self.assertEqual(self.conn.getresponse().status, 400)
         self.conn.request('GET', '/calendar')
         self.assertEqual(self.conn.getresponse().status, 200)
         self.conn.request('GET', '/calendar?start=&end=')
@@ -107,4 +107,4 @@ class TestsWithServer(TestCaseWithServer):
         self.conn.request('GET', '/calendar?start=2024-01-01&end=2025-01-01')
         self.assertEqual(self.conn.getresponse().status, 200)
         self.conn.request('GET', '/calendar?start=foo')
-        self.assertEqual(self.conn.getresponse().status, 401)
+        self.assertEqual(self.conn.getresponse().status, 400)
index 399eb9dfc354e73db88858a16dc10178f2825297..0488efc0f2a6b661feeae79d454843dd97c809ab 100644 (file)
@@ -81,11 +81,11 @@ class TestsWithServer(TestCaseWithServer):
                               body=encoded_form_data, headers=headers)
             self.assertEqual(self.conn.getresponse().status, expect)
         form_data = {'title': 'foo', 'description': 'foo', 'effort': 1.0}
-        post_data_to_expect(form_data, '/process?id=FOO', 401)
+        post_data_to_expect(form_data, '/process?id=FOO', 400)
         form_data['effort'] = 'foo'
-        post_data_to_expect(form_data, '/process?id=', 401)
+        post_data_to_expect(form_data, '/process?id=', 400)
         form_data['effort'] = None
-        post_data_to_expect(form_data, '/process?id=', 401)
+        post_data_to_expect(form_data, '/process?id=', 400)
         form_data = {'title': None, 'description': 1, 'effort': 1.0}
         post_data_to_expect(form_data, '/process?id=', 302)
         retrieved = Process.by_id(self.db_conn, 1)
@@ -102,6 +102,6 @@ class TestsWithServer(TestCaseWithServer):
         self.conn.request('GET', '/process?id=0')
         self.assertEqual(self.conn.getresponse().status, 200)
         self.conn.request('GET', '/process?id=FOO')
-        self.assertEqual(self.conn.getresponse().status, 401)
+        self.assertEqual(self.conn.getresponse().status, 400)
         self.conn.request('GET', '/processes')
         self.assertEqual(self.conn.getresponse().status, 200)