Example #1
0
def test_fetch_slots():

    # Oops I forgot centerid
    request = ScraperRequest(
        'https://www.maiia.com/centre-de-vaccination/42400-saint-chamond/centre-de-vaccination-covid---hopital-du-gier-', '2021-04-16')
    first_availability = fetch_slots(request, client=client)
    assert first_availability == None

    request = ScraperRequest(
        'https://www.maiia.com/centre-de-vaccination/42400-saint-chamond/centre-de-vaccination-covid---hopital-du-gier-?centerid=5ffc744c68dedf073a5b87a2', '2021-04-16')
    first_availability = fetch_slots(request, client=client)
    assert first_availability == "2021-05-13T13:40:00+00:00"
Example #2
0
    def test_fetch_slot_raise_HTTPError(self, monkeypatch):
        scraper.maiia.maiia.session = requests

        def mock_get(*args, **kwargs):
            return MockResponse()

        # On applique la fonction pour "mockée" pour la levée d'exception :
        monkeypatch.setattr(requests, "get", mock_get)
        scrap_request = ScraperRequest("http://dummy_website.com",
                                       TestMaiia.START_DATE)
        assert fetch_slots(scrap_request) is None
Example #3
0
def test_fetch_slots():

    # Oops I forgot centerid
    request = ScraperRequest(
        url=
        "https://www.maiia.com/centre-de-vaccination/42400-saint-chamond/centre-de-vaccination-covid---hopital-du-gier-",
        start_date="2021-04-16",
        center_info=CenterInfo(
            departement="42",
            nom="Centre de vaccination COVID - Hôpital du Gier ",
            url=
            "https://www.maiia.com/centre-de-vaccination/42400-saint-chamond/centre-de-vaccination-covid---hopital-du-gier-?centerid=5ffc744c68dedf073a5b87a2",
            location=CenterLocation(longitude=4.50184989506,
                                    latitude=45.4698319517,
                                    city="Saint-Chamond",
                                    cp="42400"),
            metadata={
                "address": "19 rue victor hugo 42400 Saint-Chamond",
                "business_hours": {
                    "Lundi": "08:15-17:15",
                    "Mardi": "08:15-17:15",
                    "Mercredi": "08:15-17:15",
                    "Jeudi": "08:15-17:15",
                    "Vendredi": "08:15-17:15",
                    "Samedi": "08:15-17:15",
                    "Dimanche": "08:15-17:15",
                },
            },
            type="vaccination-center",
            internal_id="5ffc744c",
        ),
    )
    first_availability = fetch_slots(request, client=client)
    assert first_availability == None

    request = ScraperRequest(
        url=
        "https://www.maiia.com/centre-de-vaccination/42400-saint-chamond/centre-de-vaccination-covid---hopital-du-gier-?centerid=5ffc744c68dedf073a5b87a2",
        start_date="2021-04-16",
        center_info=CenterInfo(
            departement="42",
            nom="Centre de vaccination COVID - Hôpital du Gier ",
            url=
            "https://www.maiia.com/centre-de-vaccination/42400-saint-chamond/centre-de-vaccination-covid---hopital-du-gier-?centerid=5ffc744c68dedf073a5b87a2",
            location=CenterLocation(longitude=4.50184989506,
                                    latitude=45.4698319517,
                                    city="Saint-Chamond",
                                    cp="42400"),
            metadata={
                "address": "19 rue victor hugo 42400 Saint-Chamond",
                "business_hours": {
                    "Lundi": "08:15-17:15",
                    "Mardi": "08:15-17:15",
                    "Mercredi": "08:15-17:15",
                    "Jeudi": "08:15-17:15",
                    "Vendredi": "08:15-17:15",
                    "Samedi": "08:15-17:15",
                    "Dimanche": "08:15-17:15",
                },
            },
            type="vaccination-center",
            internal_id="5ffc744c",
        ),
    )
    print(request.center_info)

    first_availability = fetch_slots(request, client=client)
    assert first_availability == "2021-05-13T13:40:00+00:00"
Example #4
0
 def test_fetch_slot_with_incorrect_soup(self):
     scrap_request = ScraperRequest("http://google.com",
                                    TestMaiia.START_DATE)
     assert fetch_slots(scrap_request) is None