1111logger = logging .getLogger ("AppDaemon._test" )
1212
1313
14-
1514@pytest .mark .ci
1615@pytest .mark .functional
1716class TestStateCallback :
1817 """Class to group the various tests for state callbacks."""
18+
1919 app_name : str = "state_test_app"
2020 timeout : int | float = 0.6
2121
22-
2322 async def _run_callback_test (self , run_app_for_time : AsyncTempTest , app_args : dict , sign : bool ) -> None :
2423 """Helper method to run callback tests with common logic.
2524
@@ -33,15 +32,15 @@ async def _run_callback_test(self, run_app_for_time: AsyncTempTest, app_args: di
3332 wait_coro = asyncio .wait_for (app_obj .execute_event .wait (), timeout = self .timeout )
3433 if sign :
3534 await wait_coro
36- logger .debug (' Callback execute event was set' )
35+ logger .debug (" Callback execute event was set" )
3736 else :
3837 # We expect the timeout because the new state filter doesn't match
3938 with pytest .raises (asyncio .TimeoutError ):
4039 await wait_coro
41- logger .debug (' Callback execute event was not set' )
40+ logger .debug (" Callback execute event was not set" )
4241 case _:
4342 raise ValueError ("App object not found in app management" )
44- logger .debug (f' Test completed in { perf_counter () - start :.3f} seconds' )
43+ logger .debug (f" Test completed in { perf_counter () - start :.3f} seconds" )
4544
4645 @pytest .mark .parametrize ("sign" , [True , False ])
4746 @pytest .mark .asyncio (loop_scope = "session" )
@@ -105,20 +104,19 @@ async def test_old_state_callback(self, run_app_for_time: AsyncTempTest, sign: b
105104 async with run_app_for_time (self .app_name , ** app_args ) as (ad , caplog ):
106105 match ad .app_management .objects .get (self .app_name ):
107106 case ManagedObject (object = app_obj ):
108- app_obj .run_in (app_obj .test_change_state , delay = app_obj .delay * 2 , state = "abc" )
109- wait_coro = asyncio .wait_for (app_obj .execute_event .wait (), timeout = self .timeout * 2 )
107+ app_obj .run_in (app_obj .test_change_state , delay = app_obj .delay * 2 , state = "abc" )
108+ wait_coro = asyncio .wait_for (app_obj .execute_event .wait (), timeout = self .timeout * 2 )
110109 if sign :
111110 await wait_coro
112- logger .debug (' Callback execute event was set' )
111+ logger .debug (" Callback execute event was set" )
113112 else :
114113 # We expect the timeout because the new state filter doesn't match
115114 with pytest .raises (asyncio .TimeoutError ):
116115 await wait_coro
117- logger .debug (' Callback execute event was not set' )
116+ logger .debug (" Callback execute event was not set" )
118117 case _:
119118 raise ValueError ("App object not found in app management" )
120119
121-
122120 @pytest .mark .parametrize ("sign" , [True , False ])
123121 @pytest .mark .asyncio (loop_scope = "session" )
124122 async def test_attribute_callback (self , run_app_for_time : AsyncTempTest , sign : bool ) -> None :
@@ -144,8 +142,5 @@ async def test_attribute_callback(self, run_app_for_time: AsyncTempTest, sign: b
144142 """
145143 new_state = str (uuid .uuid4 ())
146144 listen_state = new_state if sign else str (uuid .uuid4 ())
147- app_args = {
148- "listen_kwargs" : {"attribute" : "test_attr" , "new" : listen_state },
149- "state_kwargs" : {"state" : "changed" , "test_attr" : new_state }
150- }
145+ app_args = {"listen_kwargs" : {"attribute" : "test_attr" , "new" : listen_state }, "state_kwargs" : {"state" : "changed" , "test_attr" : new_state }}
151146 await self ._run_callback_test (run_app_for_time , app_args , sign )
0 commit comments