예제 #1
0
async def test_get_next_pickup_event_oneshot(aresponses):
    """Test getting the next pickup event with an on-the-fly aiohttp session."""
    aresponses.add(
        "api.recollect.net",
        f"/api/places/{TEST_PLACE_ID}/services/{TEST_SERVICE_ID}/events",
        "get",
        aresponses.Response(
            text=load_fixture("pickup_data_response_1.json"),
            status=200,
            headers={"Content-Type": "application/json"},
        ),
    )

    client = Client(TEST_PLACE_ID, TEST_SERVICE_ID)
    next_pickup_event = await client.async_get_next_pickup_event()

    assert next_pickup_event.date == date(2020, 11, 2)
    assert next_pickup_event.pickup_types == [
        PickupType("garbage", "Trash"),
        PickupType("recycle"),
        PickupType("organics"),
    ]
    assert next_pickup_event.area_name == "Atlantis"
예제 #2
0
async def test_get_next_pickup_event_type2(aresponses):
    """Test getting the next pickup event from data sample 2."""
    aresponses.add(
        "api.recollect.net",
        f"/api/places/{TEST_PLACE_ID}/services/{TEST_SERVICE_ID}/events",
        "get",
        aresponses.Response(
            text=load_fixture("pickup_data_response_2.json"),
            status=200,
            headers={"Content-Type": "application/json"},
        ),
    )

    async with ClientSession() as session:
        client = Client(TEST_PLACE_ID, TEST_SERVICE_ID, session=session)
        next_pickup_event = await client.async_get_next_pickup_event()

        assert next_pickup_event.date == date(2020, 12, 1)
        assert next_pickup_event.pickup_types == [
            PickupType("Recycling", "Recycling"),
            PickupType("Organics", "Organics"),
            PickupType("Garbage", "Garbage"),
        ]
        assert next_pickup_event.area_name == "GuelphON"
예제 #3
0
async def test_get_next_pickup_event_same_day(aresponses):
    """Test always returning the next pickup event (even when today is an event)."""
    aresponses.add(
        "api.recollect.net",
        f"/api/places/{TEST_PLACE_ID}/services/{TEST_SERVICE_ID}/events",
        "get",
        aresponses.Response(
            text=load_fixture("pickup_data_response_1.json"),
            status=200,
            headers={"Content-Type": "application/json"},
        ),
    )

    async with ClientSession() as session:
        client = Client(TEST_PLACE_ID, TEST_SERVICE_ID, session=session)
        next_pickup_event = await client.async_get_next_pickup_event()

        assert next_pickup_event.date == date(2020, 11, 2)
        assert next_pickup_event.pickup_types == [
            PickupType("garbage", "Trash"),
            PickupType("recycle"),
            PickupType("organics"),
        ]
        assert next_pickup_event.area_name == "Atlantis"
예제 #4
0
파일: conftest.py 프로젝트: rikroe/core
async def setup_recollect_waste_fixture(hass, config):
    """Define a fixture to set up ReCollect Waste."""
    pickup_event = PickupEvent(date(2022, 1, 23),
                               [PickupType("garbage", "Trash Collection")],
                               "The Sun")

    with patch(
            "homeassistant.components.recollect_waste.Client.async_get_pickup_events",
            return_value=[pickup_event],
    ), patch(
            "homeassistant.components.recollect_waste.config_flow.Client.async_get_pickup_events",
            return_value=[pickup_event],
    ), patch("homeassistant.components.recollect_waste.PLATFORMS", []):
        assert await async_setup_component(hass, DOMAIN, config)
        await hass.async_block_till_done()
        yield