Upgrade black to 20.8b1 (#39287)

This commit is contained in:
Franck Nijhof 2020-08-27 13:56:20 +02:00 committed by GitHub
parent 0d7eec710c
commit 1c2ebdf307
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
574 changed files with 4389 additions and 1725 deletions

View file

@ -61,7 +61,8 @@ async def test_set_alarm_away(hass):
mock_set_away.assert_called_once()
with patch(
"abodepy.ALARM.AbodeAlarm.mode", new_callable=PropertyMock,
"abodepy.ALARM.AbodeAlarm.mode",
new_callable=PropertyMock,
) as mock_mode:
mock_mode.return_value = CONST.MODE_AWAY

View file

@ -55,7 +55,9 @@ async def test_invalid_api_key(hass):
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG,
DOMAIN,
context={"source": SOURCE_USER},
data=VALID_CONFIG,
)
assert result["errors"] == {CONF_API_KEY: "invalid_api_key"}
@ -69,7 +71,9 @@ async def test_api_error(hass):
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG,
DOMAIN,
context={"source": SOURCE_USER},
data=VALID_CONFIG,
)
assert result["errors"] == {"base": "cannot_connect"}
@ -85,7 +89,9 @@ async def test_requests_exceeded_error(hass):
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG,
DOMAIN,
context={"source": SOURCE_USER},
data=VALID_CONFIG,
)
assert result["errors"] == {CONF_API_KEY: "requests_exceeded"}
@ -98,11 +104,15 @@ async def test_integration_already_exists(hass):
return_value=json.loads(load_fixture("accuweather/location_data.json")),
):
MockConfigEntry(
domain=DOMAIN, unique_id="123456", data=VALID_CONFIG,
domain=DOMAIN,
unique_id="123456",
data=VALID_CONFIG,
).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG,
DOMAIN,
context={"source": SOURCE_USER},
data=VALID_CONFIG,
)
assert result["type"] == "abort"
@ -119,7 +129,9 @@ async def test_create_entry(hass):
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=VALID_CONFIG,
DOMAIN,
context={"source": SOURCE_USER},
data=VALID_CONFIG,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
@ -133,7 +145,9 @@ async def test_create_entry(hass):
async def test_options_flow(hass):
"""Test config flow options."""
config_entry = MockConfigEntry(
domain=DOMAIN, unique_id="123456", data=VALID_CONFIG,
domain=DOMAIN,
unique_id="123456",
data=VALID_CONFIG,
)
config_entry.add_to_hass(hass)

View file

@ -156,16 +156,22 @@ async def test_hassio_update_instance_running(hass, aioclient_mock):
entry.add_to_hass(hass)
with patch.object(
hass.config_entries, "async_forward_entry_setup", return_value=True,
hass.config_entries,
"async_forward_entry_setup",
return_value=True,
) as mock_load:
assert await hass.config_entries.async_setup(entry.entry_id)
assert entry.state == config_entries.ENTRY_STATE_LOADED
assert len(mock_load.mock_calls) == 2
with patch.object(
hass.config_entries, "async_forward_entry_unload", return_value=True,
hass.config_entries,
"async_forward_entry_unload",
return_value=True,
) as mock_unload, patch.object(
hass.config_entries, "async_forward_entry_setup", return_value=True,
hass.config_entries,
"async_forward_entry_setup",
return_value=True,
) as mock_load:
result = await hass.config_entries.flow.async_init(
"adguard",

View file

@ -9,7 +9,9 @@ from tests.test_util.aiohttp import AiohttpClientMocker
async def init_integration(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_setup: bool = False,
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
skip_setup: bool = False,
) -> MockConfigEntry:
"""Set up the Agent DVR integration in Home Assistant."""

View file

@ -15,7 +15,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker
async def test_show_user_form(hass: HomeAssistant) -> None:
"""Test that the user set up form is served."""
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": SOURCE_USER},
config_flow.DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "user"
@ -70,7 +71,8 @@ async def test_full_user_flow_implementation(
)
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": SOURCE_USER},
config_flow.DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "user"

View file

@ -68,7 +68,8 @@ async def test_invalid_identifier(hass):
}
with patch(
"pyairvisual.api.API.nearest_city", side_effect=InvalidKeyError,
"pyairvisual.api.API.nearest_city",
side_effect=InvalidKeyError,
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_IMPORT}, data=geography_conf
@ -82,7 +83,8 @@ async def test_node_pro_error(hass):
node_pro_conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PASSWORD: "my_password"}
with patch(
"pyairvisual.node.Node.from_samba", side_effect=NodeProError,
"pyairvisual.node.Node.from_samba",
side_effect=NodeProError,
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data={"type": "AirVisual Node/Pro"}

View file

@ -3296,7 +3296,10 @@ async def test_media_player_sound_mode_list_unsupported(hass):
# Test equalizer controller is not there
assert_endpoint_capabilities(
appliance, "Alexa", "Alexa.PowerController", "Alexa.EndpointHealth",
appliance,
"Alexa",
"Alexa.PowerController",
"Alexa.EndpointHealth",
)
@ -3832,7 +3835,8 @@ async def test_camera_hass_urls(hass, mock_stream, url, result):
{"friendly_name": "Test camera", "supported_features": 3},
)
await async_process_ha_core_config(
hass, {"external_url": url},
hass,
{"external_url": url},
)
appliance = await discovery_test(device, hass)
@ -3846,7 +3850,8 @@ async def test_initialize_camera_stream(hass, mock_camera, mock_stream):
)
await async_process_ha_core_config(
hass, {"external_url": "https://mycamerastream.test"},
hass,
{"external_url": "https://mycamerastream.test"},
)
with patch(

View file

@ -18,7 +18,9 @@ async def test_import(hass):
"""Test that we can import a config entry."""
with patch("pyalmond.WebAlmondAPI.async_list_apps"):
assert await setup.async_setup_component(
hass, DOMAIN, {DOMAIN: {"type": "local", "host": "http://localhost:3000"}},
hass,
DOMAIN,
{DOMAIN: {"type": "local", "host": "http://localhost:3000"}},
)
await hass.async_block_till_done()
@ -34,7 +36,9 @@ async def test_import_cannot_connect(hass):
"pyalmond.WebAlmondAPI.async_list_apps", side_effect=asyncio.TimeoutError
):
assert await setup.async_setup_component(
hass, DOMAIN, {DOMAIN: {"type": "local", "host": "http://localhost:3000"}},
hass,
DOMAIN,
{DOMAIN: {"type": "local", "host": "http://localhost:3000"}},
)
await hass.async_block_till_done()

View file

@ -99,7 +99,8 @@ async def test_set_up_local(hass, aioclient_mock):
# Set up an internal URL, as Almond won't be set up if there is no URL available
await async_process_ha_core_config(
hass, {"internal_url": "https://192.168.0.1"},
hass,
{"internal_url": "https://192.168.0.1"},
)
entry = MockConfigEntry(

View file

@ -1085,7 +1085,10 @@ async def _test_service(
f"androidtv.{androidtv_patch}.{androidtv_method}", return_value=return_value
) as service_call:
await hass.services.async_call(
DOMAIN, ha_service_name, service_data=service_data, blocking=True,
DOMAIN,
ha_service_name,
service_data=service_data,
blocking=True,
)
assert service_call.called

View file

@ -56,7 +56,9 @@ def dummy_client_fixture(hass):
async def test_ssdp(hass, dummy_client):
"""Test a ssdp import flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVER,
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "confirm"
@ -75,7 +77,9 @@ async def test_ssdp_abort(hass):
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVER,
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
@ -86,7 +90,9 @@ async def test_ssdp_unable_to_connect(hass, dummy_client):
dummy_client.start.side_effect = AsyncMock(side_effect=ConnectionFailed)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVER,
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "confirm"
@ -107,7 +113,9 @@ async def test_ssdp_update(hass):
entry.add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=MOCK_DISCOVER,
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=MOCK_DISCOVER,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
@ -119,7 +127,9 @@ async def test_user(hass, aioclient_mock):
"""Test a manual user configuration flow."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=None,
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
data=None,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -149,7 +159,9 @@ async def test_invalid_ssdp(hass, aioclient_mock):
aioclient_mock.get(MOCK_UPNP_LOCATION, text="")
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input,
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
data=user_input,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == f"Arcam FMJ ({MOCK_HOST})"
@ -166,7 +178,9 @@ async def test_user_wrong(hass, aioclient_mock):
aioclient_mock.get(MOCK_UPNP_LOCATION, status=404)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input,
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
data=user_input,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == f"Arcam FMJ ({MOCK_HOST})"

View file

@ -38,7 +38,8 @@ async def test_get_triggers(hass, device_reg, entity_reg):
config_entry = MockConfigEntry(domain=DOMAIN, data={})
config_entry.add_to_hass(hass)
device_entry = device_reg.async_get_or_create(
config_entry_id=config_entry.entry_id, identifiers={(DOMAIN, "host", 1234)},
config_entry_id=config_entry.entry_id,
identifiers={(DOMAIN, "host", 1234)},
)
entity_reg.async_get_or_create(
"media_player", DOMAIN, "5678", device_id=device_entry.id
@ -83,7 +84,10 @@ async def test_if_fires_on_turn_on_request(hass, calls, player_setup, state):
)
await hass.services.async_call(
"media_player", "turn_on", {"entity_id": player_setup}, blocking=True,
"media_player",
"turn_on",
{"entity_id": player_setup},
blocking=True,
)
await hass.async_block_till_done()

View file

@ -80,7 +80,8 @@ async def test_setting_climate(
async def test_incorrect_modes(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker,
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
) -> None:
"""Test incorrect values are handled correctly."""
with patch(

View file

@ -38,7 +38,8 @@ async def test_adding_second_device(
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
assert result["reason"] == "already_configured"
with patch(
"pyatag.AtagOne.id", new_callable=PropertyMock(return_value="secondary_device"),
"pyatag.AtagOne.id",
new_callable=PropertyMock(return_value="secondary_device"),
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT
@ -50,7 +51,9 @@ async def test_connection_error(hass):
"""Test we show user form on Atag connection error."""
with patch("pyatag.AtagOne.authorize", side_effect=errors.AtagException()):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT,
DOMAIN,
context={"source": config_entries.SOURCE_USER},
data=USER_INPUT,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -62,7 +65,9 @@ async def test_unauthorized(hass):
"""Test we show correct form when Unauthorized error is raised."""
with patch("pyatag.AtagOne.authorize", side_effect=errors.Unauthorized()):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT,
DOMAIN,
context={"source": config_entries.SOURCE_USER},
data=USER_INPUT,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user"
@ -74,13 +79,17 @@ async def test_full_flow_implementation(
) -> None:
"""Test registering an integration and finishing flow works."""
aioclient_mock.get(
"http://127.0.0.1:10000/retrieve", json=RECEIVE_REPLY,
"http://127.0.0.1:10000/retrieve",
json=RECEIVE_REPLY,
)
aioclient_mock.post(
"http://127.0.0.1:10000/pair", json=PAIR_REPLY,
"http://127.0.0.1:10000/pair",
json=PAIR_REPLY,
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=USER_INPUT,
DOMAIN,
context={"source": config_entries.SOURCE_USER},
data=USER_INPUT,
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == UID

View file

@ -34,7 +34,8 @@ async def test_form(hass):
), patch(
"homeassistant.components.august.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.august.async_setup_entry", return_value=True,
"homeassistant.components.august.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -149,7 +150,8 @@ async def test_form_needs_validate(hass):
"homeassistant.components.august.async_setup_entry", return_value=True
) as mock_setup_entry:
result3 = await hass.config_entries.flow.async_configure(
result["flow_id"], {VERIFICATION_CODE_KEY: "incorrect"},
result["flow_id"],
{VERIFICATION_CODE_KEY: "incorrect"},
)
# Make sure we do not resend the code again
@ -176,7 +178,8 @@ async def test_form_needs_validate(hass):
"homeassistant.components.august.async_setup_entry", return_value=True
) as mock_setup_entry:
result4 = await hass.config_entries.flow.async_configure(
result["flow_id"], {VERIFICATION_CODE_KEY: "correct"},
result["flow_id"],
{VERIFICATION_CODE_KEY: "correct"},
)
assert len(mock_send_verification_code.mock_calls) == 0

View file

@ -42,7 +42,9 @@ async def test_august_is_offline(hass):
"""Config entry state is ENTRY_STATE_SETUP_RETRY when august is offline."""
config_entry = MockConfigEntry(
domain=DOMAIN, data=_mock_get_config()[DOMAIN], title="August august",
domain=DOMAIN,
data=_mock_get_config()[DOMAIN],
title="August august",
)
config_entry.add_to_hass(hass)
@ -146,7 +148,8 @@ async def test_set_up_from_yaml(hass):
await setup.async_setup_component(hass, "persistent_notification", {})
with patch(
"homeassistant.components.august.async_setup_august", return_value=True,
"homeassistant.components.august.async_setup_august",
return_value=True,
) as mock_setup_august, patch(
"homeassistant.components.august.config_flow.AugustGateway.async_authenticate",
return_value=True,

View file

@ -105,7 +105,8 @@ async def test_one_lock_operation(hass):
async def test_one_lock_unknown_state(hass):
"""Test creation of a lock with doorsense and bridge."""
lock_one = await _mock_lock_from_fixture(
hass, "get_lock.online.unknown_state.json",
hass,
"get_lock.online.unknown_state.json",
)
await _create_august_with_devices(hass, [lock_one])

View file

@ -166,7 +166,8 @@ async def test_find_link_tag_max_size(hass, mock_session):
@pytest.mark.parametrize(
"client_id", ["https://home-assistant.io/android", "https://home-assistant.io/iOS"],
"client_id",
["https://home-assistant.io/android", "https://home-assistant.io/iOS"],
)
async def test_verify_redirect_uri_android_ios(client_id):
"""Test that we verify redirect uri correctly for Android/iOS."""

View file

@ -584,7 +584,11 @@ async def test_automation_stops(hass, calls, service):
],
}
}
assert await async_setup_component(hass, automation.DOMAIN, config,)
assert await async_setup_component(
hass,
automation.DOMAIN,
config,
)
running = asyncio.Event()

View file

@ -15,7 +15,8 @@ async def test_form(hass):
assert result["errors"] == {}
with patch(
"homeassistant.components.avri.async_setup_entry", return_value=True,
"homeassistant.components.avri.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],

View file

@ -52,7 +52,8 @@ async def test_duplicate_error(hass):
with patch(
"python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE]
), patch(
"homeassistant.components.awair.sensor.async_setup_entry", return_value=True,
"homeassistant.components.awair.sensor.async_setup_entry",
return_value=True,
):
MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG).add_to_hass(
hass
@ -86,7 +87,8 @@ async def test_import(hass):
with patch(
"python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE]
), patch(
"homeassistant.components.awair.sensor.async_setup_entry", return_value=True,
"homeassistant.components.awair.sensor.async_setup_entry",
return_value=True,
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -120,7 +122,8 @@ async def test_import_aborts_if_configured(hass):
with patch(
"python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE]
), patch(
"homeassistant.components.awair.sensor.async_setup_entry", return_value=True,
"homeassistant.components.awair.sensor.async_setup_entry",
return_value=True,
):
MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG).add_to_hass(
hass
@ -141,7 +144,8 @@ async def test_reauth(hass):
with patch(
"python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE]
), patch(
"homeassistant.components.awair.sensor.async_setup_entry", return_value=True,
"homeassistant.components.awair.sensor.async_setup_entry",
return_value=True,
):
mock_config = MockConfigEntry(domain=DOMAIN, unique_id=UNIQUE_ID, data=CONFIG)
mock_config.add_to_hass(hass)
@ -150,7 +154,9 @@ async def test_reauth(hass):
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "reauth", "unique_id": UNIQUE_ID}, data=CONFIG,
DOMAIN,
context={"source": "reauth", "unique_id": UNIQUE_ID},
data=CONFIG,
)
assert result["type"] == "abort"
@ -158,14 +164,18 @@ async def test_reauth(hass):
with patch("python_awair.AwairClient.query", side_effect=AuthError()):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "reauth", "unique_id": UNIQUE_ID}, data=CONFIG,
DOMAIN,
context={"source": "reauth", "unique_id": UNIQUE_ID},
data=CONFIG,
)
assert result["errors"] == {CONF_ACCESS_TOKEN: "auth"}
with patch("python_awair.AwairClient.query", side_effect=AwairError()):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "reauth", "unique_id": UNIQUE_ID}, data=CONFIG,
DOMAIN,
context={"source": "reauth", "unique_id": UNIQUE_ID},
data=CONFIG,
)
assert result["type"] == "abort"
@ -178,7 +188,8 @@ async def test_create_entry(hass):
with patch(
"python_awair.AwairClient.query", side_effect=[USER_FIXTURE, DEVICES_FIXTURE]
), patch(
"homeassistant.components.awair.sensor.async_setup_entry", return_value=True,
"homeassistant.components.awair.sensor.async_setup_entry",
return_value=True,
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=CONFIG

View file

@ -68,7 +68,8 @@ async def test_manual_configuration_update_configuration(hass):
assert result["step_id"] == "user"
with patch(
"homeassistant.components.axis.async_setup_entry", return_value=True,
"homeassistant.components.axis.async_setup_entry",
return_value=True,
) as mock_setup_entry, patch(
"axis.vapix.session_request", new=vapix_session_request
):
@ -170,11 +171,13 @@ async def test_flow_fails_device_unavailable(hass):
async def test_flow_create_entry_multiple_existing_entries_of_same_model(hass):
"""Test that create entry can generate a name with other entries."""
entry = MockConfigEntry(
domain=AXIS_DOMAIN, data={CONF_NAME: "M1065-LW 0", CONF_MODEL: "M1065-LW"},
domain=AXIS_DOMAIN,
data={CONF_NAME: "M1065-LW 0", CONF_MODEL: "M1065-LW"},
)
entry.add_to_hass(hass)
entry2 = MockConfigEntry(
domain=AXIS_DOMAIN, data={CONF_NAME: "M1065-LW 1", CONF_MODEL: "M1065-LW"},
domain=AXIS_DOMAIN,
data={CONF_NAME: "M1065-LW 1", CONF_MODEL: "M1065-LW"},
)
entry2.add_to_hass(hass)
@ -289,7 +292,8 @@ async def test_zeroconf_flow_updated_configuration(hass):
}
with patch(
"homeassistant.components.axis.async_setup_entry", return_value=True,
"homeassistant.components.axis.async_setup_entry",
return_value=True,
) as mock_setup_entry, patch(
"axis.vapix.session_request", new=vapix_session_request
):
@ -359,7 +363,8 @@ async def test_option_flow(hass):
}
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_STREAM_PROFILE: "profile_1"},
result["flow_id"],
user_input={CONF_STREAM_PROFILE: "profile_1"},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY

