Add dispatcher camera for internal image. (#6471)
* Add dispatcher camera for internal image. * fix lint * Add unittest * Update dispatcher.py
This commit is contained in:
1 parent
2c5d3387f2
commit
e7f442d66b
2 files changed
+103
No files matched your search
@@ -0,0 +1,36 @@
|
||||
"""The tests for dispatcher camera component."""
|
||||
import asyncio
|
||||
|
||||
from homeassistant.setup import async_setup_component
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_send
|
||||
|
||||
|
||||
@asyncio.coroutine
|
||||
def test_run_camera_setup(hass, test_client):
|
||||
"""Test that it fetches the given dispatcher data."""
|
||||
yield from async_setup_component(hass, 'camera', {
|
||||
'camera': {
|
||||
'platform': 'dispatcher',
|
||||
'name': 'dispatcher',
|
||||
'signal': 'test_camera',
|
||||
}})
|
||||
|
||||
client = yield from test_client(hass.http.app)
|
||||
|
||||
async_dispatcher_send(hass, 'test_camera', b'test')
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
resp = yield from client.get('/api/camera_proxy/camera.dispatcher')
|
||||
|
||||
assert resp.status == 200
|
||||
body = yield from resp.text()
|
||||
assert body == 'test'
|
||||
|
||||
async_dispatcher_send(hass, 'test_camera', b'test2')
|
||||
yield from hass.async_block_till_done()
|
||||
|
||||
resp = yield from client.get('/api/camera_proxy/camera.dispatcher')
|
||||
|
||||
assert resp.status == 200
|
||||
body = yield from resp.text()
|
||||
assert body == 'test2'
|
||||
Reference in new issue
Block a user