File size: 1,008 Bytes
5796881
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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",
        },
    ]