コード例 #1
0
ファイル: test_views.py プロジェクト: bochecha/ideascube
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)
コード例 #2
0
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)
コード例 #3
0
ファイル: test_views.py プロジェクト: framabot/ideascube
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)