def paper(paper_id: str, version: str) -> Response: """Document metadata endpoint.""" data, status_code, headers = classic_api.paper(f"{paper_id}v{version}") response_data = serialize.as_atom(data.results) # type:ignore headers.update({"Content-type": ATOM_XML}) response: Response = make_response(response_data, status_code, headers) return response
def query() -> Response: """Main query endpoint.""" logger.debug("Got query: %s", request.args) data, status_code, headers = classic_api.query(request.args) response_data = serialize.as_atom( # type: ignore data.results, query=data.query) # type: ignore headers.update({"Content-type": ATOM_XML}) response: Response = make_response(response_data, status_code, headers) return response
def respond( error_msg: str, link: str = "http://arxiv.org/api/errors", status: HTTPStatus = HTTPStatus.INTERNAL_SERVER_ERROR, ) -> Response: """Generate an Atom response.""" return make_response( # type: ignore as_atom(Error(id=link, error=error_msg, link=link)), status, {"Content-type": ATOM_XML}, )
def test_to_atom(self): """Just your run-of-the-mill arXiv document generates valid Atom.""" document = mocks.document() _ = serialize.as_atom(document)