View file

@ -213,7 +213,8 @@ async def setup_axis_integration(hass, config=ENTRY_CONFIG, options=ENTRY_OPTION
config_entry.add_to_hass(hass)
with patch("axis.vapix.session_request", new=vapix_session_request), patch(
"axis.rtsp.RTSPClient.start", return_value=True,
"axis.rtsp.RTSPClient.start",
return_value=True,
):
await hass.config_entries.async_setup(config_entry.entry_id)
await hass.async_block_till_done()
@ -291,7 +292,8 @@ async def test_update_address(hass):
assert device.api.config.host == "1.2.3.4"
with patch("axis.vapix.session_request", new=vapix_session_request), patch(
"homeassistant.components.axis.async_setup_entry", return_value=True,
"homeassistant.components.axis.async_setup_entry",
return_value=True,
) as mock_setup_entry:
await hass.config_entries.flow.async_init(
AXIS_DOMAIN,

View file

@ -44,7 +44,8 @@ async def test_authorization_error(hass: HomeAssistant) -> None:
assert result["step_id"] == "user"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], FIXTURE_USER_INPUT,
result["flow_id"],
FIXTURE_USER_INPUT,
)
await hass.async_block_till_done()
@ -67,7 +68,8 @@ async def test_reauth_authorization_error(hass: HomeAssistant) -> None:
assert result["step_id"] == "reauth"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], FIXTURE_REAUTH_INPUT,
result["flow_id"],
FIXTURE_REAUTH_INPUT,
)
await hass.async_block_till_done()
@ -90,7 +92,8 @@ async def test_connection_error(hass: HomeAssistant) -> None:
assert result["step_id"] == "user"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], FIXTURE_USER_INPUT,
result["flow_id"],
FIXTURE_USER_INPUT,
)
await hass.async_block_till_done()
@ -113,7 +116,8 @@ async def test_reauth_connection_error(hass: HomeAssistant) -> None:
assert result["step_id"] == "reauth"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], FIXTURE_REAUTH_INPUT,
result["flow_id"],
FIXTURE_REAUTH_INPUT,
)
await hass.async_block_till_done()
@ -141,7 +145,8 @@ async def test_project_error(hass: HomeAssistant) -> None:
assert result["step_id"] == "user"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], FIXTURE_USER_INPUT,
result["flow_id"],
FIXTURE_USER_INPUT,
)
await hass.async_block_till_done()
@ -169,7 +174,8 @@ async def test_reauth_project_error(hass: HomeAssistant) -> None:
assert result["step_id"] == "reauth"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], FIXTURE_REAUTH_INPUT,
result["flow_id"],
FIXTURE_REAUTH_INPUT,
)
await hass.async_block_till_done()
@ -209,7 +215,8 @@ async def test_reauth_flow(hass: HomeAssistant) -> None:
),
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], FIXTURE_REAUTH_INPUT,
result["flow_id"],
FIXTURE_REAUTH_INPUT,
)
await hass.async_block_till_done()
@ -222,7 +229,8 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
with patch(
"homeassistant.components.azure_devops.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.azure_devops.async_setup_entry", return_value=True,
"homeassistant.components.azure_devops.async_setup_entry",
return_value=True,
) as mock_setup_entry, patch(
"homeassistant.components.azure_devops.config_flow.DevOpsClient.authorized",
return_value=True,
@ -242,7 +250,8 @@ async def test_full_flow_implementation(hass: HomeAssistant) -> None:
assert result["step_id"] == "user"
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], FIXTURE_USER_INPUT,
result["flow_id"],
FIXTURE_USER_INPUT,
)
await hass.async_block_till_done()
assert len(mock_setup.mock_calls) == 1

View file

@ -10,11 +10,13 @@ def test_state():
sensor = binary_sensor.BinarySensorEntity()
assert STATE_OFF == sensor.state
with mock.patch(
"homeassistant.components.binary_sensor.BinarySensorEntity.is_on", new=False,
"homeassistant.components.binary_sensor.BinarySensorEntity.is_on",
new=False,
):
assert STATE_OFF == binary_sensor.BinarySensorEntity().state
with mock.patch(
"homeassistant.components.binary_sensor.BinarySensorEntity.is_on", new=True,
"homeassistant.components.binary_sensor.BinarySensorEntity.is_on",
new=True,
):
assert STATE_ON == binary_sensor.BinarySensorEntity().state

View file

@ -210,7 +210,10 @@ async def test_open(feature, hass, config):
feature_mock.async_update = AsyncMock()
await hass.services.async_call(
"cover", SERVICE_OPEN_COVER, {"entity_id": entity_id}, blocking=True,
"cover",
SERVICE_OPEN_COVER,
{"entity_id": entity_id},
blocking=True,
)
assert hass.states.get(entity_id).state == STATE_OPENING

View file

