mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-10-12 09:13:46 +08:00
Keep live playback state unknown when supervisor status fails
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user