Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuadavidthomas committed Sep 18, 2024
1 parent a216e0a commit 6a02d07
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_crud/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,3 +452,26 @@ def get_delete_context_data(self, context, **kwargs):

with pytest.raises(ValueError):
view.get_role_context_data({})


@pytest.mark.parametrize(
"klass,quantity,paginate_by,expected",
[
(BookmarkView, 3, 1, 1),
(BookmarkTableView, 3, 1, 1),
],
)
def test_list_pagination(klass, quantity, paginate_by, expected, rf, db):
baker.make(Bookmark, _quantity=quantity)

View = klass.as_view(role=Role.LIST).view_class
request = rf.get(Role.LIST.maybe_reverse(View))

view = View(paginate_by=paginate_by, role=Role.LIST, **Role.LIST.extra_initkwargs())
view.setup(request)

rendered = view.list(request=request)

object_list = rendered.context_data["object_list"]

assert len(object_list) == expected

0 comments on commit 6a02d07

Please sign in to comment.