@ -116,7 +116,10 @@ async def test_dimmer_on(dimmer, hass, config):
feature_mock.async_on = AsyncMock(side_effect=turn_on)
await hass.services.async_call(
"light", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True,
"light",
SERVICE_TURN_ON,
{"entity_id": entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
@ -186,7 +189,10 @@ async def test_dimmer_off(dimmer, hass, config):
feature_mock.async_off = AsyncMock(side_effect=turn_off)
await hass.services.async_call(
"light", SERVICE_TURN_OFF, {"entity_id": entity_id}, blocking=True,
"light",
SERVICE_TURN_OFF,
{"entity_id": entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
@ -282,7 +288,10 @@ async def test_wlightbox_s_on(wlightbox_s, hass, config):
feature_mock.async_on = AsyncMock(side_effect=turn_on)
await hass.services.async_call(
"light", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True,
"light",
SERVICE_TURN_ON,
{"entity_id": entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
@ -523,7 +532,10 @@ async def test_wlightbox_on_to_last_color(wlightbox, hass, config):
feature_mock.sensible_on_value = "f1e2d3e4"
await hass.services.async_call(
"light", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True,
"light",
SERVICE_TURN_ON,
{"entity_id": entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
@ -555,7 +567,10 @@ async def test_wlightbox_off(wlightbox, hass, config):
feature_mock.async_off = AsyncMock(side_effect=turn_off)
await hass.services.async_call(
"light", SERVICE_TURN_OFF, {"entity_id": entity_id}, blocking=True,
"light",
SERVICE_TURN_OFF,
{"entity_id": entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
@ -589,7 +604,10 @@ async def test_turn_on_failure(feature, hass, config, caplog):
feature_mock.sensible_on_value = 123
await hass.services.async_call(
"light", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True,
"light",
SERVICE_TURN_ON,
{"entity_id": entity_id},
blocking=True,
)
assert (

View file

@ -117,7 +117,10 @@ async def test_switchbox_on(switchbox, hass, config):
feature_mock.async_turn_on = AsyncMock(side_effect=turn_on)
await hass.services.async_call(
"switch", SERVICE_TURN_ON, {"entity_id": entity_id}, blocking=True,
"switch",
SERVICE_TURN_ON,
{"entity_id": entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
@ -142,7 +145,10 @@ async def test_switchbox_off(switchbox, hass, config):
feature_mock.async_turn_off = AsyncMock(side_effect=turn_off)
await hass.services.async_call(
"switch", SERVICE_TURN_OFF, {"entity_id": entity_id}, blocking=True,
"switch",
SERVICE_TURN_OFF,
{"entity_id": entity_id},
blocking=True,
)
state = hass.states.get(entity_id)
assert state.state == STATE_OFF
@ -279,7 +285,10 @@ async def test_switchbox_d_turn_first_on(switchbox_d, hass, config):
feature_mocks[0].async_turn_on = AsyncMock(side_effect=turn_on0)
await hass.services.async_call(
"switch", SERVICE_TURN_ON, {"entity_id": entity_ids[0]}, blocking=True,
"switch",
SERVICE_TURN_ON,
{"entity_id": entity_ids[0]},
blocking=True,
)
assert hass.states.get(entity_ids[0]).state == STATE_ON
@ -305,7 +314,10 @@ async def test_switchbox_d_second_on(switchbox_d, hass, config):
feature_mocks[1].async_turn_on = AsyncMock(side_effect=turn_on1)
await hass.services.async_call(
"switch", SERVICE_TURN_ON, {"entity_id": entity_ids[1]}, blocking=True,
"switch",
SERVICE_TURN_ON,
{"entity_id": entity_ids[1]},
blocking=True,
)
assert hass.states.get(entity_ids[0]).state == STATE_OFF
@ -331,7 +343,10 @@ async def test_switchbox_d_first_off(switchbox_d, hass, config):
feature_mocks[0].async_turn_off = AsyncMock(side_effect=turn_off0)
await hass.services.async_call(
"switch", SERVICE_TURN_OFF, {"entity_id": entity_ids[0]}, blocking=True,
"switch",
SERVICE_TURN_OFF,
{"entity_id": entity_ids[0]},
blocking=True,
)
assert hass.states.get(entity_ids[0]).state == STATE_OFF
@ -357,7 +372,10 @@ async def test_switchbox_d_second_off(switchbox_d, hass, config):
feature_mocks[1].async_turn_off = AsyncMock(side_effect=turn_off1)
await hass.services.async_call(
"switch", SERVICE_TURN_OFF, {"entity_id": entity_ids[1]}, blocking=True,
"switch",
SERVICE_TURN_OFF,
{"entity_id": entity_ids[1]},
blocking=True,
)
assert hass.states.get(entity_ids[0]).state == STATE_ON
assert hass.states.get(entity_ids[1]).state == STATE_OFF

View file

@ -24,10 +24,12 @@ async def test_form(hass):
), patch(
"homeassistant.components.blink.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.blink.async_setup_entry", return_value=True,
"homeassistant.components.blink.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"username": "blink@example.com", "password": "example"},
result["flow_id"],
{"username": "blink@example.com", "password": "example"},
)
assert result2["type"] == "create_entry"
@ -62,7 +64,8 @@ async def test_form_2fa(hass):
"homeassistant.components.blink.async_setup", return_value=True
) as mock_setup:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"username": "blink@example.com", "password": "example"},
result["flow_id"],
{"username": "blink@example.com", "password": "example"},
)
assert result2["type"] == "form"
@ -106,7 +109,8 @@ async def test_form_2fa_connect_error(hass):
return_value=True,
), patch("homeassistant.components.blink.async_setup", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"username": "blink@example.com", "password": "example"},
result["flow_id"],
{"username": "blink@example.com", "password": "example"},
)
assert result2["type"] == "form"
@ -146,7 +150,8 @@ async def test_form_2fa_invalid_key(hass):
return_value=True,
), patch("homeassistant.components.blink.async_setup", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"username": "blink@example.com", "password": "example"},
result["flow_id"],
{"username": "blink@example.com", "password": "example"},
)
assert result2["type"] == "form"
@ -186,7 +191,8 @@ async def test_form_2fa_unknown_error(hass):
return_value=True,
), patch("homeassistant.components.blink.async_setup", return_value=True):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"username": "blink@example.com", "password": "example"},
result["flow_id"],
{"username": "blink@example.com", "password": "example"},
)
assert result2["type"] == "form"
@ -239,7 +245,8 @@ async def test_form_unknown_error(hass):
)
with patch(
"homeassistant.components.blink.config_flow.Auth.startup", side_effect=KeyError,
"homeassistant.components.blink.config_flow.Auth.startup",
side_effect=KeyError,
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"username": "blink@example.com", "password": "example"}
@ -288,7 +295,8 @@ async def test_options_flow(hass):
assert result["step_id"] == "simple_options"
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={"scan_interval": 5},
result["flow_id"],
user_input={"scan_interval": 5},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY

View file

@ -113,7 +113,8 @@ def patch_bond_device_ids(enabled: bool = True, return_value=None, side_effect=N
def patch_bond_device(return_value=None):
"""Patch Bond API device endpoint."""
return patch(
"homeassistant.components.bond.Bond.device", return_value=return_value,
"homeassistant.components.bond.Bond.device",
return_value=return_value,
)

View file

@ -162,7 +162,8 @@ async def test_zeroconf_form(hass: core.HomeAssistant):
return_value={"bondid": "test-bond-id"}
), patch_bond_device_ids(), _patch_async_setup() as mock_setup, _patch_async_setup_entry() as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_ACCESS_TOKEN: "test-token"},
result["flow_id"],
{CONF_ACCESS_TOKEN: "test-token"},
)
assert result2["type"] == "create_entry"
@ -249,4 +250,7 @@ def _patch_async_setup():
def _patch_async_setup_entry():
return patch("homeassistant.components.bond.async_setup_entry", return_value=True,)
return patch(
"homeassistant.components.bond.async_setup_entry",
return_value=True,
)

View file

@ -45,7 +45,10 @@ async def turn_fan_on(
if speed:
service_data[fan.ATTR_SPEED] = speed
await hass.services.async_call(
FAN_DOMAIN, SERVICE_TURN_ON, service_data=service_data, blocking=True,
FAN_DOMAIN,
SERVICE_TURN_ON,
service_data=service_data,
blocking=True,
)
await hass.async_block_till_done()
@ -149,7 +152,10 @@ async def test_turn_off_fan(hass: core.HomeAssistant):
with patch_bond_action() as mock_turn_off, patch_bond_device_state():
await hass.services.async_call(
FAN_DOMAIN, SERVICE_TURN_OFF, {ATTR_ENTITY_ID: "fan.name_1"}, blocking=True,
FAN_DOMAIN,
SERVICE_TURN_OFF,
{ATTR_ENTITY_ID: "fan.name_1"},
blocking=True,
)
await hass.async_block_till_done()

View file

@ -27,7 +27,8 @@ async def test_async_setup_no_domain_config(hass: HomeAssistant):
async def test_async_setup_raises_entry_not_ready(hass: HomeAssistant):
"""Test that it throws ConfigEntryNotReady when exception occurs during setup."""
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
domain=DOMAIN,
data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
)
config_entry.add_to_hass(hass)
@ -39,7 +40,8 @@ async def test_async_setup_raises_entry_not_ready(hass: HomeAssistant):
async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAssistant):
"""Test that configuring entry sets up cover domain."""
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
domain=DOMAIN,
data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
)
with patch_bond_version(
@ -86,7 +88,8 @@ async def test_async_setup_entry_sets_up_hub_and_supported_domains(hass: HomeAss
async def test_unload_config_entry(hass: HomeAssistant):
"""Test that configuration entry supports unloading."""
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
domain=DOMAIN,
data={CONF_HOST: "some host", CONF_ACCESS_TOKEN: "test-token"},
)
result = await setup_bond_entity(

View file

@ -165,7 +165,10 @@ async def test_brightness_support(hass: core.HomeAssistant):
async def test_brightness_not_supported(hass: core.HomeAssistant):
"""Tests that a non-dimmable light should not support the brightness feature."""
await setup_platform(
hass, LIGHT_DOMAIN, ceiling_fan("name-1"), bond_device_id="test-device-id",
hass,
LIGHT_DOMAIN,
ceiling_fan("name-1"),
bond_device_id="test-device-id",
)
state = hass.states.get("light.name_1")

View file

@ -40,7 +40,8 @@ async def test_flow_user_works(hass):
with patch("broadlink.discover", return_value=[mock_api]) as mock_discover:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
assert result["type"] == "form"
@ -48,7 +49,8 @@ async def test_flow_user_works(hass):
assert result["errors"] == {}
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"name": device.name},
result["flow_id"],
{"name": device.name},
)
assert result["type"] == "create_entry"
@ -69,7 +71,8 @@ async def test_flow_user_already_in_progress(hass):
with patch("broadlink.discover", return_value=[device.get_mock_api()]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
result = await hass.config_entries.flow.async_init(
@ -78,7 +81,8 @@ async def test_flow_user_already_in_progress(hass):
with patch("broadlink.discover", return_value=[device.get_mock_api()]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
assert result["type"] == "abort"
@ -104,7 +108,8 @@ async def test_flow_user_mac_already_configured(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
assert result["type"] == "abort"
@ -122,7 +127,8 @@ async def test_flow_user_invalid_ip_address(hass):
with patch("broadlink.discover", side_effect=OSError(errno.EINVAL, None)):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "0.0.0.1"},
result["flow_id"],
{"host": "0.0.0.1"},
)
assert result["type"] == "form"
@ -138,7 +144,8 @@ async def test_flow_user_invalid_hostname(hass):
with patch("broadlink.discover", side_effect=OSError(socket.EAI_NONAME, None)):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "pancakemaster.local"},
result["flow_id"],
{"host": "pancakemaster.local"},
)
assert result["type"] == "form"
@ -156,7 +163,8 @@ async def test_flow_user_device_not_found(hass):
with patch("broadlink.discover", return_value=[]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host},
result["flow_id"],
{"host": device.host},
)
assert result["type"] == "form"
@ -172,7 +180,8 @@ async def test_flow_user_network_unreachable(hass):
with patch("broadlink.discover", side_effect=OSError(errno.ENETUNREACH, None)):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "192.168.1.32"},
result["flow_id"],
{"host": "192.168.1.32"},
)
assert result["type"] == "form"
@ -188,7 +197,8 @@ async def test_flow_user_os_error(hass):
with patch("broadlink.discover", side_effect=OSError()):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "192.168.1.32"},
result["flow_id"],
{"host": "192.168.1.32"},
)
assert result["type"] == "form"
@ -208,7 +218,8 @@ async def test_flow_auth_authentication_error(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
assert result["type"] == "form"
@ -228,7 +239,8 @@ async def test_flow_auth_device_offline(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host},
result["flow_id"],
{"host": device.host},
)
assert result["type"] == "form"
@ -248,7 +260,8 @@ async def test_flow_auth_firmware_error(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host},
result["flow_id"],
{"host": device.host},
)
assert result["type"] == "form"
@ -268,7 +281,8 @@ async def test_flow_auth_network_unreachable(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host},
result["flow_id"],
{"host": device.host},
)
assert result["type"] == "form"
@ -288,7 +302,8 @@ async def test_flow_auth_os_error(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host},
result["flow_id"],
{"host": device.host},
)
assert result["type"] == "form"
@ -308,16 +323,19 @@ async def test_flow_reset_works(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
with patch("broadlink.discover", return_value=[device.get_mock_api()]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"name": device.name},
result["flow_id"],
{"name": device.name},
)
assert result["type"] == "create_entry"
@ -337,7 +355,8 @@ async def test_flow_unlock_works(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
assert result["type"] == "form"
@ -345,11 +364,13 @@ async def test_flow_unlock_works(hass):
assert result["errors"] == {}
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"unlock": True},
result["flow_id"],
{"unlock": True},
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"name": device.name},
result["flow_id"],
{"name": device.name},
)
assert result["type"] == "create_entry"
@ -373,11 +394,13 @@ async def test_flow_unlock_device_offline(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"unlock": True},
result["flow_id"],
{"unlock": True},
)
assert result["type"] == "form"
@ -398,11 +421,13 @@ async def test_flow_unlock_firmware_error(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"unlock": True},
result["flow_id"],
{"unlock": True},
)
assert result["type"] == "form"
@ -423,11 +448,13 @@ async def test_flow_unlock_network_unreachable(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"unlock": True},
result["flow_id"],
{"unlock": True},
)
assert result["type"] == "form"
@ -448,11 +475,13 @@ async def test_flow_unlock_os_error(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"unlock": True},
result["flow_id"],
{"unlock": True},
)
assert result["type"] == "form"
@ -472,15 +501,18 @@ async def test_flow_do_not_unlock(hass):
with patch("broadlink.discover", return_value=[mock_api]):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"unlock": False},
result["flow_id"],
{"unlock": False},
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"name": device.name},
result["flow_id"],
{"name": device.name},
)
assert result["type"] == "create_entry"
@ -507,7 +539,8 @@ async def test_flow_import_works(hass):
assert result["errors"] == {}
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"name": device.name},
result["flow_id"],
{"name": device.name},
)
assert result["type"] == "create_entry"
@ -671,7 +704,8 @@ async def test_flow_reauth_works(hass):
with patch("broadlink.discover", return_value=[mock_api]) as mock_discover:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
assert result["type"] == "abort"
@ -704,7 +738,8 @@ async def test_flow_reauth_invalid_host(hass):
with patch("broadlink.discover", return_value=[mock_api]) as mock_discover:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
assert result["type"] == "form"
@ -737,7 +772,8 @@ async def test_flow_reauth_valid_host(hass):
with patch("broadlink.discover", return_value=[mock_api]) as mock_discover:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": device.host, "timeout": device.timeout},
result["flow_id"],
{"host": device.host, "timeout": device.timeout},
)
assert result["type"] == "abort"

View file

@ -13,7 +13,9 @@ from tests.test_util.aiohttp import AiohttpClientMocker
async def init_integration(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_setup: bool = False,
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
skip_setup: bool = False,
) -> MockConfigEntry:
"""Set up the BSBLan integration in Home Assistant."""

