Axis component reflect device availability (#22401)

This commit is contained in:
Robert Svensson authored and GitHub committed 2019-03-29 15:20:12 +01:00
1 parent f4625fd561
commit 5f6037d563
10 files changed
+69 -28

No files matched your search

+2 -2
View File
@@ -53,9 +53,9 @@ async def setup_device(hass):
1, axis.DOMAIN, 'Mock Title', ENTRY_CONFIG, 'test',
config_entries.CONN_CLASS_LOCAL_PUSH, options=ENTRY_OPTIONS)
device = axis.AxisNetworkDevice(hass, config_entry)
device.api = AxisDevice(loop=loop, **config_entry.data[axis.CONF_DEVICE],
signal=device.async_signal_callback)
device.api = AxisDevice(loop=loop, **config_entry.data[axis.CONF_DEVICE])
hass.data[axis.DOMAIN] = {device.serial: device}
device.api.enable_events(event_callback=device.async_event_callback)
await hass.config_entries.async_forward_entry_setup(
config_entry, 'binary_sensor')
+2 -2
View File
@@ -37,9 +37,9 @@ async def setup_device(hass):
1, axis.DOMAIN, 'Mock Title', ENTRY_CONFIG, 'test',
config_entries.CONN_CLASS_LOCAL_PUSH, options=ENTRY_OPTIONS)
device = axis.AxisNetworkDevice(hass, config_entry)
device.api = AxisDevice(loop=loop, **config_entry.data[axis.CONF_DEVICE],
signal=device.async_signal_callback)
device.api = AxisDevice(loop=loop, **config_entry.data[axis.CONF_DEVICE])
hass.data[axis.DOMAIN] = {device.serial: device}
device.api.enable_events(event_callback=device.async_event_callback)
await hass.config_entries.async_forward_entry_setup(
config_entry, 'camera')
+3 -6
View File
@@ -31,8 +31,7 @@ async def test_flow_works(hass):
with patch('axis.AxisDevice') as mock_device:
def mock_constructor(
loop, host, username, password, port, web_proto, event_types,
signal):
loop, host, username, password, port, web_proto):
"""Fake the controller constructor."""
mock_device.loop = loop
mock_device.host = host
@@ -189,8 +188,7 @@ async def test_discovery_flow_known_device(hass):
config_flow.CONF_PORT: 80}}), \
patch('axis.AxisDevice') as mock_device:
def mock_constructor(
loop, host, username, password, port, web_proto, event_types,
signal):
loop, host, username, password, port, web_proto):
"""Fake the controller constructor."""
mock_device.loop = loop
mock_device.host = host
@@ -277,8 +275,7 @@ async def test_import_flow_works(hass):
with patch('axis.AxisDevice') as mock_device:
def mock_constructor(
loop, host, username, password, port, web_proto, event_types,
signal):
loop, host, username, password, port, web_proto):
"""Fake the controller constructor."""
mock_device.loop = loop
mock_device.host = host
+1 -1
View File
@@ -94,7 +94,7 @@ async def test_new_event_sends_signal(hass):
axis_device = device.AxisNetworkDevice(hass, entry)
with patch.object(device, 'async_dispatcher_send') as mock_dispatch_send:
axis_device.async_signal_callback(action='add', event='event')
axis_device.async_event_callback(action='add', event='event')
await hass.async_block_till_done()
assert len(mock_dispatch_send.mock_calls) == 1