1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Move MQTT platforms under the component (#20050)

* Move MQTT platforms under the component
This commit is contained in:
emontnemery
2019-01-15 17:31:06 +01:00
committed by GitHub
parent 5fd1053a38
commit 5b53bd6aa0
27 changed files with 6 additions and 5 deletions

View File

@@ -0,0 +1,54 @@
"""The tests for mqtt camera component."""
import asyncio
from homeassistant.setup import async_setup_component
from tests.common import (
async_mock_mqtt_component, async_fire_mqtt_message)
@asyncio.coroutine
def test_run_camera_setup(hass, aiohttp_client):
"""Test that it fetches the given payload."""
topic = 'test/camera'
yield from async_mock_mqtt_component(hass)
yield from async_setup_component(hass, 'camera', {
'camera': {
'platform': 'mqtt',
'topic': topic,
'name': 'Test Camera',
}})
url = hass.states.get('camera.test_camera').attributes['entity_picture']
async_fire_mqtt_message(hass, topic, 'beer')
yield from hass.async_block_till_done()
client = yield from aiohttp_client(hass.http.app)
resp = yield from client.get(url)
assert resp.status == 200
body = yield from resp.text()
assert body == 'beer'
@asyncio.coroutine
def test_unique_id(hass):
"""Test unique id option only creates one camera per unique_id."""
yield from async_mock_mqtt_component(hass)
yield from async_setup_component(hass, 'camera', {
'camera': [{
'platform': 'mqtt',
'name': 'Test Camera 1',
'topic': 'test-topic',
'unique_id': 'TOTALLY_UNIQUE'
}, {
'platform': 'mqtt',
'name': 'Test Camera 2',
'topic': 'test-topic',
'unique_id': 'TOTALLY_UNIQUE'
}]
})
async_fire_mqtt_message(hass, 'test-topic', 'payload')
yield from hass.async_block_till_done()
assert len(hass.states.async_all()) == 1