def test_no_query(self, db_request):
        db_request.db.query(ProhibitedProjectName).delete()
        prohibited = sorted(
            [ProhibitedProjectFactory.create() for _ in range(30)],
            key=lambda b: canonicalize_name(b.name),
        )
        result = views.prohibited_project_names(db_request)

        assert result == {"prohibited_project_names": prohibited[:25], "query": None}
    def test_wildcard_query(self, db_request):
        db_request.db.query(ProhibitedProjectName).delete()
        prohibited = sorted(
            [ProhibitedProjectFactory.create() for _ in range(30)],
            key=lambda b: canonicalize_name(b.name),
        )
        db_request.GET["q"] = prohibited[0].name[:-1] + "%"
        result = views.prohibited_project_names(db_request)

        assert result == {
            "prohibited_project_names": [prohibited[0]],
            "query": prohibited[0].name[:-1] + "%",
        }
    def test_with_invalid_page(self):
        request = pretend.stub(params={"page": "not an integer"})

        with pytest.raises(HTTPBadRequest):
            views.prohibited_project_names(request)