def test_normalizing_redirects(self, db_request): release = ReleaseFactory.create() db_request.route_path = pretend.call_recorder( lambda *a, **kw: "/project/the-redirect") resp = json.json_release_slash(release, db_request) assert isinstance(resp, HTTPMovedPermanently) assert db_request.route_path.calls == [ pretend.call("legacy.api.json.release", name=release.name, version=release.version) ] assert resp.headers["Location"] == "/project/the-redirect"
def test_normalizing_redirects(self, db_request): release = ReleaseFactory.create() db_request.route_path = pretend.call_recorder( lambda *a, **kw: "/project/the-redirect" ) resp = json.json_release_slash(release, db_request) assert isinstance(resp, HTTPMovedPermanently) assert db_request.route_path.calls == [ pretend.call( "legacy.api.json.release", name=release.project.name, version=release.version, ) ] assert resp.headers["Location"] == "/project/the-redirect"
def test_normalizing_redirects(self, db_request): project = ProjectFactory.create() release = ReleaseFactory.create(project=project, version="3.0") name = release.project.name.lower() if name == release.project.name: name = release.project.name.upper() db_request.matchdict = {"name": name} db_request.current_route_path = pretend.call_recorder( lambda name: "/project/the-redirect/3.0/" ) resp = json.json_release_slash(release, db_request) assert isinstance(resp, HTTPMovedPermanently) assert resp.headers["Location"] == "/project/the-redirect/3.0/" _assert_has_cors_headers(resp.headers) assert db_request.current_route_path.calls == [ pretend.call(name=release.project.name) ]