33import asyncio
44import os
55import time
6+ from datetime import datetime , timezone
67from typing import Any
78from unittest .mock import AsyncMock , MagicMock , patch
89
1819 TadoBadRequestError ,
1920 TadoConnectionError ,
2021 TadoError ,
22+ TadoReadingError ,
2123)
2224
2325from syrupy import SnapshotAssertion
@@ -477,14 +479,14 @@ async def test_set_zone_overlay_success(
477479
478480
479481async def test_add_meter_readings_success (
480- python_tado : Tado , responses : aioresponses , snapshot : SnapshotAssertion
482+ python_tado : Tado , responses : aioresponses
481483) -> None :
482484 """Test adding meter readings."""
483485 responses .post (
484486 TADO_EIQ_URL ,
485487 body = load_fixture (folder = "meter" , filename = "add_reading_success.json" ),
486488 )
487- assert await python_tado .set_meter_readings (reading = 5 ) == snapshot
489+ await python_tado .set_meter_readings (5 )
488490
489491
490492async def test_set_child_lock (python_tado : Tado , responses : aioresponses ) -> None :
@@ -500,16 +502,21 @@ async def test_set_child_lock(python_tado: Tado, responses: aioresponses) -> Non
500502
501503
502504async def test_add_meter_readings_duplicated (
503- python_tado : Tado , responses : aioresponses , snapshot : SnapshotAssertion
505+ python_tado : Tado , responses : aioresponses
504506) -> None :
505507 """Test adding meter readings with duplicate."""
506- date = "2021-01-01"
508+ date = datetime ( 2023 , 10 , 1 , 12 , 0 , 0 , tzinfo = timezone . utc )
507509 reading = 5
508510 responses .post (
509511 TADO_EIQ_URL ,
510512 body = load_fixture (folder = "meter" , filename = "add_reading_duplicate.json" ),
511513 )
512- assert await python_tado .set_meter_readings (date , reading ) == snapshot
514+ with pytest .raises (
515+ TadoReadingError ,
516+ match = "Error setting meter reading: "
517+ "reading already exists for date \\ [2024-01-01\\ ]" ,
518+ ):
519+ await python_tado .set_meter_readings (reading , date )
513520
514521
515522async def test_request_client_response_error (python_tado : Tado ) -> None :
0 commit comments