Esempio n. 1
0
def test_handler_alexa_disabled(hass, mock_cloud_fixture):
    """Test handler Alexa when user has disabled it."""
    mock_cloud_fixture[PREF_ENABLE_ALEXA] = False

    resp = yield from iot.async_handle_alexa(
        hass, hass.data['cloud'],
        test_alexa.get_new_request('Alexa.Discovery', 'Discover'))

    assert resp['event']['header']['namespace'] == 'Alexa'
    assert resp['event']['header']['name'] == 'ErrorResponse'
    assert resp['event']['payload']['type'] == 'BRIDGE_UNREACHABLE'
Esempio n. 2
0
def test_handler_alexa_disabled(hass, mock_cloud_fixture):
    """Test handler Alexa when user has disabled it."""
    mock_cloud_fixture[STORAGE_ENABLE_ALEXA] = False

    resp = yield from iot.async_handle_alexa(
        hass, hass.data['cloud'],
        test_alexa.get_new_request('Alexa.Discovery', 'Discover'))

    assert resp['event']['header']['namespace'] == 'Alexa'
    assert resp['event']['header']['name'] == 'ErrorResponse'
    assert resp['event']['payload']['type'] == 'BRIDGE_UNREACHABLE'
Esempio n. 3
0
def test_handler_alexa(hass):
    """Test handler Alexa."""
    hass.states.async_set('switch.test', 'on',
                          {'friendly_name': "Test switch"})
    hass.states.async_set('switch.test2', 'on',
                          {'friendly_name': "Test switch 2"})

    with patch('homeassistant.components.cloud.Cloud.async_start',
               return_value=mock_coro()):
        setup = yield from async_setup_component(
            hass, 'cloud', {
                'cloud': {
                    'alexa': {
                        'filter': {
                            'exclude_entities': 'switch.test2'
                        },
                        'entity_config': {
                            'switch.test': {
                                'name': 'Config name',
                                'description': 'Config description',
                                'display_categories': 'LIGHT'
                            }
                        }
                    }
                }
            })
        assert setup

    mock_cloud_prefs(hass)

    resp = yield from iot.async_handle_alexa(
        hass, hass.data['cloud'],
        test_alexa.get_new_request('Alexa.Discovery', 'Discover'))

    endpoints = resp['event']['payload']['endpoints']

    assert len(endpoints) == 1
    device = endpoints[0]

    assert device['description'] == 'Config description'
    assert device['friendlyName'] == 'Config name'
    assert device['displayCategories'] == ['LIGHT']
    assert device['manufacturerName'] == 'Home Assistant'
Esempio n. 4
0
def test_handler_alexa(hass):
    """Test handler Alexa."""
    hass.states.async_set(
        'switch.test', 'on', {'friendly_name': "Test switch"})
    hass.states.async_set(
        'switch.test2', 'on', {'friendly_name': "Test switch 2"})

    with patch('homeassistant.components.cloud.Cloud.async_start',
               return_value=mock_coro()):
        setup = yield from async_setup_component(hass, 'cloud', {
            'cloud': {
                'alexa': {
                    'filter': {
                        'exclude_entities': 'switch.test2'
                    },
                    'entity_config': {
                        'switch.test': {
                            'name': 'Config name',
                            'description': 'Config description',
                            'display_categories': 'LIGHT'
                        }
                    }
                }
            }
        })
        assert setup

    mock_cloud_prefs(hass)

    resp = yield from iot.async_handle_alexa(
        hass, hass.data['cloud'],
        test_alexa.get_new_request('Alexa.Discovery', 'Discover'))

    endpoints = resp['event']['payload']['endpoints']

    assert len(endpoints) == 1
    device = endpoints[0]

    assert device['description'] == 'Config description'
    assert device['friendlyName'] == 'Config name'
    assert device['displayCategories'] == ['LIGHT']
    assert device['manufacturerName'] == 'Home Assistant'