Skip to content

Commit

Permalink
test(api): add test for paginate
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxime Vergez committed Jan 13, 2023
1 parent dad60cd commit f0e6939
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion backend/gn_module_monitoring/tests/test_utils/test_routes.py
Original file line number Diff line number Diff line change
@@ -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")])
Expand All @@ -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

0 comments on commit f0e6939

Please sign in to comment.