Exemplo n.º 1
0
    def test_normalizing_redirects(self, db_request):
        project = ProjectFactory.create()

        db_request.route_path = pretend.call_recorder(
            lambda *a, **kw: "/project/the-redirect")

        resp = json.json_project_slash(project, db_request)

        assert isinstance(resp, HTTPMovedPermanently)
        assert db_request.route_path.calls == [
            pretend.call("legacy.api.json.project", name=project.name)
        ]
        assert resp.headers["Location"] == "/project/the-redirect"
Exemplo n.º 2
0
    def test_normalizing_redirects(self, db_request):
        project = ProjectFactory.create()

        db_request.route_path = pretend.call_recorder(
            lambda *a, **kw: "/project/the-redirect"
        )

        resp = json.json_project_slash(project, db_request)

        assert isinstance(resp, HTTPMovedPermanently)
        assert db_request.route_path.calls == [
            pretend.call("legacy.api.json.project", name=project.name)
        ]
        assert resp.headers["Location"] == "/project/the-redirect"
Exemplo n.º 3
0
    def test_normalizing_redirects(self, db_request):
        project = ProjectFactory.create()

        name = project.name.lower()
        if name == project.name:
            name = project.name.upper()

        db_request.matchdict = {"name": name}
        db_request.current_route_path = pretend.call_recorder(
            lambda name: "/project/the-redirect/"
        )

        resp = json.json_project_slash(project, db_request)

        assert isinstance(resp, HTTPMovedPermanently)
        assert resp.headers["Location"] == "/project/the-redirect/"
        _assert_has_cors_headers(resp.headers)
        assert db_request.current_route_path.calls == [pretend.call(name=project.name)]