Skip to content

Commit

Permalink
dont pass __range_header param to model validator if value is non-tru…
Browse files Browse the repository at this point in the history
…thy (#125)
  • Loading branch information
trondhindenes committed Jan 2, 2022
1 parent 7cf67c4 commit 596f305
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 3 additions & 2 deletions piccolo_api/crud/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,9 @@ def _split_params(params: t.Dict[str, t.Any]) -> Params:
response.include_readable = True
continue

if key == "__range_header" and value in ("true", "True", "1"):
response.range_header = True
if key == "__range_header":
if value in ("true", "True", "1"):
response.range_header = True
continue

if key == "__range_header_name":
Expand Down
17 changes: 17 additions & 0 deletions tests/crud/test_crud_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,23 @@ def test_plural_name(self):
self.assertEqual(0, len(response_json["rows"]))
self.assertEqual(response.headers.get("Content-Range"), "movies 0-0/0")

def test_false_range_header_param(self):
"""
Make sure that __range_header=false is supported
"""
client = TestClient(
PiccoloCRUD(
table=Movie,
read_only=False,
)
)

response = client.get(
"/?__range_header=false"
)
self.assertTrue(response.status_code == 200)
self.assertEqual(response.headers.get("Content-Range"), None)

def test_empty_list(self):
"""
Make sure the content-range header responds correctly for empty rows
Expand Down

0 comments on commit 596f305

Please sign in to comment.