diff --git a/tests/api/test_api.py b/tests/api/test_api.py index f60200e..8f7576a 100644 --- a/tests/api/test_api.py +++ b/tests/api/test_api.py @@ -408,7 +408,8 @@ def test_set_cost_simulation(self): assert all(name in response["estimationPerZone"][0] for name in KEYS) def test_get_consumption_overview(self): - monthYear = "2023-09" + # Get current datetime and convert to "YYYY-MM" format + monthYear = date.today().strftime("%Y-%m") # 2023-09 country = "FRA" response = tado.get_consumption_overview(monthYear=monthYear, country=country) @@ -416,14 +417,18 @@ def test_get_consumption_overview(self): KEYS = ["ecogaz", "isInPreferredUnit", "energySavingsReport", "monthlyAggregation", "unit"] assert all(name in response for name in KEYS) + if len(response["ecogaz"]) > 0: + KEYS = ["date", "status"] + assert all(name in response["ecogaz"][0] for name in KEYS) + KEYS = ["totalSavingsInPercent", "yearMonth"] assert all(name in response["energySavingsReport"] for name in KEYS) KEYS = ["endOfMonthForecast", "requestedMonth", "monthBefore", "yearBefore"] assert all(name in response["monthlyAggregation"] for name in KEYS) - # KEYS = ["consumptionPerDate", "endDate", "startDate", "totalConsumption", "totalCostInCents"] - # assert all(name in response["monthlyAggregation"]["endOfMonthForecast"] for name in KEYS) + KEYS = ["consumptionPerDate", "endDate", "startDate", "totalConsumption", "totalCostInCents"] + assert all(name in response["monthlyAggregation"]["endOfMonthForecast"] for name in KEYS) KEYS = ["consumptionPerDate", "endDate", "startDate", "totalConsumption", "totalCostInCents"] assert all(name in response["monthlyAggregation"]["requestedMonth"] for name in KEYS) @@ -434,9 +439,9 @@ def test_get_consumption_overview(self): KEYS = ["consumptionPerDate", "endDate", "startDate", "totalConsumption", "totalCostInCents"] assert all(name in response["monthlyAggregation"]["yearBefore"] for name in KEYS) - # if len(response["monthlyAggregation"]["endOfMonthForecast"]["consumptionPerDate"]) > 0: - # KEYS = ["consumption", "costInCents", "date"] - # assert all(name in response["monthlyAggregation"]["endOfMonthForecast"]["consumptionPerDate"][0] for name in KEYS) + if len(response["monthlyAggregation"]["endOfMonthForecast"]["consumptionPerDate"]) > 0: + KEYS = ["consumption", "costInCents", "date"] + assert all(name in response["monthlyAggregation"]["endOfMonthForecast"]["consumptionPerDate"][0] for name in KEYS) def test_get_enery_settings(self): response = tado.get_enery_settings()