From 8329ddbf369505c929a689f650033425c2c3a42e Mon Sep 17 00:00:00 2001 From: Maxime Vergez Date: Wed, 4 Jan 2023 15:42:11 +0100 Subject: [PATCH] test(api): add test for paginate --- .../tests/test_utils/test_routes.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/backend/gn_module_monitoring/tests/test_utils/test_routes.py b/backend/gn_module_monitoring/tests/test_utils/test_routes.py index cc6357f37..39434141d 100644 --- a/backend/gn_module_monitoring/tests/test_utils/test_routes.py +++ b/backend/gn_module_monitoring/tests/test_utils/test_routes.py @@ -1,7 +1,9 @@ import pytest from werkzeug.datastructures import MultiDict -from gn_module_monitoring.utils.routes import get_limit_offset +from gn_module_monitoring.monitoring.models import TMonitoringSites +from gn_module_monitoring.monitoring.schemas import MonitoringSitesSchema +from gn_module_monitoring.utils.routes import get_limit_offset, paginate @pytest.mark.parametrize("limit, offset", [("1", "2"), (1, 2), ("1", 2), (1, "2")]) @@ -12,3 +14,14 @@ def test_get_limit_offset(limit, offset): assert isinstance(comp_limit, int) assert isinstance(comp_offset, int) + + +def test_paginate(sites): + limit = 1 + page = 2 + + res = paginate( + query=TMonitoringSites.query, schema=MonitoringSitesSchema, limit=limit, page=page + ) + + assert res.json["offset"] == page