Ejemplo n.º 1
0
async def test_update_app_updated_needed(hass, app):
    """Test update_app updates when an app is needed."""
    mock_app = Mock(AppEntity)
    mock_app.app_name = "Test"

    await smartapp.update_app(hass, mock_app)

    assert mock_app.save.call_count == 1
    assert mock_app.app_name == "Test"
    assert mock_app.display_name == app.display_name
    assert mock_app.description == app.description
    assert mock_app.webhook_target_url == app.webhook_target_url
    assert mock_app.app_type == app.app_type
    assert mock_app.single_instance == app.single_instance
    assert mock_app.classifications == app.classifications
Ejemplo n.º 2
0
def app_fixture(hass, config_file):
    """Fixture for a single app."""
    app = Mock(AppEntity)
    app.app_name = APP_NAME_PREFIX + str(uuid4())
    app.app_id = str(uuid4())
    app.app_type = "WEBHOOK_SMART_APP"
    app.classifications = [CLASSIFICATION_AUTOMATION]
    app.display_name = "Home Assistant"
    app.description = hass.config.location_name + " at " + hass.config.api.base_url
    app.single_instance = True
    app.webhook_target_url = webhook.async_generate_url(
        hass, hass.data[DOMAIN][CONF_WEBHOOK_ID])

    settings = Mock(AppSettings)
    settings.app_id = app.app_id
    settings.settings = {SETTINGS_INSTANCE_ID: config_file[CONF_INSTANCE_ID]}
    app.settings.return_value = settings
    return app