View file

@ -17,7 +17,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker
async def test_show_user_form(hass: HomeAssistant) -> None:
"""Test that the user set up form is served."""
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": SOURCE_USER},
config_flow.DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "user"
@ -70,7 +71,8 @@ async def test_full_user_flow_implementation(
)
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": SOURCE_USER},
config_flow.DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "user"

View file

@ -27,7 +27,8 @@ async def mock_camera_fixture(hass):
await hass.async_block_till_done()
with patch(
"homeassistant.components.demo.camera.Path.read_bytes", return_value=b"Test",
"homeassistant.components.demo.camera.Path.read_bytes",
return_value=b"Test",
):
yield
@ -258,7 +259,8 @@ async def test_play_stream_service_no_source(hass, mock_camera, mock_stream):
async def test_handle_play_stream_service(hass, mock_camera, mock_stream):
"""Test camera play_stream service."""
await async_process_ha_core_config(
hass, {"external_url": "https://example.com"},
hass,
{"external_url": "https://example.com"},
)
await async_setup_component(hass, "media_player", {})
with patch(

View file

@ -9,7 +9,8 @@ from tests.common import MockConfigEntry, async_mock_signal
async def test_service_show_view(hass):
"""Test we don't set app id in prod."""
await async_process_ha_core_config(
hass, {"external_url": "https://example.com"},
hass,
{"external_url": "https://example.com"},
)
await home_assistant_cast.async_setup_ha_cast(hass, MockConfigEntry())
calls = async_mock_signal(hass, home_assistant_cast.SIGNAL_HASS_CAST_SHOW_VIEW)
@ -35,7 +36,8 @@ async def test_service_show_view(hass):
async def test_service_show_view_dashboard(hass):
"""Test casting a specific dashboard."""
await async_process_ha_core_config(
hass, {"external_url": "https://example.com"},
hass,
{"external_url": "https://example.com"},
)
await home_assistant_cast.async_setup_ha_cast(hass, MockConfigEntry())
calls = async_mock_signal(hass, home_assistant_cast.SIGNAL_HASS_CAST_SHOW_VIEW)
@ -61,7 +63,8 @@ async def test_service_show_view_dashboard(hass):
async def test_use_cloud_url(hass):
"""Test that we fall back to cloud url."""
await async_process_ha_core_config(
hass, {"internal_url": "http://example.local:8123"},
hass,
{"internal_url": "http://example.local:8123"},
)
hass.config.components.add("cloud")

View file

@ -629,7 +629,8 @@ async def test_failed_cast_other_url(hass, caplog):
async def test_failed_cast_internal_url(hass, caplog):
"""Test warning when casting from internal_url fails."""
await async_process_ha_core_config(
hass, {"internal_url": "http://example.local:8123"},
hass,
{"internal_url": "http://example.local:8123"},
)
with assert_setup_component(1, tts.DOMAIN):
assert await async_setup_component(
@ -653,7 +654,8 @@ async def test_failed_cast_internal_url(hass, caplog):
async def test_failed_cast_external_url(hass, caplog):
"""Test warning when casting from external_url fails."""
await async_process_ha_core_config(
hass, {"external_url": "http://example.com:8123"},
hass,
{"external_url": "http://example.com:8123"},
)
with assert_setup_component(1, tts.DOMAIN):
assert await async_setup_component(

View file

@ -462,7 +462,8 @@ async def test_websocket_subscription_not_logged_in(hass, hass_ws_client):
"""Test querying the status."""
client = await hass_ws_client(hass)
with patch(
"hass_nabucasa.Cloud.fetch_subscription_info", return_value={"return": "value"},
"hass_nabucasa.Cloud.fetch_subscription_info",
return_value={"return": "value"},
):
await client.send_json({"id": 5, "type": "cloud/subscription"})
response = await client.receive_json()

View file

@ -111,11 +111,16 @@ async def test_reload(hass):
assert hass.states.get("cover.test").state
yaml_path = path.join(
_get_fixtures_base_path(), "fixtures", "command_line/configuration.yaml",
_get_fixtures_base_path(),
"fixtures",
"command_line/configuration.yaml",
)
with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path):
await hass.services.async_call(
"command_line", SERVICE_RELOAD, {}, blocking=True,
"command_line",
SERVICE_RELOAD,
{},
blocking=True,
)
await hass.async_block_till_done()

View file

@ -78,7 +78,9 @@ class TestCommandSensorSensor(unittest.TestCase):
return_value=b"Works\n",
) as check_output:
data = command_line.CommandSensorData(
self.hass, 'echo "{{ states.sensor.test_state.state }}" "3 4"', 15,
self.hass,
'echo "{{ states.sensor.test_state.state }}" "3 4"',
15,
)
data.update()

View file

@ -406,7 +406,8 @@ async def test_continue_flow_unauth(hass, client, hass_admin_user):
hass_admin_user.groups = []
resp = await client.post(
f"/api/config/config_entries/flow/{flow_id}", json={"user_title": "user-title"},
f"/api/config/config_entries/flow/{flow_id}",
json={"user_title": "user-title"},
)
assert resp.status == 401

View file

@ -125,7 +125,8 @@ async def test_websocket_bad_core_update(hass, client):
async def test_detect_config(hass, client):
"""Test detect config."""
with patch(
"homeassistant.util.location.async_detect_location_info", return_value=None,
"homeassistant.util.location.async_detect_location_info",
return_value=None,
):
await client.send_json({"id": 1, "type": "config/core/detect"})

View file

@ -55,7 +55,8 @@ async def test_update_entity(hass, hass_client):
with patch("homeassistant.components.config._read", mock_read), patch(
"homeassistant.components.config._write", mock_write
), patch(
"homeassistant.config.async_hass_config_yaml", return_value={},
"homeassistant.config.async_hass_config_yaml",
return_value={},
):
resp = await client.post(
"/api/config/customize/config/hello.world",

View file

@ -15,6 +15,7 @@ zeroconf.install_multiple_zeroconf_catcher = lambda zc: None
def prevent_io():
"""Fixture to prevent certain I/O from happening."""
with patch(
"homeassistant.components.http.ban.async_load_ip_bans_config", return_value=[],
"homeassistant.components.http.ban.async_load_ip_bans_config",
return_value=[],
):
yield

View file

@ -64,7 +64,8 @@ async def test_form(hass):
), patch(
"homeassistant.components.control4.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.control4.async_setup_entry", return_value=True,
"homeassistant.components.control4.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -171,7 +172,8 @@ async def test_option_flow(hass):
assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_SCAN_INTERVAL: 4},
result["flow_id"],
user_input={CONF_SCAN_INTERVAL: 4},
)
assert result["type"] == "create_entry"
assert result["data"] == {

View file

@ -26,7 +26,8 @@ async def test_form(hass):
), patch(
"homeassistant.components.coolmaster.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.coolmaster.async_setup_entry", return_value=True,
"homeassistant.components.coolmaster.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], _flow_data()

View file

@ -13,7 +13,8 @@ async def test_form(hass):
assert result["errors"] == {}
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"country": OPTION_WORLDWIDE},
result["flow_id"],
{"country": OPTION_WORLDWIDE},
)
assert result2["type"] == "create_entry"
assert result2["title"] == "Worldwide"

View file

@ -54,14 +54,17 @@ def mock_daikin_discovery():
async def test_user(hass, mock_daikin):
"""Test user config."""
result = await hass.config_entries.flow.async_init(
"daikin", context={"source": SOURCE_USER},
"daikin",
context={"source": SOURCE_USER},
)
assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_init(
"daikin", context={"source": SOURCE_USER}, data={CONF_HOST: HOST},
"daikin",
context={"source": SOURCE_USER},
data={CONF_HOST: HOST},
)
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
assert result["title"] == HOST
@ -73,7 +76,9 @@ async def test_abort_if_already_setup(hass, mock_daikin):
"""Test we abort if Daikin is already setup."""
MockConfigEntry(domain="daikin", unique_id=MAC).add_to_hass(hass)
result = await hass.config_entries.flow.async_init(
"daikin", context={"source": SOURCE_USER}, data={CONF_HOST: HOST, KEY_MAC: MAC},
"daikin",
context={"source": SOURCE_USER},
data={CONF_HOST: HOST, KEY_MAC: MAC},
)
assert result["type"] == RESULT_TYPE_ABORT
@ -83,13 +88,17 @@ async def test_abort_if_already_setup(hass, mock_daikin):
async def test_import(hass, mock_daikin):
"""Test import step."""
result = await hass.config_entries.flow.async_init(
"daikin", context={"source": SOURCE_IMPORT}, data={},
"daikin",
context={"source": SOURCE_IMPORT},
data={},
)
assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "user"
result = await hass.config_entries.flow.async_init(
"daikin", context={"source": SOURCE_IMPORT}, data={CONF_HOST: HOST},
"daikin",
context={"source": SOURCE_IMPORT},
data={CONF_HOST: HOST},
)
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
assert result["title"] == HOST
@ -111,7 +120,9 @@ async def test_device_abort(hass, mock_daikin, s_effect, reason):
mock_daikin.factory.side_effect = s_effect
result = await hass.config_entries.flow.async_init(
"daikin", context={"source": SOURCE_USER}, data={CONF_HOST: HOST, KEY_MAC: MAC},
"daikin",
context={"source": SOURCE_USER},
data={CONF_HOST: HOST, KEY_MAC: MAC},
)
assert result["type"] == RESULT_TYPE_FORM
assert result["errors"] == {"base": reason}
@ -130,7 +141,9 @@ async def test_discovery_zeroconf(
):
"""Test discovery/zeroconf step."""
result = await hass.config_entries.flow.async_init(
"daikin", context={"source": source}, data=data,
"daikin",
context={"source": source},
data=data,
)
assert result["type"] == RESULT_TYPE_FORM
assert result["step_id"] == "user"
@ -146,7 +159,9 @@ async def test_discovery_zeroconf(
assert result["reason"] == "already_configured"
result = await hass.config_entries.flow.async_init(
"daikin", context={"source": source}, data=data,
"daikin",
context={"source": source},
data=data,
)
assert result["type"] == RESULT_TYPE_ABORT

View file

@ -161,7 +161,10 @@ class TestDatadog(unittest.TestCase):
)
assert mock_client.gauge.call_args == mock.call(
"ha.sensor", out, sample_rate=1, tags=[f"entity:{state.entity_id}"],
"ha.sensor",
out,
sample_rate=1,
tags=[f"entity:{state.entity_id}"],
)
mock_client.gauge.reset_mock()

View file

@ -53,7 +53,9 @@ async def test_on_demand(hass: HomeAssistant, mock_debugpy) -> None:
assert len(mock_debugpy.method_calls) == 0
await hass.services.async_call(
DOMAIN, SERVICE_START, blocking=True,
DOMAIN,
SERVICE_START,
blocking=True,
)
mock_debugpy.listen.assert_called_once_with(("127.0.0.1", 80))

View file

