Skip to content

Commit

Permalink
test: Update test for get_consumption_overview api
Browse files Browse the repository at this point in the history
  • Loading branch information
germainlefebvre4 committed Jan 20, 2024
1 parent f9a16e7 commit 1939423
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions tests/api/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,22 +408,27 @@ 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)

assert isinstance(response, dict)
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)
Expand All @@ -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()
Expand Down

0 comments on commit 1939423

Please sign in to comment.