Keep live playback state unknown when supervisor status fails

This commit is contained in:
firestar5683
2026-09-19 21:18:00 -07:00
parent ec380c1e59
commit b24ef8aa6f
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ class LiveController:
return {**status,'available':True,'can_enable':not status.get('enabled',False) and not reason,
'reason':reason or status.get('reason','')}
except Exception as error:
return dict(available=False,enabled=False,state='DEGRADED',can_enable=False,reason='Live supervisor status unavailable: '+str(error))
return dict(available=False,enabled=None,state='DEGRADED',can_enable=False,reason='Live supervisor status unavailable: '+str(error))
def set_enabled(self, enabled):
if type(enabled) is not bool:raise ValueError('enabled must be a boolean')
@@ -52,3 +52,11 @@ def test_missing_adapter_unavailable():
assert not controller.status()['available'] and not controller.status()['can_enable']
with pytest.raises(RuntimeError):controller.set_enabled(True)
assert controller.set_enabled(False)['enabled'] is False
def test_failed_status_does_not_claim_audio_is_stopped():
adapter=Mock()
adapter.status.side_effect=RuntimeError('unreachable')
controller=LiveController(adapter=adapter)
assert controller.status()['enabled'] is None
controller.set_enabled(False)
adapter.stop_owned.assert_called_once()