@ -87,7 +87,8 @@ async def test_flow_manual_configuration_decision(hass, aioclient_mock):
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
result["flow_id"],
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -134,7 +135,8 @@ async def test_flow_manual_configuration(hass, aioclient_mock):
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
result["flow_id"],
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -209,7 +211,8 @@ async def test_manual_configuration_update_configuration(hass, aioclient_mock):
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "2.3.4.5", CONF_PORT: 80},
result["flow_id"],
user_input={CONF_HOST: "2.3.4.5", CONF_PORT: 80},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -254,7 +257,8 @@ async def test_manual_configuration_dont_update_configuration(hass, aioclient_mo
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
result["flow_id"],
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -296,7 +300,8 @@ async def test_manual_configuration_timeout_get_bridge(hass, aioclient_mock):
assert result["step_id"] == "manual_input"
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
result["flow_id"],
user_input={CONF_HOST: "1.2.3.4", CONF_PORT: 80},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -401,7 +406,8 @@ async def test_ssdp_discovery_update_configuration(hass):
gateway = await setup_deconz_integration(hass)
with patch(
"homeassistant.components.deconz.async_setup_entry", return_value=True,
"homeassistant.components.deconz.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -478,7 +484,8 @@ async def test_flow_hassio_discovery(hass):
with patch(
"homeassistant.components.deconz.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.deconz.async_setup_entry", return_value=True,
"homeassistant.components.deconz.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={}
@ -500,7 +507,8 @@ async def test_hassio_discovery_update_configuration(hass):
gateway = await setup_deconz_integration(hass)
with patch(
"homeassistant.components.deconz.async_setup_entry", return_value=True,
"homeassistant.components.deconz.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
DOMAIN,

View file

@ -136,7 +136,8 @@ async def test_update_address(hass):
assert gateway.api.host == "1.2.3.4"
with patch(
"homeassistant.components.deconz.async_setup_entry", return_value=True,
"homeassistant.components.deconz.async_setup_entry",
return_value=True,
) as mock_setup_entry:
await hass.config_entries.flow.async_init(
deconz.config_flow.DOMAIN,
@ -173,7 +174,8 @@ async def test_get_gateway(hass):
async def test_get_gateway_fails_unauthorized(hass):
"""Failed call."""
with patch(
"pydeconz.DeconzSession.initialize", side_effect=pydeconz.errors.Unauthorized,
"pydeconz.DeconzSession.initialize",
side_effect=pydeconz.errors.Unauthorized,
), pytest.raises(deconz.errors.AuthenticationRequired):
assert (
await deconz.gateway.get_gateway(hass, ENTRY_CONFIG, Mock(), Mock())
@ -184,7 +186,8 @@ async def test_get_gateway_fails_unauthorized(hass):
async def test_get_gateway_fails_cannot_connect(hass):
"""Failed call."""
with patch(
"pydeconz.DeconzSession.initialize", side_effect=pydeconz.errors.RequestError,
"pydeconz.DeconzSession.initialize",
side_effect=pydeconz.errors.RequestError,
), pytest.raises(deconz.errors.CannotConnect):
assert (
await deconz.gateway.get_gateway(hass, ENTRY_CONFIG, Mock(), Mock())

View file

@ -55,7 +55,8 @@ def denonavr_connect_fixture():
"homeassistant.components.denonavr.receiver.denonavr.DenonAVR.get_device_info",
return_value=True,
), patch(
"homeassistant.components.denonavr.receiver.denonavr.DenonAVR.name", TEST_NAME,
"homeassistant.components.denonavr.receiver.denonavr.DenonAVR.name",
TEST_NAME,
), patch(
"homeassistant.components.denonavr.receiver.denonavr.DenonAVR.model_name",
TEST_MODEL,
@ -92,7 +93,8 @@ async def test_config_flow_manual_host_success(hass):
assert result["errors"] == {}
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST},
result["flow_id"],
{CONF_HOST: TEST_HOST},
)
assert result["type"] == "create_entry"
@ -125,7 +127,10 @@ async def test_config_flow_manual_discover_1_success(hass):
"homeassistant.components.denonavr.config_flow.denonavr.ssdp.identify_denonavr_receivers",
return_value=TEST_DISCOVER_1_RECEIVER,
):
result = await hass.config_entries.flow.async_configure(result["flow_id"], {},)
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
)
assert result["type"] == "create_entry"
assert result["title"] == TEST_NAME
@ -157,14 +162,18 @@ async def test_config_flow_manual_discover_2_success(hass):
"homeassistant.components.denonavr.config_flow.denonavr.ssdp.identify_denonavr_receivers",
return_value=TEST_DISCOVER_2_RECEIVER,
):
result = await hass.config_entries.flow.async_configure(result["flow_id"], {},)
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
)
assert result["type"] == "form"
assert result["step_id"] == "select"
assert result["errors"] == {}
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"select_host": TEST_HOST2},
result["flow_id"],
{"select_host": TEST_HOST2},
)
assert result["type"] == "create_entry"
@ -197,7 +206,10 @@ async def test_config_flow_manual_discover_error(hass):
"homeassistant.components.denonavr.config_flow.denonavr.ssdp.identify_denonavr_receivers",
return_value=[],
):
result = await hass.config_entries.flow.async_configure(result["flow_id"], {},)
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
)
assert result["type"] == "form"
assert result["step_id"] == "user"
@ -223,7 +235,8 @@ async def test_config_flow_manual_host_no_serial(hass):
None,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST},
result["flow_id"],
{CONF_HOST: TEST_HOST},
)
assert result["type"] == "create_entry"
@ -257,7 +270,8 @@ async def test_config_flow_manual_host_no_mac(hass):
return_value=None,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST},
result["flow_id"],
{CONF_HOST: TEST_HOST},
)
assert result["type"] == "create_entry"
@ -294,7 +308,8 @@ async def test_config_flow_manual_host_no_serial_no_mac(hass):
return_value=None,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST},
result["flow_id"],
{CONF_HOST: TEST_HOST},
)
assert result["type"] == "create_entry"
@ -331,7 +346,8 @@ async def test_config_flow_manual_host_no_serial_no_mac_exception(hass):
side_effect=OSError,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST},
result["flow_id"],
{CONF_HOST: TEST_HOST},
)
assert result["type"] == "create_entry"
@ -368,7 +384,8 @@ async def test_config_flow_manual_host_connection_error(hass):
None,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST},
result["flow_id"],
{CONF_HOST: TEST_HOST},
)
assert result["type"] == "abort"
@ -394,7 +411,8 @@ async def test_config_flow_manual_host_no_device_info(hass):
None,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST},
result["flow_id"],
{CONF_HOST: TEST_HOST},
)
assert result["type"] == "abort"
@ -417,7 +435,10 @@ async def test_config_flow_ssdp(hass):
assert result["type"] == "form"
assert result["step_id"] == "confirm"
result = await hass.config_entries.flow.async_configure(result["flow_id"], {},)
result = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
)
assert result["type"] == "create_entry"
assert result["title"] == TEST_NAME
@ -549,7 +570,8 @@ async def test_config_flow_manual_host_no_serial_double_config(hass):
None,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST},
result["flow_id"],
{CONF_HOST: TEST_HOST},
)
assert result["type"] == "create_entry"
@ -576,7 +598,8 @@ async def test_config_flow_manual_host_no_serial_double_config(hass):
None,
):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {CONF_HOST: TEST_HOST},
result["flow_id"],
{CONF_HOST: TEST_HOST},
)
assert result["type"] == "abort"

View file

@ -36,7 +36,8 @@ ENTITY_ID = f"{media_player.DOMAIN}.{TEST_NAME}"
def client_fixture():
"""Patch of client library for tests."""
with patch(
"homeassistant.components.denonavr.receiver.denonavr.DenonAVR", autospec=True,
"homeassistant.components.denonavr.receiver.denonavr.DenonAVR",
autospec=True,
) as mock_client_class, patch(
"homeassistant.components.denonavr.receiver.denonavr.discover"
):
@ -64,7 +65,9 @@ async def setup_denonavr(hass):
}
mock_entry = MockConfigEntry(
domain=DOMAIN, unique_id=TEST_UNIQUE_ID, data=entry_data,
domain=DOMAIN,
unique_id=TEST_UNIQUE_ID,
data=entry_data,
)
mock_entry.add_to_hass(hass)

View file

@ -222,7 +222,9 @@ async def test_initialize_start(hass):
"""Test we initialize when HA starts."""
hass.state = CoreState.not_running
assert await async_setup_component(
hass, device_sun_light_trigger.DOMAIN, {device_sun_light_trigger.DOMAIN: {}},
hass,
device_sun_light_trigger.DOMAIN,
{device_sun_light_trigger.DOMAIN: {}},
)
with patch(

View file

@ -17,7 +17,8 @@ async def test_form(hass):
assert result["errors"] == {}
with patch(
"homeassistant.components.devolo_home_control.async_setup", return_value=True,
"homeassistant.components.devolo_home_control.async_setup",
return_value=True,
) as mock_setup, patch(
"homeassistant.components.devolo_home_control.async_setup_entry",
return_value=True,
@ -96,7 +97,8 @@ async def test_form_advanced_options(hass):
assert result["errors"] == {}
with patch(
"homeassistant.components.devolo_home_control.async_setup", return_value=True,
"homeassistant.components.devolo_home_control.async_setup",
return_value=True,
) as mock_setup, patch(
"homeassistant.components.devolo_home_control.async_setup_entry",
return_value=True,

View file

@ -25,10 +25,12 @@ async def test_form(hass):
), patch(
"homeassistant.components.dexcom.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.dexcom.async_setup_entry", return_value=True,
"homeassistant.components.dexcom.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], CONFIG,
result["flow_id"],
CONFIG,
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
@ -46,10 +48,12 @@ async def test_form_account_error(hass):
)
with patch(
"homeassistant.components.dexcom.config_flow.Dexcom", side_effect=AccountError,
"homeassistant.components.dexcom.config_flow.Dexcom",
side_effect=AccountError,
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], CONFIG,
result["flow_id"],
CONFIG,
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -63,10 +67,12 @@ async def test_form_session_error(hass):
)
with patch(
"homeassistant.components.dexcom.config_flow.Dexcom", side_effect=SessionError,
"homeassistant.components.dexcom.config_flow.Dexcom",
side_effect=SessionError,
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], CONFIG,
result["flow_id"],
CONFIG,
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -80,10 +86,12 @@ async def test_form_unknown_error(hass):
)
with patch(
"homeassistant.components.dexcom.config_flow.Dexcom", side_effect=Exception,
"homeassistant.components.dexcom.config_flow.Dexcom",
side_effect=Exception,
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], CONFIG,
result["flow_id"],
CONFIG,
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -92,7 +100,11 @@ async def test_form_unknown_error(hass):
async def test_option_flow_default(hass):
"""Test config flow options."""
entry = MockConfigEntry(domain=DOMAIN, data=CONFIG, options=None,)
entry = MockConfigEntry(
domain=DOMAIN,
data=CONFIG,
options=None,
)
entry.add_to_hass(hass)
result = await hass.config_entries.options.async_init(entry.entry_id)
@ -101,7 +113,8 @@ async def test_option_flow_default(hass):
assert result["step_id"] == "init"
result2 = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={},
result["flow_id"],
user_input={},
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result2["data"] == {
@ -112,7 +125,9 @@ async def test_option_flow_default(hass):
async def test_option_flow(hass):
"""Test config flow options."""
entry = MockConfigEntry(
domain=DOMAIN, data=CONFIG, options={CONF_UNIT_OF_MEASUREMENT: MG_DL},
domain=DOMAIN,
data=CONFIG,
options={CONF_UNIT_OF_MEASUREMENT: MG_DL},
)
entry.add_to_hass(hass)
@ -122,7 +137,8 @@ async def test_option_flow(hass):
assert result["step_id"] == "init"
result = await hass.config_entries.options.async_configure(
result["flow_id"], user_input={CONF_UNIT_OF_MEASUREMENT: MMOL_L},
result["flow_id"],
user_input={CONF_UNIT_OF_MEASUREMENT: MMOL_L},
)
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["data"] == {

View file

@ -19,7 +19,8 @@ async def test_setup_entry_account_error(hass):
options=None,
)
with patch(
"homeassistant.components.dexcom.Dexcom", side_effect=AccountError,
"homeassistant.components.dexcom.Dexcom",
side_effect=AccountError,
):
entry.add_to_hass(hass)
result = await hass.config_entries.async_setup(entry.entry_id)
@ -38,7 +39,8 @@ async def test_setup_entry_session_error(hass):
options=None,
)
with patch(
"homeassistant.components.dexcom.Dexcom", side_effect=SessionError,
"homeassistant.components.dexcom.Dexcom",
side_effect=SessionError,
):
entry.add_to_hass(hass)
result = await hass.config_entries.async_setup(entry.entry_id)

View file

@ -98,7 +98,8 @@ async def test_sensors_options_changed(hass):
return_value="test_session_id",
):
hass.config_entries.async_update_entry(
entry=entry, options={CONF_UNIT_OF_MEASUREMENT: MMOL_L},
entry=entry,
options={CONF_UNIT_OF_MEASUREMENT: MMOL_L},
)
await hass.async_block_till_done()

View file

@ -79,7 +79,8 @@ async def fixture(hass, aiohttp_client):
)
await async_process_ha_core_config(
hass, {"internal_url": "http://example.local:8123"},
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(

View file

@ -28,7 +28,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker
async def test_show_user_form(hass: HomeAssistantType) -> None:
"""Test that the user set up form is served."""
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER},
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
)
assert result["step_id"] == "user"
@ -59,7 +60,9 @@ async def test_cannot_connect(
user_input = MOCK_USER_INPUT.copy()
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input,
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
data=user_input,
)
assert result["type"] == RESULT_TYPE_FORM
@ -75,7 +78,9 @@ async def test_ssdp_cannot_connect(
discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy()
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info,
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=discovery_info,
)
assert result["type"] == RESULT_TYPE_ABORT
@ -107,7 +112,9 @@ async def test_user_device_exists_abort(
user_input = MOCK_USER_INPUT.copy()
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input,
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
data=user_input,
)
assert result["type"] == RESULT_TYPE_ABORT
@ -122,7 +129,9 @@ async def test_ssdp_device_exists_abort(
discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy()
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info,
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=discovery_info,
)
assert result["type"] == RESULT_TYPE_ABORT
@ -138,7 +147,9 @@ async def test_ssdp_with_receiver_id_device_exists_abort(
discovery_info = MOCK_SSDP_DISCOVERY_INFO.copy()
discovery_info[ATTR_UPNP_SERIAL] = UPNP_SERIAL
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info,
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=discovery_info,
)
assert result["type"] == RESULT_TYPE_ABORT
@ -155,7 +166,9 @@ async def test_unknown_error(
side_effect=Exception,
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER}, data=user_input,
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
data=user_input,
)
assert result["type"] == RESULT_TYPE_ABORT
@ -172,7 +185,9 @@ async def test_ssdp_unknown_error(
side_effect=Exception,
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_SSDP}, data=discovery_info,
DOMAIN,
context={CONF_SOURCE: SOURCE_SSDP},
data=discovery_info,
)
assert result["type"] == RESULT_TYPE_ABORT
@ -209,7 +224,9 @@ async def test_full_import_flow_implementation(
"homeassistant.components.directv.async_setup_entry", return_value=True
), patch("homeassistant.components.directv.async_setup", return_value=True):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_IMPORT}, data=user_input,
DOMAIN,
context={CONF_SOURCE: SOURCE_IMPORT},
data=user_input,
)
assert result["type"] == RESULT_TYPE_CREATE_ENTRY
@ -227,7 +244,8 @@ async def test_full_user_flow_implementation(
mock_connection(aioclient_mock)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={CONF_SOURCE: SOURCE_USER},
DOMAIN,
context={CONF_SOURCE: SOURCE_USER},
)
assert result["type"] == RESULT_TYPE_FORM
@ -238,7 +256,8 @@ async def test_full_user_flow_implementation(
"homeassistant.components.directv.async_setup_entry", return_value=True
), patch("homeassistant.components.directv.async_setup", return_value=True):
result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input=user_input,
result["flow_id"],
user_input=user_input,
)
assert result["type"] == RESULT_TYPE_CREATE_ENTRY

