def test_basic_query(self, db_request): projects = sorted([ProjectFactory.create() for _ in range(5)], key=lambda p: p.normalized_name) db_request.GET["q"] = projects[0].name result = views.project_list(db_request) assert result == {"projects": [projects[0]], "query": projects[0].name}
def test_no_query(self, db_request): projects = sorted( [ProjectFactory.create() for _ in range(30)], key=lambda p: p.normalized_name, ) result = views.project_list(db_request) assert result == {"projects": projects[:25], "query": None}
def test_basic_query(self, db_request): projects = sorted( [ProjectFactory.create() for _ in range(5)], key=lambda p: p.normalized_name ) db_request.GET["q"] = projects[0].name result = views.project_list(db_request) assert result == {"projects": [projects[0]], "query": projects[0].name}
def test_with_page(self, db_request): projects = sorted( [ProjectFactory.create() for _ in range(30)], key=lambda p: p.normalized_name, ) db_request.GET["page"] = "2" result = views.project_list(db_request) assert result == {"projects": projects[25:], "query": None}
def test_with_invalid_page(self): request = pretend.stub(params={"page": "not an integer"}) with pytest.raises(HTTPBadRequest): views.project_list(request)