Ejemplo n.º 1
0
def setup_comp(hass):
    """Initialize components."""
    hass.loop.run_until_complete(async_mock_mqtt_component(hass))
    yaml_devices = hass.config.path(device_tracker.YAML_DEVICES)
    yield
    if os.path.isfile(yaml_devices):
        os.remove(yaml_devices)
Ejemplo n.º 2
0
def setup_comp(hass):
    """Initialize components."""
    hass.loop.run_until_complete(async_mock_mqtt_component(hass))
    yaml_devices = hass.config.path(device_tracker.YAML_DEVICES)
    yield
    if os.path.isfile(yaml_devices):
        os.remove(yaml_devices)
Ejemplo n.º 3
0
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
def test_run_camera_setup(hass, test_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 test_client(hass.http.app)
    resp = yield from client.get(url)
    assert resp.status == 200
    body = yield from resp.text()
    assert body == 'beer'
Ejemplo n.º 5
0
def mqtt_mock(loop, hass):
    """Fixture to mock MQTT."""
    client = loop.run_until_complete(async_mock_mqtt_component(hass))
    client.reset_mock()
    return client
Ejemplo n.º 6
0
def mock_publish(hass):
    """Initialize components."""
    yield hass.loop.run_until_complete(async_mock_mqtt_component(hass))
Ejemplo n.º 7
0
def mqtt_mock(loop, hass):
    """Fixture to mock MQTT."""
    client = loop.run_until_complete(async_mock_mqtt_component(hass))
    client.reset_mock()
    return client
Ejemplo n.º 8
0
def setup_comp(hass):
    """Initialize components."""
    mock_component(hass, "group")
    hass.loop.run_until_complete(async_mock_mqtt_component(hass))
Ejemplo n.º 9
0
def setup_comp(hass):
    """Initialize components."""
    mock_component(hass, 'group')
    hass.loop.run_until_complete(async_mock_mqtt_component(hass))
Ejemplo n.º 10
0
def mock_publish(opp):
    """Initialize components."""
    yield opp.loop.run_until_complete(async_mock_mqtt_component(opp))
Ejemplo n.º 11
0
def setup_comp(opp):
    """Initialize components."""
    mock_component(opp, "group")
    opp.loop.run_until_complete(async_mock_mqtt_component(opp))
Ejemplo n.º 12
0
def mock_publish(hass):
    """Initialize components."""
    yield hass.loop.run_until_complete(async_mock_mqtt_component(hass))