View file

@ -55,10 +55,12 @@ async def test_user_form(hass):
), patch(
"homeassistant.components.doorbird.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.doorbird.async_setup_entry", return_value=True,
"homeassistant.components.doorbird.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], VALID_CONFIG,
result["flow_id"],
VALID_CONFIG,
)
assert result2["type"] == "create_entry"
@ -98,7 +100,8 @@ async def test_form_import(hass):
), patch("homeassistant.components.logbook.async_setup", return_value=True), patch(
"homeassistant.components.doorbird.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.doorbird.async_setup_entry", return_value=True,
"homeassistant.components.doorbird.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -165,7 +168,8 @@ async def test_form_import_with_zeroconf_already_discovered(hass):
), patch("homeassistant.components.logbook.async_setup", return_value=True), patch(
"homeassistant.components.doorbird.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.doorbird.async_setup_entry", return_value=True,
"homeassistant.components.doorbird.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -264,7 +268,8 @@ async def test_form_zeroconf_correct_oui(hass):
), patch("homeassistant.components.logbook.async_setup", return_value=True), patch(
"homeassistant.components.doorbird.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.doorbird.async_setup_entry", return_value=True,
"homeassistant.components.doorbird.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], VALID_CONFIG
@ -299,7 +304,8 @@ async def test_form_user_cannot_connect(hass):
return_value=doorbirdapi,
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], VALID_CONFIG,
result["flow_id"],
VALID_CONFIG,
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
@ -325,7 +331,8 @@ async def test_form_user_invalid_auth(hass):
return_value=doorbirdapi,
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], VALID_CONFIG,
result["flow_id"],
VALID_CONFIG,
)
assert result2["type"] == "form"

View file

@ -39,7 +39,9 @@ async def test_import_cannot_connect(hass):
async def test_import_duplicate_error(hass):
"""Test that errors are shown when duplicates are added during import."""
config_entry = MockConfigEntry(
domain=DOMAIN, data={CONF_HOST: "dunehd-host"}, title="dunehd-host",
domain=DOMAIN,
data={CONF_HOST: "dunehd-host"},
title="dunehd-host",
)
config_entry.add_to_hass(hass)
@ -74,7 +76,9 @@ async def test_user_cannot_connect(hass):
async def test_duplicate_error(hass):
"""Test that errors are shown when duplicates are added."""
config_entry = MockConfigEntry(
domain=DOMAIN, data=CONFIG_HOSTNAME, title="dunehd-host",
domain=DOMAIN,
data=CONFIG_HOSTNAME,
title="dunehd-host",
)
config_entry.add_to_hass(hass)

View file

