Skip to content

Commit 3557f64

Browse files
Merge pull request #93 from ChristianProgrammeert/development
Development onto main
2 parents ecbc7e0 + 54b60d4 commit 3557f64

4 files changed

Lines changed: 8 additions & 8 deletions

File tree

app/error_handling.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
BOOL_ERROR_MESSAGE = "ValueError: boolean values expected [True,False,1,0]. rage_inducing | action_packed | skill_based | mature_themes | open_world | multiplayer"
44

55
def raise_request_error(message):
6-
"""Raises HTTPError with code 422 for bad input with a custom message."""
7-
raise HTTPException(status_code=422, detail=message)
6+
"""Raises HTTPError with code 400 for bad input with a custom message."""
7+
raise HTTPException(status_code=400, detail=message)
88

99
def raise_boolean_error():
10-
"""Raises HTTPError with code 422 for when input values aren't booleans."""
11-
raise HTTPException(status_code=422, detail=BOOL_ERROR_MESSAGE)
10+
"""Raises HTTPError with code 400 for when input values aren't booleans."""
11+
raise HTTPException(status_code=400, detail=BOOL_ERROR_MESSAGE)

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from app import input_parser as parser
1010
from app.database import get_db
1111

12-
VERSION = "1.1.1"
12+
VERSION = "1.1.2"
1313
# Prometheus metrics
1414
REQUEST_COUNT = Counter("http_requests_total", "Total HTTP requests", ["method", "endpoint", "status"])
1515
REQUEST_LATENCY = Summary("http_request_latency_seconds", "Request latency in seconds")

test/test_error_handling.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ class TestRequestErrorHandling(unittest.TestCase):
66
def test_request_error_handling(self):
77
with self.assertRaises(HTTPException) as _:
88
error.raise_request_error("")
9-
self.assertEqual(_.exception.status_code,422,msg = "Wrong status code was given")
9+
self.assertEqual(_.exception.status_code,400,msg = "Wrong status code was given")
1010

1111
class TestBooleanErrorHandling(unittest.TestCase):
1212
def test_boolean_error_handling(self):
1313
with self.assertRaises(HTTPException) as _:
1414
error.raise_boolean_error()
15-
self.assertEqual(_.exception.status_code,422,msg = "Wrong status code was given")
15+
self.assertEqual(_.exception.status_code,400,msg = "Wrong status code was given")

test/test_input_parser.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ def test_parse_input(self):
3232
def test_wrong_input(self):
3333
with self.assertRaises(HTTPException) as _:
3434
TestClass = parser.parse_input([1,"a",False,{"Name":"Test"}])
35-
self.assertEqual(_.exception.status_code,422,msg = "Incorrect or no error raised with wrong datatypes")
35+
self.assertEqual(_.exception.status_code,400,msg = "Incorrect or no error raised with wrong datatypes")

0 commit comments

Comments
 (0)