def test_by_tag_page_is_paginated(app, monkeypatch): monkeypatch.setattr(ByTag, 'paginate_by', 2) ContentFactory.create_batch(size=2, status=Content.PUBLISHED, tags=['plane']) BookSpecimenFactory.create_batch(size=2, book__tags=['plane']) url = reverse('by_tag', kwargs={'tag': 'plane'}) response = app.get(url) assert response.pyquery.find('.pagination') assert response.pyquery.find('.next') assert not response.pyquery.find('.previous') response = app.get(url + '?page=2') assert response.pyquery.find('.pagination') assert not response.pyquery.find('.next') assert response.pyquery.find('.previous') response = app.get(url + '?page=3', status=404)
def test_by_tag_page_is_paginated(app, monkeypatch): monkeypatch.setattr(ByTag, 'paginate_by', 2) ContentFactory.create_batch(size=2, status=Content.PUBLISHED, tags=['plane']) BookSpecimenFactory.create_batch(size=2, item__tags=['plane']) url = reverse('by_tag') url = url + "?tags=plane" response = app.get(url, status=200) assert response.pyquery.find('.pagination') assert response.pyquery.find('.next') assert not response.pyquery.find('.previous') response = app.get(url, params={'page': 2}, status=200) assert response.pyquery.find('.pagination') assert not response.pyquery.find('.next') assert response.pyquery.find('.previous') response = app.get(url, params={'page': 3}, status=404)