@ -88,7 +88,8 @@ async def test_service_request_area_preset(hass):
"homeassistant.components.dynalite.bridge.DynaliteDevices.async_setup",
return_value=True,
), patch(
"dynalite_devices_lib.dynalite.Dynalite.request_area_preset", return_value=True,
"dynalite_devices_lib.dynalite.Dynalite.request_area_preset",
return_value=True,
) as mock_req_area_pres:
assert await async_setup_component(
hass,
@ -105,25 +106,33 @@ async def test_service_request_area_preset(hass):
await hass.async_block_till_done()
assert len(hass.config_entries.async_entries(dynalite.DOMAIN)) == 2
await hass.services.async_call(
dynalite.DOMAIN, "request_area_preset", {"host": "1.2.3.4", "area": 2},
dynalite.DOMAIN,
"request_area_preset",
{"host": "1.2.3.4", "area": 2},
)
await hass.async_block_till_done()
mock_req_area_pres.assert_called_once_with(2, 1)
mock_req_area_pres.reset_mock()
await hass.services.async_call(
dynalite.DOMAIN, "request_area_preset", {"area": 3},
dynalite.DOMAIN,
"request_area_preset",
{"area": 3},
)
await hass.async_block_till_done()
assert mock_req_area_pres.mock_calls == [call(3, 1), call(3, 1)]
mock_req_area_pres.reset_mock()
await hass.services.async_call(
dynalite.DOMAIN, "request_area_preset", {"host": "5.6.7.8", "area": 4},
dynalite.DOMAIN,
"request_area_preset",
{"host": "5.6.7.8", "area": 4},
)
await hass.async_block_till_done()
mock_req_area_pres.assert_called_once_with(4, 1)
mock_req_area_pres.reset_mock()
await hass.services.async_call(
dynalite.DOMAIN, "request_area_preset", {"host": "6.5.4.3", "area": 5},
dynalite.DOMAIN,
"request_area_preset",
{"host": "6.5.4.3", "area": 5},
)
await hass.async_block_till_done()
mock_req_area_pres.assert_not_called()
@ -137,7 +146,9 @@ async def test_service_request_area_preset(hass):
mock_req_area_pres.assert_called_once_with(6, 9)
mock_req_area_pres.reset_mock()
await hass.services.async_call(
dynalite.DOMAIN, "request_area_preset", {"host": "1.2.3.4", "area": 7},
dynalite.DOMAIN,
"request_area_preset",
{"host": "1.2.3.4", "area": 7},
)
await hass.async_block_till_done()
mock_req_area_pres.assert_called_once_with(7, 1)
@ -179,12 +190,16 @@ async def test_service_request_channel_level(hass):
mock_req_chan_lvl.reset_mock()
with pytest.raises(MultipleInvalid):
await hass.services.async_call(
dynalite.DOMAIN, "request_channel_level", {"area": 3},
dynalite.DOMAIN,
"request_channel_level",
{"area": 3},
)
await hass.async_block_till_done()
mock_req_chan_lvl.assert_not_called()
await hass.services.async_call(
dynalite.DOMAIN, "request_channel_level", {"area": 4, "channel": 5},
dynalite.DOMAIN,
"request_channel_level",
{"area": 4, "channel": 5},
)
await hass.async_block_till_done()
assert mock_req_chan_lvl.mock_calls == [call(4, 5), call(4, 5)]

View file

@ -35,14 +35,16 @@ def mock_responses(mock):
"""Mock responses for Efergy."""
base_url = "https://engage.efergy.com/mobile_proxy/"
mock.get(
f"{base_url}getInstant?token={token}", text=load_fixture("efergy_instant.json"),
f"{base_url}getInstant?token={token}",
text=load_fixture("efergy_instant.json"),
)
mock.get(
f"{base_url}getEnergy?token={token}&offset=300&period=day",
text=load_fixture("efergy_energy.json"),
)
mock.get(
f"{base_url}getBudget?token={token}", text=load_fixture("efergy_budget.json"),
f"{base_url}getBudget?token={token}",
text=load_fixture("efergy_budget.json"),
)
mock.get(
f"{base_url}getCost?token={token}&offset=300&period=day",

View file

@ -9,7 +9,9 @@ from tests.test_util.aiohttp import AiohttpClientMocker
async def init_integration(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, skip_setup: bool = False,
hass: HomeAssistant,
aioclient_mock: AiohttpClientMocker,
skip_setup: bool = False,
) -> MockConfigEntry:
"""Set up the Elgato Key Light integration in Home Assistant."""

View file

@ -17,7 +17,8 @@ from tests.test_util.aiohttp import AiohttpClientMocker
async def test_show_user_form(hass: HomeAssistant) -> None:
"""Test that the user set up form is served."""
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": SOURCE_USER},
config_flow.DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "user"
@ -179,7 +180,8 @@ async def test_full_user_flow_implementation(
)
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN, context={"source": SOURCE_USER},
config_flow.DOMAIN,
context={"source": SOURCE_USER},
)
assert result["step_id"] == "user"

View file

@ -51,7 +51,8 @@ async def test_light_change_state(
assert state.state == STATE_ON
with patch(
"homeassistant.components.elgato.light.Elgato.light", return_value=mock_coro(),
"homeassistant.components.elgato.light.Elgato.light",
return_value=mock_coro(),
) as mock_light:
await hass.services.async_call(
LIGHT_DOMAIN,
@ -68,7 +69,8 @@ async def test_light_change_state(
mock_light.assert_called_with(on=True, brightness=100, temperature=100)
with patch(
"homeassistant.components.elgato.light.Elgato.light", return_value=mock_coro(),
"homeassistant.components.elgato.light.Elgato.light",
return_value=mock_coro(),
) as mock_light:
await hass.services.async_call(
LIGHT_DOMAIN,
@ -87,7 +89,8 @@ async def test_light_unavailable(
"""Test error/unavailable handling of an Elgato Key Light."""
await init_integration(hass, aioclient_mock)
with patch(
"homeassistant.components.elgato.light.Elgato.light", side_effect=ElgatoError,
"homeassistant.components.elgato.light.Elgato.light",
side_effect=ElgatoError,
):
with patch(
"homeassistant.components.elgato.light.Elgato.state",

View file

@ -26,11 +26,13 @@ async def test_form_user_with_secure_elk(hass):
mocked_elk = mock_elk(invalid_auth=False)
with patch(
"homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk,
"homeassistant.components.elkm1.config_flow.elkm1.Elk",
return_value=mocked_elk,
), patch(
"homeassistant.components.elkm1.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.elkm1.async_setup_entry", return_value=True,
"homeassistant.components.elkm1.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -71,11 +73,13 @@ async def test_form_user_with_non_secure_elk(hass):
mocked_elk = mock_elk(invalid_auth=False)
with patch(
"homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk,
"homeassistant.components.elkm1.config_flow.elkm1.Elk",
return_value=mocked_elk,
), patch(
"homeassistant.components.elkm1.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.elkm1.async_setup_entry", return_value=True,
"homeassistant.components.elkm1.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -114,11 +118,13 @@ async def test_form_user_with_serial_elk(hass):
mocked_elk = mock_elk(invalid_auth=False)
with patch(
"homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk,
"homeassistant.components.elkm1.config_flow.elkm1.Elk",
return_value=mocked_elk,
), patch(
"homeassistant.components.elkm1.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.elkm1.async_setup_entry", return_value=True,
"homeassistant.components.elkm1.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -154,7 +160,8 @@ async def test_form_cannot_connect(hass):
mocked_elk = mock_elk(invalid_auth=False)
with patch(
"homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk,
"homeassistant.components.elkm1.config_flow.elkm1.Elk",
return_value=mocked_elk,
), patch(
"homeassistant.components.elkm1.config_flow.async_wait_for_elk_to_sync",
return_value=False,
@ -184,7 +191,8 @@ async def test_form_invalid_auth(hass):
mocked_elk = mock_elk(invalid_auth=True)
with patch(
"homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk,
"homeassistant.components.elkm1.config_flow.elkm1.Elk",
return_value=mocked_elk,
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -208,11 +216,13 @@ async def test_form_import(hass):
mocked_elk = mock_elk(invalid_auth=False)
with patch(
"homeassistant.components.elkm1.config_flow.elkm1.Elk", return_value=mocked_elk,
"homeassistant.components.elkm1.config_flow.elkm1.Elk",
return_value=mocked_elk,
), patch(
"homeassistant.components.elkm1.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.elkm1.async_setup_entry", return_value=True,
"homeassistant.components.elkm1.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
DOMAIN,

View file

@ -120,7 +120,8 @@ async def test_manual_flow_with_invalid_path(hass):
USER_PROVIDED_PATH = "/user/provided/path"
with patch(
DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=False),
DONGLE_VALIDATE_PATH_METHOD,
Mock(return_value=False),
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "manual"}, data={CONF_DEVICE: USER_PROVIDED_PATH}
@ -149,7 +150,8 @@ async def test_import_flow_with_invalid_path(hass):
DATA_TO_IMPORT = {CONF_DEVICE: "/invalid/path/to/import"}
with patch(
DONGLE_VALIDATE_PATH_METHOD, Mock(return_value=False),
DONGLE_VALIDATE_PATH_METHOD,
Mock(return_value=False),
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "import"}, data=DATA_TO_IMPORT

View file

@ -49,7 +49,9 @@ def mock_api_connection_error():
async def test_user_connection_works(hass, mock_client):
"""Test we can finish a config flow."""
result = await hass.config_entries.flow.async_init(
"esphome", context={"source": "user"}, data=None,
"esphome",
context={"source": "user"},
data=None,
)
assert result["type"] == RESULT_TYPE_FORM

View file

@ -345,11 +345,16 @@ async def test_reload(hass):
assert hass.states.get("sensor.test")
yaml_path = path.join(
_get_fixtures_base_path(), "fixtures", "filter/configuration.yaml",
_get_fixtures_base_path(),
"fixtures",
"filter/configuration.yaml",
)
with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path):
await hass.services.async_call(
DOMAIN, SERVICE_RELOAD, {}, blocking=True,
DOMAIN,
SERVICE_RELOAD,
{},
blocking=True,
)
await hass.async_block_till_done()

View file

@ -15,7 +15,9 @@ CONF = {CONF_USERNAME: "test-username", CONF_PASSWORD: "test-password"}
async def _flow_submit(hass):
return await hass.config_entries.flow.async_init(
DOMAIN, context={"source": config_entries.SOURCE_USER}, data=CONF,
DOMAIN,
context={"source": config_entries.SOURCE_USER},
data=CONF,
)
@ -34,10 +36,12 @@ async def test_form(hass):
), patch(
"homeassistant.components.flick_electric.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.flick_electric.async_setup_entry", return_value=True,
"homeassistant.components.flick_electric.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], CONF,
result["flow_id"],
CONF,
)
assert result2["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY

View file

@ -31,14 +31,16 @@ async def test_form(hass):
mock_flume_device_list = _get_mocked_flume_device_list()
with patch(
"homeassistant.components.flume.config_flow.FlumeAuth", return_value=True,
"homeassistant.components.flume.config_flow.FlumeAuth",
return_value=True,
), patch(
"homeassistant.components.flume.config_flow.FlumeDeviceList",
return_value=mock_flume_device_list,
), patch(
"homeassistant.components.flume.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.flume.async_setup_entry", return_value=True,
"homeassistant.components.flume.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -69,14 +71,16 @@ async def test_form_import(hass):
mock_flume_device_list = _get_mocked_flume_device_list()
with patch(
"homeassistant.components.flume.config_flow.FlumeAuth", return_value=True,
"homeassistant.components.flume.config_flow.FlumeAuth",
return_value=True,
), patch(
"homeassistant.components.flume.config_flow.FlumeDeviceList",
return_value=mock_flume_device_list,
), patch(
"homeassistant.components.flume.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.flume.async_setup_entry", return_value=True,
"homeassistant.components.flume.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -109,7 +113,8 @@ async def test_form_invalid_auth(hass):
)
with patch(
"homeassistant.components.flume.config_flow.FlumeAuth", return_value=True,
"homeassistant.components.flume.config_flow.FlumeAuth",
return_value=True,
), patch(
"homeassistant.components.flume.config_flow.FlumeDeviceList",
side_effect=Exception,
@ -134,7 +139,8 @@ async def test_form_cannot_connect(hass):
DOMAIN, context={"source": config_entries.SOURCE_USER}
)
with patch(
"homeassistant.components.flume.config_flow.FlumeAuth", return_value=True,
"homeassistant.components.flume.config_flow.FlumeAuth",
return_value=True,
), patch(
"homeassistant.components.flume.config_flow.FlumeDeviceList",
side_effect=requests.exceptions.ConnectionError(),

View file

@ -31,7 +31,8 @@ async def test_general_error(hass):
conf = {CONF_LATITUDE: "51.528308", CONF_LONGITUDE: "-0.3817765"}
with patch(
"pyflunearyou.cdc.CdcReport.status_by_coordinates", side_effect=FluNearYouError,
"pyflunearyou.cdc.CdcReport.status_by_coordinates",
side_effect=FluNearYouError,
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=conf

View file

@ -89,7 +89,9 @@ async def test_config_flow(hass, config_entry):
# Also test that creating a new entry with the same host aborts
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=config_entry.data,
DOMAIN,
context={"source": SOURCE_USER},
data=config_entry.data,
)
await hass.async_block_till_done()
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT

View file

@ -528,7 +528,9 @@ async def test_bunch_of_stuff_master(hass, get_request_return_values, mock_api_o
await _service_call(hass, TEST_MASTER_ENTITY_NAME, SERVICE_TOGGLE)
for output in SAMPLE_OUTPUTS_ON:
mock_api_object.change_output.assert_any_call(
output["id"], selected=output["selected"], volume=output["volume"],
output["id"],
selected=output["selected"],
volume=output["volume"],
)
mock_api_object.set_volume.assert_any_call(volume=0)
mock_api_object.set_volume.assert_any_call(volume=SAMPLE_PLAYER_PAUSED["volume"])

View file

@ -23,7 +23,9 @@ MOCK_CONF = {
@pytest.fixture(name="mock_garmin_connect")
def mock_garmin():
"""Mock Garmin."""
with patch("homeassistant.components.garmin_connect.config_flow.Garmin",) as garmin:
with patch(
"homeassistant.components.garmin_connect.config_flow.Garmin",
) as garmin:
garmin.return_value.get_full_name.return_value = MOCK_CONF[CONF_ID]
yield garmin.return_value

View file

@ -29,10 +29,24 @@ async def test_setup(hass, legacy_patchable_time):
"""Test the general setup of the integration."""
# Set up some mock feed entries for this test.
mock_entry_1 = _generate_mock_feed_entry(
"1234", "Title 1", 15.5, (38.0, -3.0), attribution="Attribution 1",
"1234",
"Title 1",
15.5,
(38.0, -3.0),
attribution="Attribution 1",
)
mock_entry_2 = _generate_mock_feed_entry(
"2345",
"Title 2",
20.5,
(38.1, -3.1),
)
mock_entry_3 = _generate_mock_feed_entry(
"3456",
"Title 3",
25.5,
(38.2, -3.2),
)
mock_entry_2 = _generate_mock_feed_entry("2345", "Title 2", 20.5, (38.1, -3.1),)
mock_entry_3 = _generate_mock_feed_entry("3456", "Title 3", 25.5, (38.2, -3.2),)
mock_entry_4 = _generate_mock_feed_entry("4567", "Title 4", 12.5, (38.3, -3.3))
# Patching 'utcnow' to gain more control over the timed update.

View file

@ -150,7 +150,8 @@ async def setup_zones(loop, hass):
async def webhook_id(hass, geofency_client):
"""Initialize the Geofency component and get the webhook_id."""
await async_process_ha_core_config(
hass, {"internal_url": "http://example.local:8123"},
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}

View file

@ -129,7 +129,8 @@ class ComponentFactory:
assert result["step_id"] == "user"
result = await self._hass.config_entries.flow.async_configure(
result["flow_id"], user_input=config_data,
result["flow_id"],
user_input=config_data,
)
assert result
assert result["type"] == RESULT_TYPE_CREATE_ENTRY

View file

@ -22,7 +22,8 @@ async def test_auth_fail(
with patch(
"homeassistant.components.gogogate2.async_setup", return_value=True
), patch(
"homeassistant.components.gogogate2.async_setup_entry", return_value=True,
"homeassistant.components.gogogate2.async_setup_entry",
return_value=True,
):
await component_factory.configure_component()
component_factory.api_class_mock.return_value = api_mock

View file

@ -398,7 +398,9 @@ async def test_open_close(
assert hass.states.get("cover.door1").state == STATE_OPEN
await hass.services.async_call(
COVER_DOMAIN, "close_cover", service_data={"entity_id": "cover.door1"},
COVER_DOMAIN,
"close_cover",
service_data={"entity_id": "cover.door1"},
)
await hass.async_block_till_done()
component_data.api.close_door.assert_called_with(1)
@ -410,7 +412,9 @@ async def test_open_close(
# Assert mid state changed when new status is received.
await hass.services.async_call(
COVER_DOMAIN, "open_cover", service_data={"entity_id": "cover.door1"},
COVER_DOMAIN,
"open_cover",
service_data={"entity_id": "cover.door1"},
)
await hass.async_block_till_done()
component_data.api.open_door.assert_called_with(1)
@ -423,7 +427,9 @@ async def test_open_close(
await component_data.data_update_coordinator.async_refresh()
await hass.services.async_call(
HA_DOMAIN, "update_entity", service_data={"entity_id": "cover.door1"},
HA_DOMAIN,
"update_entity",
service_data={"entity_id": "cover.door1"},
)
await hass.async_block_till_done()
assert hass.states.get("cover.door1").state == STATE_CLOSED

View file

@ -27,7 +27,8 @@ async def test_google_entity_sync_serialize_with_local_sdk(hass):
hass.states.async_set("light.ceiling_lights", "off")
hass.config.api = Mock(port=1234, use_ssl=True)
await async_process_ha_core_config(
hass, {"external_url": "https://hostname:1234"},
hass,
{"external_url": "https://hostname:1234"},
)
hass.http = Mock(server_port=1234)
@ -227,7 +228,8 @@ async def test_report_state_all(agents):
@pytest.mark.parametrize(
"agents, result", [({}, 204), ({"1": 200}, 200), ({"1": 200, "2": 300}, 300)],
"agents, result",
[({}, 204), ({"1": 200}, 200), ({"1": 200, "2": 300}, 300)],
)
async def test_sync_entities_all(agents, result):
"""Test sync entities ."""

View file

@ -17,7 +17,9 @@ async def test_request_sync_service(aioclient_mock, hass):
aioclient_mock.post(ga.const.REQUEST_SYNC_BASE_URL, status=200)
await async_setup_component(
hass, "google_assistant", {"google_assistant": DUMMY_CONFIG},
hass,
"google_assistant",
{"google_assistant": DUMMY_CONFIG},
)
assert aioclient_mock.call_count == 0

View file

@ -914,7 +914,8 @@ async def test_query_disconnect(hass):
async def test_trait_execute_adding_query_data(hass):
"""Test a trait execute influencing query data."""
await async_process_ha_core_config(
hass, {"external_url": "https://example.com"},
hass,
{"external_url": "https://example.com"},
)
hass.states.async_set(
"camera.office", "idle", {"supported_features": camera.SUPPORT_STREAM}

View file

@ -110,7 +110,8 @@ async def test_brightness_light(hass):
async def test_camera_stream(hass):
"""Test camera stream trait support for camera domain."""
await async_process_ha_core_config(
hass, {"external_url": "https://example.com"},
hass,
{"external_url": "https://example.com"},
)
assert helpers.get_google_type(camera.DOMAIN, None) is not None
assert trait.CameraStreamTrait.supported(camera.DOMAIN, camera.SUPPORT_STREAM, None)
@ -564,7 +565,8 @@ async def test_light_modes(hass):
}
assert trt.can_execute(
trait.COMMAND_MODES, params={"updateModeSettings": {"effect": "colorloop"}},
trait.COMMAND_MODES,
params={"updateModeSettings": {"effect": "colorloop"}},
)
calls = async_mock_service(hass, light.DOMAIN, SERVICE_TURN_ON)
@ -988,7 +990,9 @@ async def test_lock_unlock_unlock(hass):
# Test with 2FA override
with patch.object(
BASIC_CONFIG, "should_2fa", return_value=False,
BASIC_CONFIG,
"should_2fa",
return_value=False,
):
await trt.execute(trait.COMMAND_LOCKUNLOCK, BASIC_DATA, {"lock": False}, {})
assert len(calls) == 2
@ -1150,7 +1154,10 @@ async def test_arm_disarm_arm_away(hass):
with pytest.raises(error.SmartHomeError) as err:
await trt.execute(
trait.COMMAND_ARMDISARM, PIN_DATA, {"arm": True}, {},
trait.COMMAND_ARMDISARM,
PIN_DATA,
{"arm": True},
{},
)
@ -1483,13 +1490,19 @@ async def test_inputselector(hass):
"currentInput": "game",
}
assert trt.can_execute(trait.COMMAND_INPUT, params={"newInput": "media"},)
assert trt.can_execute(
trait.COMMAND_INPUT,
params={"newInput": "media"},
)
calls = async_mock_service(
hass, media_player.DOMAIN, media_player.SERVICE_SELECT_SOURCE
)
await trt.execute(
trait.COMMAND_INPUT, BASIC_DATA, {"newInput": "media"}, {},
trait.COMMAND_INPUT,
BASIC_DATA,
{"newInput": "media"},
{},
)
assert len(calls) == 1
@ -1526,10 +1539,16 @@ async def test_inputselector_nextprev(hass, sources, source, source_next, source
hass, media_player.DOMAIN, media_player.SERVICE_SELECT_SOURCE
)
await trt.execute(
"action.devices.commands.NextInput", BASIC_DATA, {}, {},
"action.devices.commands.NextInput",
BASIC_DATA,
{},
{},
)
await trt.execute(
"action.devices.commands.PreviousInput", BASIC_DATA, {}, {},
"action.devices.commands.PreviousInput",
BASIC_DATA,
{},
{},
)
assert len(calls) == 2
@ -1563,17 +1582,26 @@ async def test_inputselector_nextprev_invalid(hass, sources, source):
with pytest.raises(SmartHomeError):
await trt.execute(
"action.devices.commands.NextInput", BASIC_DATA, {}, {},
"action.devices.commands.NextInput",
BASIC_DATA,
{},
{},
)
with pytest.raises(SmartHomeError):
await trt.execute(
"action.devices.commands.PreviousInput", BASIC_DATA, {}, {},
"action.devices.commands.PreviousInput",
BASIC_DATA,
{},
{},
)
with pytest.raises(SmartHomeError):
await trt.execute(
"action.devices.commands.InvalidCommand", BASIC_DATA, {}, {},
"action.devices.commands.InvalidCommand",
BASIC_DATA,
{},
{},
)
@ -1583,7 +1611,9 @@ async def test_modes_input_select(hass):
assert trait.ModesTrait.supported(input_select.DOMAIN, None, None)
trt = trait.ModesTrait(
hass, State("input_select.bla", "unavailable"), BASIC_CONFIG,
hass,
State("input_select.bla", "unavailable"),
BASIC_CONFIG,
)
assert trt.sync_attributes() == {"availableModes": []}
@ -1633,14 +1663,18 @@ async def test_modes_input_select(hass):
}
assert trt.can_execute(
trait.COMMAND_MODES, params={"updateModeSettings": {"option": "xyz"}},
trait.COMMAND_MODES,
params={"updateModeSettings": {"option": "xyz"}},
)
calls = async_mock_service(
hass, input_select.DOMAIN, input_select.SERVICE_SELECT_OPTION
)
await trt.execute(
trait.COMMAND_MODES, BASIC_DATA, {"updateModeSettings": {"option": "xyz"}}, {},
trait.COMMAND_MODES,
BASIC_DATA,
{"updateModeSettings": {"option": "xyz"}},
{},
)
assert len(calls) == 1
@ -1711,7 +1745,10 @@ async def test_modes_humidifier(hass):
calls = async_mock_service(hass, humidifier.DOMAIN, humidifier.SERVICE_SET_MODE)
await trt.execute(
trait.COMMAND_MODES, BASIC_DATA, {"updateModeSettings": {"mode": "away"}}, {},
trait.COMMAND_MODES,
BASIC_DATA,
{"updateModeSettings": {"mode": "away"}},
{},
)
assert len(calls) == 1
@ -1774,7 +1811,8 @@ async def test_sound_modes(hass):
}
assert trt.can_execute(
trait.COMMAND_MODES, params={"updateModeSettings": {"sound mode": "stereo"}},
trait.COMMAND_MODES,
params={"updateModeSettings": {"sound mode": "stereo"}},
)
calls = async_mock_service(
@ -2003,7 +2041,9 @@ async def test_volume_media_player(hass):
"""Test volume trait support for media player domain."""
assert helpers.get_google_type(media_player.DOMAIN, None) is not None
assert trait.VolumeTrait.supported(
media_player.DOMAIN, media_player.SUPPORT_VOLUME_SET, None,
media_player.DOMAIN,
media_player.SUPPORT_VOLUME_SET,
None,
)
trt = trait.VolumeTrait(
@ -2054,7 +2094,9 @@ async def test_volume_media_player(hass):
async def test_volume_media_player_relative(hass):
"""Test volume trait support for relative-volume-only media players."""
assert trait.VolumeTrait.supported(
media_player.DOMAIN, media_player.SUPPORT_VOLUME_STEP, None,
media_player.DOMAIN,
media_player.SUPPORT_VOLUME_STEP,
None,
)
trt = trait.VolumeTrait(
hass,
@ -2083,7 +2125,10 @@ async def test_volume_media_player_relative(hass):
)
await trt.execute(
trait.COMMAND_VOLUME_RELATIVE, BASIC_DATA, {"relativeSteps": 10}, {},
trait.COMMAND_VOLUME_RELATIVE,
BASIC_DATA,
{"relativeSteps": 10},
{},
)
assert len(calls) == 10
for call in calls:
@ -2095,7 +2140,10 @@ async def test_volume_media_player_relative(hass):
hass, media_player.DOMAIN, media_player.SERVICE_VOLUME_DOWN
)
await trt.execute(
trait.COMMAND_VOLUME_RELATIVE, BASIC_DATA, {"relativeSteps": -10}, {},
trait.COMMAND_VOLUME_RELATIVE,
BASIC_DATA,
{"relativeSteps": -10},
{},
)
assert len(calls) == 10
for call in calls:
@ -2144,7 +2192,10 @@ async def test_media_player_mute(hass):
hass, media_player.DOMAIN, media_player.SERVICE_VOLUME_MUTE
)
await trt.execute(
trait.COMMAND_MUTE, BASIC_DATA, {"mute": True}, {},
trait.COMMAND_MUTE,
BASIC_DATA,
{"mute": True},
{},
)
assert len(mute_calls) == 1
assert mute_calls[0].data == {
@ -2156,7 +2207,10 @@ async def test_media_player_mute(hass):
hass, media_player.DOMAIN, media_player.SERVICE_VOLUME_MUTE
)
await trt.execute(
trait.COMMAND_MUTE, BASIC_DATA, {"mute": False}, {},
trait.COMMAND_MUTE,
BASIC_DATA,
{"mute": False},
{},
)
assert len(unmute_calls) == 1
assert unmute_calls[0].data == {

View file

@ -64,7 +64,8 @@ async def setup_zones(loop, hass):
async def webhook_id(hass, gpslogger_client):
"""Initialize the GPSLogger component and get the webhook_id."""
await async_process_ha_core_config(
hass, {"internal_url": "http://example.local:8123"},
hass,
{"internal_url": "http://example.local:8123"},
)
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": "user"}

View file

@ -22,10 +22,12 @@ async def test_form(hass):
), patch(
"homeassistant.components.griddy.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.griddy.async_setup_entry", return_value=True,
"homeassistant.components.griddy.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"loadzone": "LZ_HOUSTON"},
result["flow_id"],
{"loadzone": "LZ_HOUSTON"},
)
assert result2["type"] == "create_entry"
@ -47,7 +49,8 @@ async def test_form_cannot_connect(hass):
side_effect=asyncio.TimeoutError,
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"loadzone": "LZ_NORTH"},
result["flow_id"],
{"loadzone": "LZ_NORTH"},
)
assert result2["type"] == "form"

View file

@ -31,18 +31,34 @@ def async_reload(hass):
@bind_hass
def set_group(
hass, object_id, name=None, entity_ids=None, icon=None, add=None,
hass,
object_id,
name=None,
entity_ids=None,
icon=None,
add=None,
):
"""Create/Update a group."""
hass.add_job(
async_set_group, hass, object_id, name, entity_ids, icon, add,
async_set_group,
hass,
object_id,
name,
entity_ids,
icon,
add,
)
@callback
@bind_hass
def async_set_group(
hass, object_id, name=None, entity_ids=None, icon=None, add=None,
hass,
object_id,
name=None,
entity_ids=None,
icon=None,
add=None,
):
"""Create/Update a group."""
data = {

View file

@ -667,11 +667,16 @@ async def test_reload(hass):
assert hass.states.get("light.light_group").state == STATE_ON
yaml_path = path.join(
_get_fixtures_base_path(), "fixtures", "group/configuration.yaml",
_get_fixtures_base_path(),
"fixtures",
"group/configuration.yaml",
)
with patch.object(hass_config, "YAML_CONFIG_FILE", yaml_path):
await hass.services.async_call(
DOMAIN, SERVICE_RELOAD, {}, blocking=True,
DOMAIN,
SERVICE_RELOAD,
{},
blocking=True,
)
await hass.async_block_till_done()

View file

@ -35,7 +35,8 @@ async def test_connect_error(hass):
conf = {CONF_IP_ADDRESS: "192.168.1.100", CONF_PORT: 7777}
with patch(
"aioguardian.client.Client.connect", side_effect=GuardianError,
"aioguardian.client.Client.connect",
side_effect=GuardianError,
):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_USER}, data=conf

View file

@ -44,14 +44,17 @@ async def test_user_form(hass):
harmonyapi = _get_mock_harmonyapi(connect=True)
with patch(
"homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi,
"homeassistant.components.harmony.util.HarmonyAPI",
return_value=harmonyapi,
), patch(
"homeassistant.components.harmony.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.harmony.async_setup_entry", return_value=True,
"homeassistant.components.harmony.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"], {"host": "1.2.3.4", "name": "friend"},
result["flow_id"],
{"host": "1.2.3.4", "name": "friend"},
)
assert result2["type"] == "create_entry"
@ -68,11 +71,13 @@ async def test_form_import(hass):
harmonyapi = _get_mock_harmonyapi(connect=True)
with patch(
"homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi,
"homeassistant.components.harmony.util.HarmonyAPI",
return_value=harmonyapi,
), patch(
"homeassistant.components.harmony.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.harmony.async_setup_entry", return_value=True,
"homeassistant.components.harmony.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -110,7 +115,8 @@ async def test_form_ssdp(hass):
harmonyapi = _get_mock_harmonyapi(connect=True)
with patch(
"homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi,
"homeassistant.components.harmony.util.HarmonyAPI",
return_value=harmonyapi,
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -129,13 +135,18 @@ async def test_form_ssdp(hass):
}
with patch(
"homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi,
"homeassistant.components.harmony.util.HarmonyAPI",
return_value=harmonyapi,
), patch(
"homeassistant.components.harmony.async_setup", return_value=True
) as mock_setup, patch(
"homeassistant.components.harmony.async_setup_entry", return_value=True,
"homeassistant.components.harmony.async_setup_entry",
return_value=True,
) as mock_setup_entry:
result2 = await hass.config_entries.flow.async_configure(result["flow_id"], {},)
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
{},
)
assert result2["type"] == "create_entry"
assert result2["title"] == "Harmony Hub"
@ -149,17 +160,22 @@ async def test_form_ssdp_aborts_before_checking_remoteid_if_host_known(hass):
"""Test we abort without connecting if the host is already known."""
await setup.async_setup_component(hass, "persistent_notification", {})
config_entry = MockConfigEntry(
domain=DOMAIN, data={"host": "2.2.2.2", "name": "any"},
domain=DOMAIN,
data={"host": "2.2.2.2", "name": "any"},
)
config_entry.add_to_hass(hass)
config_entry_without_host = MockConfigEntry(domain=DOMAIN, data={"name": "other"},)
config_entry_without_host = MockConfigEntry(
domain=DOMAIN,
data={"name": "other"},
)
config_entry_without_host.add_to_hass(hass)
harmonyapi = _get_mock_harmonyapi(connect=True)
with patch(
"homeassistant.components.harmony.util.HarmonyAPI", return_value=harmonyapi,
"homeassistant.components.harmony.util.HarmonyAPI",
return_value=harmonyapi,
):
result = await hass.config_entries.flow.async_init(
DOMAIN,
@ -179,7 +195,8 @@ async def test_form_cannot_connect(hass):
)
with patch(
"homeassistant.components.harmony.util.HarmonyAPI", side_effect=CannotConnect,
"homeassistant.components.harmony.util.HarmonyAPI",
side_effect=CannotConnect,
):
result2 = await hass.config_entries.flow.async_configure(
result["flow_id"],
@ -208,7 +225,8 @@ async def test_options_flow(hass):
harmony_client = _get_mock_harmonyclient()
with patch(
"aioharmony.harmonyapi.HarmonyClient", return_value=harmony_client,
"aioharmony.harmonyapi.HarmonyClient",
return_value=harmony_client,
), patch("homeassistant.components.harmony.remote.HarmonyRemote.write_config_file"):
config_entry.add_to_hass(hass)
assert await hass.config_entries.async_setup(config_entry.entry_id)

View file

@ -35,7 +35,8 @@ def hassio_stubs(hassio_env, hass, hass_client, aioclient_mock):
"homeassistant.components.hassio.HassIO.update_hass_timezone",
return_value={"result": "ok"},
), patch(
"homeassistant.components.hassio.HassIO.get_info", side_effect=HassioAPIError(),
"homeassistant.components.hassio.HassIO.get_info",
side_effect=HassioAPIError(),
):
hass.state = CoreState.starting
hass.loop.run_until_complete(async_setup_component(hass, "hassio", {}))
@ -60,7 +61,8 @@ async def hassio_client_supervisor(hass, aiohttp_client, hassio_stubs):
"""Return an authenticated HTTP client."""
access_token = hass.auth.async_create_access_token(hassio_stubs)
return await aiohttp_client(
hass.http.app, headers={"Authorization": f"Bearer {access_token}"},
hass.http.app,
headers={"Authorization": f"Bearer {access_token}"},
)

View file

@ -61,7 +61,8 @@ async def test_hassio_discovery_startup(hass, aioclient_mock, hassio_client):
async def test_hassio_discovery_startup_done(hass, aioclient_mock, hassio_client):
"""Test startup and discovery with hass discovery."""
aioclient_mock.post(
"http://127.0.0.1/supervisor/options", json={"result": "ok", "data": {}},
"http://127.0.0.1/supervisor/options",
json={"result": "ok", "data": {}},
)
aioclient_mock.get(
"http://127.0.0.1/discovery",

View file

@ -213,7 +213,8 @@ async def test_fail_setup_without_environ_var(hass):
async def test_warn_when_cannot_connect(hass, caplog):
"""Fail warn when we cannot connect."""
with patch.dict(os.environ, MOCK_ENVIRON), patch(
"homeassistant.components.hassio.HassIO.is_connected", return_value=None,
"homeassistant.components.hassio.HassIO.is_connected",
return_value=None,
):
result = await async_setup_component(hass, "hassio", {})
assert result

View file

@ -78,7 +78,8 @@ async def test_configuring_hisense_w4a1_not_creates_entry_for_device_not_found(h
async def test_configuring_hisense_w4a1_not_creates_entry_for_empty_import(hass):
"""Test that specifying config will not create an entry."""
with patch(
"homeassistant.components.hisense_aehw4a1.async_setup_entry", return_value=True,
"homeassistant.components.hisense_aehw4a1.async_setup_entry",
return_value=True,
) as mock_setup:
await async_setup_component(hass, hisense_aehw4a1.DOMAIN, {})
await hass.async_block_till_done()

Some files were not shown because too many files have changed in this diff Show more