From: Christian Heller Date: Wed, 27 Mar 2024 00:39:44 +0000 (+0100) Subject: Fix HTTP exception codes. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/static/%7B%7Bdb.prefix%7D%7D/todos?a=commitdiff_plain;h=be5fe79322159cee339baa7919e38774298ebd95;p=plomtask Fix HTTP exception codes. --- diff --git a/plomtask/exceptions.py b/plomtask/exceptions.py index 379ae9f..2e479d9 100644 --- a/plomtask/exceptions.py +++ b/plomtask/exceptions.py @@ -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): diff --git a/tests/days.py b/tests/days.py index 61a27ed..06e4302 100644 --- a/tests/days.py +++ b/tests/days.py @@ -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) diff --git a/tests/processes.py b/tests/processes.py index 399eb9d..0488efc 100644 --- a/tests/processes.py +++ b/tests/processes.py @@ -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)