Use config_entries.SOURCE_* constants (#49631)

This commit is contained in:
Ville Skyttä
2021-04-25 12:27:40 +03:00
committed by GitHub
parent 34a588d1ba
commit 153d6e891e
103 changed files with 723 additions and 488 deletions

View File

@@ -34,7 +34,14 @@ async def test_creating_entry_sets_up_media_player(hass):
assert len(mock_setup.mock_calls) == 1
@pytest.mark.parametrize("source", ["import", "user", "zeroconf"])
@pytest.mark.parametrize(
"source",
[
config_entries.SOURCE_IMPORT,
config_entries.SOURCE_USER,
config_entries.SOURCE_ZEROCONF,
],
)
async def test_single_instance(hass, source):
"""Test we only allow a single config flow."""
MockConfigEntry(domain="cast").add_to_hass(hass)
@@ -50,7 +57,7 @@ async def test_single_instance(hass, source):
async def test_user_setup(hass):
"""Test we can finish a config flow."""
result = await hass.config_entries.flow.async_init(
"cast", context={"source": "user"}
"cast", context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
@@ -70,7 +77,7 @@ async def test_user_setup(hass):
async def test_user_setup_options(hass):
"""Test we can finish a config flow."""
result = await hass.config_entries.flow.async_init(
"cast", context={"source": "user"}
"cast", context={"source": config_entries.SOURCE_USER}
)
assert result["type"] == "form"
@@ -92,7 +99,7 @@ async def test_user_setup_options(hass):
async def test_zeroconf_setup(hass):
"""Test we can finish a config flow through zeroconf."""
result = await hass.config_entries.flow.async_init(
"cast", context={"source": "zeroconf"}
"cast", context={"source": config_entries.SOURCE_ZEROCONF}
)
assert result["type"] == "form"
@@ -169,7 +176,7 @@ async def test_option_flow(hass, parameter_data):
orig_data = dict(config_entry.data)
# Reconfigure ignore_cec, known_hosts, uuid
context = {"source": "user", "show_advanced_options": True}
context = {"source": config_entries.SOURCE_USER, "show_advanced_options": True}
result = await hass.config_entries.options.async_init(
config_entry.entry_id, context=context
)
@@ -213,7 +220,7 @@ async def test_option_flow(hass, parameter_data):
async def test_known_hosts(hass, castbrowser_mock, castbrowser_constructor_mock):
"""Test known hosts is passed to pychromecasts."""
result = await hass.config_entries.flow.async_init(
"cast", context={"source": "user"}
"cast", context={"source": config_entries.SOURCE_USER}
)
result = await hass.config_entries.flow.async_configure(
result["flow_id"], {"known_hosts": "192.168.0.1, 192.168.0.2"}