Example #1
0
    def test_get_next_pickup(self):
        place_id = '85E562F0-49EC-11E6-A261-153143E100E1'
        service_id = '339'
        client = recollect_waste.RecollectWasteClient(place_id, service_id)
        pickup_event = client.get_next_pickup()

        assert hasattr(pickup_event, 'event_date')
        assert type(pickup_event.event_date) is date

        assert hasattr(pickup_event, 'pickup_types')
        assert type(pickup_event.pickup_types) is list
        assert len(pickup_event.pickup_types) > 0

        assert hasattr(pickup_event, 'area_name')
        assert pickup_event.area_name == "Abbotsford"
Example #2
0
def setup_platform(hass, config, add_entities, discovery_info=None):
    """Set up the Recollect Waste platform."""
    client = recollect_waste.RecollectWasteClient(
        config[CONF_PLACE_ID], config[CONF_SERVICE_ID]
    )

    # Ensure the client can connect to the API successfully
    # with given place_id and service_id.
    try:
        client.get_next_pickup()
    except recollect_waste.RecollectWasteException as ex:
        _LOGGER.error("Recollect Waste platform error. %s", ex)
        return

    add_entities([RecollectWasteSensor(config.get(CONF_NAME), client)], True)
Example #3
0
 def test_get_next_pickup_exception(self):
     with pytest.raises(RecollectWasteException):
         place_id = '1234567890'
         service_id = '1234567890'
         client = recollect_waste.RecollectWasteClient(place_id, service_id)
         pickup_event = client.get_next_pickup()