@@ -368,6 +368,48 @@ async def mock_fetch7(url, **kwargs):
368368 else :
369369 print ("PASS: None returned when timestamp falls exactly on valid_to boundary" )
370370
371+ # ------------------------------------------------------------------
372+ # Test 9: is_intelligent_go_tariff — shared IOG/Intelligent detection helper.
373+ # Covers the bug where async_update_intelligent_devices only checked for
374+ # "INTELLI-" and missed plain "IOG-" tariff codes.
375+ # ------------------------------------------------------------------
376+ print ("\n *** Test 9: is_intelligent_go_tariff detects INTELLI and IOG- tariff codes ***" )
377+ intelligent_go_cases = [
378+ ("E-1R-INTELLI-VAR-25-01-01-H" , True ),
379+ ("E-1R-IOG-SMB-TOU-25-12-12-H" , True ),
380+ ("E-1R-INTELLI-FLUX-IMPORT-23-07-14-A" , True ),
381+ ("E-1R-GO-VAR-22-10-14-H" , False ),
382+ ("E-2R-VAR-22-11-01-A" , False ),
383+ ("" , False ),
384+ ]
385+ case_failed = False
386+ for tariff_code , expected in intelligent_go_cases :
387+ actual = OctopusAPI .is_intelligent_go_tariff (tariff_code )
388+ if actual != expected :
389+ print (f"ERROR: is_intelligent_go_tariff({ tariff_code !r} ) returned { actual } , expected { expected } " )
390+ failed = True
391+ case_failed = True
392+ if not case_failed :
393+ print ("PASS: is_intelligent_go_tariff correctly classifies INTELLI, IOG-, and non-intelligent tariff codes" )
394+
395+ # ------------------------------------------------------------------
396+ # Test 10: async_update_intelligent_devices regression — an IOG-only tariff
397+ # code (no "INTELLI" substring) must still be treated as an intelligent
398+ # tariff and proceed to fetch devices, rather than returning early.
399+ # ------------------------------------------------------------------
400+ print ("\n *** Test 10: async_update_intelligent_devices proceeds for IOG-only tariff code ***" )
401+ api10 = OctopusAPI (my_predbat , key = "test-key" , account_id = "test-account" , automatic = False )
402+ api10 .tariffs = {"import" : {"tariffCode" : "E-1R-IOG-SMB-TOU-25-12-12-H" , "deviceID" : "test-device-789" }}
403+ api10 .async_get_intelligent_devices = AsyncMock (return_value = {})
404+
405+ await api10 .async_update_intelligent_devices ("test-account" )
406+
407+ if api10 .async_get_intelligent_devices .call_count != 1 :
408+ print (f"ERROR: Expected async_get_intelligent_devices to be called for IOG-only tariff code, got { api10 .async_get_intelligent_devices .call_count } calls" )
409+ failed = True
410+ else :
411+ print ("PASS: async_update_intelligent_devices proceeds for IOG-only tariff code (no INTELLI substring)" )
412+
371413 # ------------------------------------------------------------------
372414 if failed :
373415 print ("\n **** ❌ async_get_day_night_rates tests FAILED ****" )
0 commit comments