Skip to content

Commit

Permalink
improve bad int message
Browse files Browse the repository at this point in the history
  • Loading branch information
djay committed Jan 15, 2025
1 parent d33092b commit 8c6ab20
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/plone/restapi/deserializer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ def parse_int(data, prop, default):
try:
return int(data.get(prop, default))
except (ValueError, TypeError):
raise BadRequest("Invalid %s" % prop)
raise BadRequest(f"Invalid {prop}: Not an integer")
6 changes: 5 additions & 1 deletion src/plone/restapi/tests/test_batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,11 @@ def test_batching_links_omitted_if_resulset_fits_in_single_batch(self):
def test_batching_badrequests(self):
response = self.api_session.get("/collection?b_size=php")
self.assertEqual(response.status_code, 400)
self.assertIn("invalid literal for int()", response.json()["message"])
self.assertIn("Invalid b_size", response.json()["message"])

response = self.api_session.get("/collection?b_size:list=1")
self.assertEqual(response.status_code, 400)
self.assertIn("Invalid b_size", response.json()["message"])


class TestBatchingDXFolders(TestBatchingDXBase):
Expand Down
2 changes: 1 addition & 1 deletion src/plone/restapi/tests/test_services_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,4 +246,4 @@ def test_navigation_badrequests(self):
)

self.assertEqual(response.status_code, 400)
self.assertIn("invalid literal for int()", response.json()["message"])
self.assertIn("Invalid expand.navigation.depth", response.json()["message"])

0 comments on commit 8c6ab20

Please sign in to comment.