@@ -39,7 +39,7 @@ async def test_async_get_config(async_cached_client: Client) -> None:
3939def test_get_logbook_entries (cached_client : Client ) -> None :
4040 """Tests the `GET /api/logbook/<timestamp>` endpoint."""
4141 for entry in cached_client .get_logbook_entries (
42- filter_entities = "sun.sun " ,
42+ filter_entities = "sun.red_sun " ,
4343 start_timestamp = datetime (2020 , 1 , 1 ),
4444 end_timestamp = datetime .now (),
4545 ):
@@ -49,7 +49,7 @@ def test_get_logbook_entries(cached_client: Client) -> None:
4949async def test_async_get_logbook_entries (async_cached_client : Client ) -> None :
5050 """Tests the `GET /api/logbook/<timestamp>` endpoint."""
5151 async for entry in async_cached_client .async_get_logbook_entries (
52- filter_entities = "sun.sun " ,
52+ filter_entities = "sun.red_sun " ,
5353 start_timestamp = datetime (2020 , 1 , 1 ),
5454 end_timestamp = datetime .now (),
5555 ):
@@ -70,35 +70,30 @@ def test_get_entity_histories(cached_client: Client) -> None:
7070 """Tests the `GET /api/history/period/<timestamp>` endpoint."""
7171 sun = cached_client .get_entity (entity_id = "sun.sun" )
7272 assert sun is not None
73- for history in cached_client .get_entity_histories (
74- (sun ,),
75- end_timestamp = datetime .now (), # test for microsecond truncation
76- start_timestamp = datetime (2020 , 1 , 1 ),
77- significant_changes_only = True ,
78- ):
79- for state in history .states :
80- assert isinstance (state , State )
81- break
82- else :
83- raise AssertionError ("No states in entity history found." )
84- break
85- else :
86- raise AssertionError ("No history found." )
73+ histories = list (
74+ cached_client .get_entity_histories (
75+ (sun ,),
76+ end_timestamp = datetime .now (),
77+ start_timestamp = datetime (2020 , 1 , 1 ),
78+ significant_changes_only = True ,
79+ )
80+ )
81+ assert histories , "No history found."
82+ assert histories [0 ].states , "No states in entity history found."
83+ assert isinstance (histories [0 ].states [0 ], State )
8784
8885
8986async def test_async_get_entity_histories (async_cached_client : Client ) -> None :
9087 """Tests the `GET /api/history/period/<timestamp>` endpoint."""
9188 sun = await async_cached_client .async_get_entity (entity_id = "sun.sun" )
9289 assert sun is not None
93- async for history in async_cached_client .async_get_entity_histories ((sun ,)):
94- for state in history .states :
95- assert isinstance (state , State )
96- break
97- else :
98- raise AssertionError ("No states in entity history found." )
99- break
100- else :
101- raise AssertionError ("No history found." )
90+ histories = [
91+ history
92+ async for history in async_cached_client .async_get_entity_histories ((sun ,))
93+ ]
94+ assert histories , "No history found."
95+ assert histories [0 ].states , "No states in entity history found."
96+ assert isinstance (histories [0 ].states [0 ], State )
10297
10398
10499def test_get_rendered_template (cached_client : Client ) -> None :
0 commit comments