3232CORE_NOTIFICATIONS_TAIL = "/core/notifications{tail:.*}"
3333CORE_RULES_TAIL = "/core/rules{tail:.*}"
3434EMPTY_XML = "<xml />"
35+ BOGUS = "!bogus"
3536
3637_LOGGER = logging .getLogger (__name__ )
3738_LOGGER .setLevel (logging .DEBUG )
@@ -109,19 +110,17 @@ async def setup_app(
109110 # Introducte timeout with 2 seconds, test by setting response to 10ms
110111 # Don't actually wait 2 seconds as this will prolongue testing
111112 if not raise_timeout :
113+ app .router .add_route ("PUT" , CORE_LOCATIONS_TAIL , self .smile_http_accept )
112114 app .router .add_route (
113- "PUT " , CORE_LOCATIONS_TAIL , self .smile_set_temp_or_preset
115+ "DELETE " , CORE_NOTIFICATIONS_TAIL , self .smile_http_accept
114116 )
115- app .router .add_route (
116- "DELETE" , CORE_NOTIFICATIONS_TAIL , self .smile_del_notification
117- )
118- app .router .add_route ("PUT" , CORE_RULES_TAIL , self .smile_set_schedule )
117+ app .router .add_route ("PUT" , CORE_RULES_TAIL , self .smile_http_accept )
119118 if not stretch :
120- app .router .add_route ("PUT" , CORE_APPLIANCES_TAIL , self .smile_set_relay )
121- else :
122119 app .router .add_route (
123- "PUT" , CORE_APPLIANCES_TAIL , self .smile_set_relay_stretch
120+ "PUT" , CORE_APPLIANCES_TAIL , self .smile_http_accept
124121 )
122+ else :
123+ app .router .add_route ("PUT" , CORE_APPLIANCES_TAIL , self .smile_http_ok )
125124 else :
126125 app .router .add_route ("PUT" , CORE_LOCATIONS_TAIL , self .smile_timeout )
127126 app .router .add_route ("PUT" , CORE_RULES_TAIL , self .smile_timeout )
@@ -187,35 +186,17 @@ async def smile_status(self, request):
187186 raise aiohttp .web .HTTPNotFound
188187
189188 @classmethod
190- async def smile_set_temp_or_preset (cls , request ):
191- """Render generic API calling endpoint."""
192- text = EMPTY_XML
193- raise aiohttp .web .HTTPAccepted (text = text )
194-
195- @classmethod
196- async def smile_set_schedule (cls , request ):
197- """Render generic API calling endpoint."""
198- text = EMPTY_XML
199- raise aiohttp .web .HTTPAccepted (text = text )
200-
201- @classmethod
202- async def smile_set_relay (cls , request ):
189+ async def smile_http_accept (cls , request ):
203190 """Render generic API calling endpoint."""
204191 text = EMPTY_XML
205192 raise aiohttp .web .HTTPAccepted (text = text )
206193
207194 @classmethod
208- async def smile_set_relay_stretch (cls , request ):
195+ async def smile_http_ok (cls , request ):
209196 """Render generic API calling endpoint."""
210197 text = EMPTY_XML
211198 raise aiohttp .web .HTTPOk (text = text )
212199
213- @classmethod
214- async def smile_del_notification (cls , request ):
215- """Render generic API calling endpoint."""
216- text = EMPTY_XML
217- raise aiohttp .web .HTTPAccepted (text = text )
218-
219200 @classmethod
220201 async def smile_timeout (cls , request ):
221202 """Render timeout endpoint."""
@@ -392,7 +373,6 @@ def show_setup(location_list, device_list):
392373 _LOGGER .info (" ! no devices found in this location" )
393374 assert False
394375
395- # pragma warning disable S3776
396376 @pytest .mark .asyncio
397377 async def device_test (
398378 self ,
@@ -403,6 +383,9 @@ async def device_test(
403383 ):
404384 """Perform basic device tests."""
405385 bsw_list = ["binary_sensors" , "central" , "climate" , "sensors" , "switches" ]
386+
387+ # pragma warning disable S3776
388+
406389 # Make sure to test thermostats with the day set to Monday, needed for full testcoverage of schedules_temps()
407390 # Otherwise set the day to Sunday.
408391 with freeze_time (test_time ):
@@ -480,7 +463,7 @@ async def device_test(
480463 assert tests == asserts
481464 _LOGGER .debug ("Number of test-assert: %s" , asserts )
482465
483- # pragma warning restore S3776
466+ # pragma warning restore S3776
484467
485468 @pytest .mark .asyncio
486469 async def tinker_switch (
@@ -540,11 +523,11 @@ async def tinker_thermostat_temp(
540523 @pytest .mark .asyncio
541524 async def tinker_thermostat_preset (self , smile , loc_id , unhappy = False ):
542525 """Toggle preset to test functionality."""
543- for new_preset in ["asleep" , "home" , "!bogus" ]:
526+ for new_preset in ["asleep" , "home" , BOGUS ]:
544527 tinker_preset_passed = False
545528 warning = ""
546529 if new_preset [0 ] == "!" :
547- warning = " Negative test"
530+ warning = " TTP Negative test"
548531 new_preset = new_preset [1 :]
549532 _LOGGER .info ("%s" , f"- Adjusting preset to { new_preset } { warning } " )
550533 try :
@@ -572,14 +555,15 @@ async def tinker_thermostat_schedule(
572555 self , smile , loc_id , state , good_schedules = None , single = False , unhappy = False
573556 ):
574557 """Toggle schedules to test functionality."""
558+ # pragma warning disable S3776
575559 if good_schedules != []:
576560 if not single and ("!VeryBogusSchedule" not in good_schedules ):
577561 good_schedules .append ("!VeryBogusSchedule" )
578562 for new_schedule in good_schedules :
579563 tinker_schedule_passed = False
580564 warning = ""
581565 if new_schedule is not None and new_schedule [0 ] == "!" :
582- warning = " Negative test"
566+ warning = " TTS Negative test"
583567 new_schedule = new_schedule [1 :]
584568 _LOGGER .info ("- Adjusting schedule to %s" , f"{ new_schedule } { warning } " )
585569 try :
@@ -604,6 +588,7 @@ async def tinker_thermostat_schedule(
604588 return tinker_schedule_passed
605589
606590 _LOGGER .info ("- Skipping schedule adjustments" ) # pragma: no cover
591+ # pragma warning restore S3776
607592
608593 @pytest .mark .asyncio
609594 async def tinker_thermostat (
@@ -643,10 +628,10 @@ async def tinker_thermostat(
643628 @staticmethod
644629 async def tinker_dhw_mode (smile ):
645630 """Toggle dhw to test functionality."""
646- for mode in ["auto" , "boost" , "!bogus" ]:
631+ for mode in ["auto" , "boost" , BOGUS ]:
647632 warning = ""
648633 if mode [0 ] == "!" :
649- warning = " Negative test"
634+ warning = " TD Negative test"
650635 mode = mode [1 :]
651636 _LOGGER .info ("%s" , f"- Adjusting dhw mode to { mode } { warning } " )
652637 try :
@@ -658,10 +643,10 @@ async def tinker_dhw_mode(smile):
658643 @staticmethod
659644 async def tinker_regulation_mode (smile ):
660645 """Toggle regulation_mode to test functionality."""
661- for mode in ["off" , "heating" , "bleeding_cold" , "!bogus" ]:
646+ for mode in ["off" , "heating" , "bleeding_cold" , BOGUS ]:
662647 warning = ""
663648 if mode [0 ] == "!" :
664- warning = " Negative test"
649+ warning = " TR Negative test"
665650 mode = mode [1 :]
666651 _LOGGER .info ("%s" , f"- Adjusting regulation mode to { mode } { warning } " )
667652 try :
@@ -700,18 +685,22 @@ async def tinker_temp_offset(smile, dev_id):
700685
701686 @staticmethod
702687 def validate_test_basics (
703- _LOGGER , smile , smile_type = "thermostat" , smile_version = None , smile_legacy = False
688+ parent_logger ,
689+ smile ,
690+ smile_type = "thermostat" ,
691+ smile_version = None ,
692+ smile_legacy = False ,
704693 ):
705694 """Produce visual assertion of components base validation."""
706- _LOGGER .info ("Basics:" )
695+ parent_logger .info ("Basics:" )
707696 if smile_type :
708- _LOGGER .info (f" # Assert type matching { smile_type } " )
697+ parent_logger .info (f" # Assert type matching { smile_type } " )
709698 assert smile .smile_type == smile_type
710699 if smile_version :
711- _LOGGER .info (f" # Assert version matching '{ smile_version } " )
700+ parent_logger .info (f" # Assert version matching '{ smile_version } " )
712701 assert smile .smile_version [0 ] == smile_version
713702 if smile_version :
714- _LOGGER .info (f" # Assert legacy { smile_legacy } " )
703+ parent_logger .info (f" # Assert legacy { smile_legacy } " )
715704 if smile_legacy :
716705 assert smile ._smile_legacy
717706 else :
0 commit comments