fix: per-page needs to be non zero

Signed-off-by: Leonidas Spyropoulos <artafinde@archlinux.org>
This commit is contained in:
Leonidas Spyropoulos 2023-02-08 15:13:21 +00:00
parent cb16f42a27
commit 45218c4ce7
No known key found for this signature in database
GPG key ID: 59E43E106B247368
2 changed files with 2 additions and 1 deletions

View file

@ -103,7 +103,7 @@ def sanitize_params(offset_str: str, per_page_str: str) -> Tuple[int, int]:
offset = defaults.O offset = defaults.O
try: try:
per_page = defaults.PP if int(per_page_str) < 0 else int(per_page_str) per_page = defaults.PP if int(per_page_str) <= 0 else int(per_page_str)
except ValueError: except ValueError:
per_page = defaults.PP per_page = defaults.PP

View file

@ -130,6 +130,7 @@ fRSo6OFcejKc=
("", "", (0, 50)), ("", "", (0, 50)),
("-1", "100", (0, 100)), ("-1", "100", (0, 100)),
("5", "-100", (5, 50)), ("5", "-100", (5, 50)),
("0", "0", (0, 50)),
], ],
) )
def test_sanitize_params(offset_str: str, per_page_str: str, expected: tuple[int, int]): def test_sanitize_params(offset_str: str, per_page_str: str, expected: tuple[int, int]):