def test_fetch_slots():
    def app(request: httpx.Request) -> httpx.Response:
        try:
            with open(Path("tests", "fixtures", "mapharma", "slots.json"),
                      encoding="utf8") as f:
                return httpx.Response(200, content=f.read())
        except IOError:
            return httpx.Response(404, content="")

    client = httpx.Client(transport=httpx.MockTransport(app))

    request = ScraperRequest("https://mapharma.net/97200?c=60&l=1",
                             "2021-04-14")
    first_availability = fetch_slots(request,
                                     client,
                                     opendata_file=TEST_OPEN_DATA_FILE)
    assert first_availability == "2021-04-19T17:15:00"

    # test campagne["total_libres"]: 0
    request = ScraperRequest("https://mapharma.net/88400?c=92&l=1",
                             "2021-04-14")
    first_availability = fetch_slots(request,
                                     client,
                                     opendata_file=TEST_OPEN_DATA_FILE)
    assert first_availability == None
Пример #2
0
def test_fetch_slots():
    def app(request: httpx.Request) -> httpx.Response:
        try:
            with open(Path("tests", "fixtures", "mapharma", "slots.json"),
                      encoding="utf8") as f:
                return httpx.Response(200, content=f.read())
        except IOError:
            return httpx.Response(404, content="")

    client = httpx.Client(transport=httpx.MockTransport(app))

    center_info = CenterInfo(
        departement="49",
        nom="Pharmacie Grand Maine",
        url="https://mapharma.net/49100-3?c=257&l=0",
        location=CenterLocation(longitude=-0.595416,
                                latitude=47.468377,
                                city="ANGERS",
                                cp="49100"),
        metadata={
            "address":
            "CENTRE CIAL GRAND MAINE RUE DU GRAND LAUNAY, 49100 ANGERS",
            "business_hours": {
                "lundi": "09:30 – 20:00",
                "mardi": "09:30 – 20:00",
                "mercredi": "09:30 – 20:00",
                "jeudi": "09:30 – 20:00",
                "vendredi": "09:30 – 20:00",
                "samedi": "09:30 – 20:00",
                "dimanche": "Fermé",
            },
        },
    )

    request = ScraperRequest(url="https://mapharma.net/97200?c=60&l=1",
                             start_date="2021-04-14",
                             center_info=center_info)
    first_availability = fetch_slots(request,
                                     creneau_q=DummyQueue(),
                                     client=client,
                                     opendata_file=TEST_OPEN_DATA_FILE)

    assert first_availability == "2021-04-19T17:15:00"

    # test campagne["total_libres"]: 0
    request = ScraperRequest("https://mapharma.net/88400?c=92&l=1",
                             "2021-04-14",
                             center_info=center_info)
    first_availability = fetch_slots(request,
                                     client=client,
                                     opendata_file=TEST_OPEN_DATA_FILE)
    assert first_availability == None
Пример #3
0
def test_fetch_slots():
    def app(request: httpx.Request) -> httpx.Response:
        try:
            with open(Path('tests', 'fixtures', 'mapharma', 'slots.json'), encoding='utf8') as f:
                return httpx.Response(200, content=f.read())
        except IOError:
            return httpx.Response(404, content='')

    client = httpx.Client(transport=httpx.MockTransport(app))

    request = ScraperRequest(
        'https://mapharma.net/97200?c=60&l=1', '2021-04-14')
    first_availability = fetch_slots(request, client)
    assert first_availability == "2021-04-19T17:15:00"