From 275a23d366b2be77c6f9dc7592b703ff7c6389fd Mon Sep 17 00:00:00 2001 From: Bram van Dartel Date: Sun, 29 Dec 2024 10:29:09 +0100 Subject: [PATCH] test --- custom_components/afvalwijzer/__init__.py | 46 +++++++++---------- .../afvalwijzer/collector/mijnafvalwijzer.py | 5 +- custom_components/afvalwijzer/tests/test.py | 2 +- .../afvalwijzer/tests/test_module.py | 11 +++-- 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/custom_components/afvalwijzer/__init__.py b/custom_components/afvalwijzer/__init__.py index 496b7de..52900b8 100644 --- a/custom_components/afvalwijzer/__init__.py +++ b/custom_components/afvalwijzer/__init__.py @@ -1,31 +1,31 @@ -from homeassistant.config_entries import ConfigEntry -from homeassistant.core import HomeAssistant -from homeassistant.helpers.typing import ConfigType -from .const.const import DOMAIN +# from homeassistant.config_entries import ConfigEntry +# from homeassistant.core import HomeAssistant +# from homeassistant.helpers.typing import ConfigType +# from .const.const import DOMAIN -async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: - """Set up the Afvalwijzer integration.""" - hass.data.setdefault(DOMAIN, {}) - return True +# async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: +# """Set up the Afvalwijzer integration.""" +# hass.data.setdefault(DOMAIN, {}) +# return True -async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: - """Set up Afvalwijzer from a config entry.""" - # Store config entry data - hass.data[DOMAIN][entry.entry_id] = entry.data +# async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: +# """Set up Afvalwijzer from a config entry.""" +# # Store config entry data +# hass.data[DOMAIN][entry.entry_id] = entry.data - # Forward the setup to the sensor platform - await hass.config_entries.async_forward_entry_setups(entry, ["sensor"]) - return True +# # Forward the setup to the sensor platform +# await hass.config_entries.async_forward_entry_setups(entry, ["sensor"]) +# return True -async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: - """Unload a config entry.""" - # Remove stored data - if entry.entry_id in hass.data[DOMAIN]: - hass.data[DOMAIN].pop(entry.entry_id) +# async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: +# """Unload a config entry.""" +# # Remove stored data +# if entry.entry_id in hass.data[DOMAIN]: +# hass.data[DOMAIN].pop(entry.entry_id) - # Unload the sensor platform - await hass.config_entries.async_forward_entry_unload(entry, "sensor") - return True +# # Unload the sensor platform +# await hass.config_entries.async_forward_entry_unload(entry, "sensor") +# return True diff --git a/custom_components/afvalwijzer/collector/mijnafvalwijzer.py b/custom_components/afvalwijzer/collector/mijnafvalwijzer.py index e1e21e3..2876e83 100644 --- a/custom_components/afvalwijzer/collector/mijnafvalwijzer.py +++ b/custom_components/afvalwijzer/collector/mijnafvalwijzer.py @@ -25,13 +25,16 @@ def get_waste_data_raw(provider, postal_code, street_number, suffix): try: response = raw_response.json() + print(response) ophaaldagen_data = response.get("ophaaldagen", {}).get("data", []) ophaaldagen_next_data = response.get("ophaaldagenNext", {}).get("data", []) + # print(ophaaldagen_next_data) + if not ophaaldagen_data and not ophaaldagen_next_data: _LOGGER.error("Address not found or no data available!") raise KeyError except KeyError as err: raise KeyError(f"Invalid and/or no data received from {url}") from err - return ophaaldagen_data + ophaaldagen_next_data[:25] + return ophaaldagen_data + ophaaldagen_next_data diff --git a/custom_components/afvalwijzer/tests/test.py b/custom_components/afvalwijzer/tests/test.py index db541d0..ac883f5 100644 --- a/custom_components/afvalwijzer/tests/test.py +++ b/custom_components/afvalwijzer/tests/test.py @@ -119,7 +119,7 @@ def parse_data(self, data): if __name__ == "__main__": logging.basicConfig(level=logging.INFO) - collector = AfvalwijzerCollector("mijnafvalwijzer", "5146EA", 73, "") + collector = AfvalwijzerCollector("mijnafvalwijzer", "5685AB", 57, "") repository = WasteCollectionRepository() try: diff --git a/custom_components/afvalwijzer/tests/test_module.py b/custom_components/afvalwijzer/tests/test_module.py index bafacd5..48cd126 100644 --- a/custom_components/afvalwijzer/tests/test_module.py +++ b/custom_components/afvalwijzer/tests/test_module.py @@ -42,14 +42,19 @@ # street_number = "2" # Afvalwijzer -provider = "mijnafvalwijzer" -postal_code = "5146eg" -street_number = "1" +# provider = "mijnafvalwijzer" +# postal_code = "5146eg" +# street_number = "1" # provider = "mijnafvalwijzer" # postal_code = "5563CM" # street_number = "22" +provider = "mijnafvalwijzer" +postal_code = "5685AB" +street_number = "57" + + # provider = "mijnafvalwijzer" # postal_code = "3601AC" # street_number = "10"