Spaces:
Sleeping
Sleeping
Download tests/test_serp_arxiv.py from OrganizedProgrammers/SERPent: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/OrganizedProgrammers/SERPent/resolve/main/tests/test_serp_arxiv.py
- Command line
-
hf download hf://spaces/OrganizedProgrammers/SERPent/tests/test_serp_arxiv.py
-
curl -L -o test_serp_arxiv.py https://huggingface.co/spaces/OrganizedProgrammers/SERPent/resolve/main/tests/test_serp_arxiv.py
1.01 kB
| import httpx | |
| import respx | |
| from helpers import load_fixture | |
| from serp import query_arxiv | |
| ARXIV_XML = load_fixture("arxiv_response.xml") | |
| async def test_query_arxiv_parses_the_atom_feed(): | |
| with respx.mock: | |
| respx.get("https://export.arxiv.org/api/query").mock( | |
| return_value=httpx.Response(200, text=ARXIV_XML, headers={"content-type": "application/atom+xml"}) | |
| ) | |
| async with httpx.AsyncClient() as client: | |
| results = await query_arxiv(client, "widgets", 2) | |
| assert results == [ | |
| { | |
| "title": "A Study of Widgets", | |
| "href": "http://arxiv.org/pdf/2401.00001v1", | |
| "body": "This paper studies widgets in depth.", | |
| "id": "http://arxiv.org/abs/2401.00001v1", | |
| }, | |
| { | |
| "title": "Gadgets and Their Applications", | |
| "href": "http://arxiv.org/pdf/2401.00002v1", | |
| "body": "An overview of gadgets.", | |
| "id": "http://arxiv.org/abs/2401.00002v1", | |
| }, | |
| ] | |