Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion homeassistant/components/wled/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def async_step_zeroconf(
# pylint: disable=no-member # https://github.com/PyCQA/pylint/issues/3167
self.context.update(
{
CONF_HOST: host,
CONF_HOST: user_input["host"],
CONF_NAME: name,
CONF_MAC: user_input["properties"].get(CONF_MAC),
"title_placeholders": {"name": name},
Expand Down
10 changes: 5 additions & 5 deletions tests/components/wled/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ async def init_integration(

fixture = "wled/rgb.json" if not rgbw else "wled/rgbw.json"
aioclient_mock.get(
"http://example.local:80/json/",
"http://192.168.1.123:80/json/",
text=load_fixture(fixture),
headers={"Content-Type": "application/json"},
)

aioclient_mock.post(
"http://example.local:80/json/state",
"http://192.168.1.123:80/json/state",
json={},
headers={"Content-Type": "application/json"},
)

aioclient_mock.get(
"http://example.local:80/json/info",
"http://192.168.1.123:80/json/info",
json={},
headers={"Content-Type": "application/json"},
)

aioclient_mock.get(
"http://example.local:80/json/state",
"http://192.168.1.123:80/json/state",
json={},
headers={"Content-Type": "application/json"},
)

entry = MockConfigEntry(
domain=DOMAIN, data={CONF_HOST: "example.local", CONF_MAC: "aabbccddeeff"}
domain=DOMAIN, data={CONF_HOST: "192.168.1.123", CONF_MAC: "aabbccddeeff"}
)

entry.add_to_hass(hass)
Expand Down
44 changes: 23 additions & 21 deletions tests/components/wled/test_config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async def test_show_zerconf_form(
) -> None:
"""Test that the zeroconf confirmation form is served."""
aioclient_mock.get(
"http://example.local:80/json/",
"http://192.168.1.123:80/json/",
text=load_fixture("wled/rgb.json"),
headers={"Content-Type": "application/json"},
)
Expand All @@ -49,10 +49,10 @@ async def test_show_zerconf_form(
flow.hass = hass
flow.context = {"source": SOURCE_ZEROCONF}
result = await flow.async_step_zeroconf(
{"hostname": "example.local.", "properties": {}}
{"host": "192.168.1.123", "hostname": "example.local.", "properties": {}}
)

assert flow.context[CONF_HOST] == "example.local"
assert flow.context[CONF_HOST] == "192.168.1.123"
assert flow.context[CONF_NAME] == "example"
assert result["description_placeholders"] == {CONF_NAME: "example"}
assert result["step_id"] == "zeroconf_confirm"
Expand Down Expand Up @@ -80,12 +80,12 @@ async def test_zeroconf_connection_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort zeroconf flow on WLED connection error."""
aioclient_mock.get("http://example.local/json/", exc=aiohttp.ClientError)
aioclient_mock.get("http://192.168.1.123/json/", exc=aiohttp.ClientError)

result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
context={"source": SOURCE_ZEROCONF},
data={"hostname": "example.local.", "properties": {}},
data={"host": "192.168.1.123", "hostname": "example.local.", "properties": {}},
)

assert result["reason"] == "connection_error"
Expand All @@ -96,7 +96,7 @@ async def test_zeroconf_confirm_connection_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test we abort zeroconf flow on WLED connection error."""
aioclient_mock.get("http://example.com/json/", exc=aiohttp.ClientError)
aioclient_mock.get("http://192.168.1.123:80/json/", exc=aiohttp.ClientError)

result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
Expand All @@ -105,7 +105,7 @@ async def test_zeroconf_confirm_connection_error(
CONF_HOST: "example.com",
CONF_NAME: "test",
},
data={"hostname": "example.com.", "properties": {}},
data={"host": "192.168.1.123", "hostname": "example.com.", "properties": {}},
)

assert result["reason"] == "connection_error"
Expand Down Expand Up @@ -133,7 +133,7 @@ async def test_user_device_exists_abort(
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
context={"source": SOURCE_USER},
data={CONF_HOST: "example.local"},
data={CONF_HOST: "192.168.1.123"},
)

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
Expand All @@ -149,7 +149,7 @@ async def test_zeroconf_device_exists_abort(
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
context={"source": SOURCE_ZEROCONF},
data={"hostname": "example.local.", "properties": {}},
data={"host": "192.168.1.123", "hostname": "example.local.", "properties": {}},
)

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
Expand All @@ -165,7 +165,11 @@ async def test_zeroconf_with_mac_device_exists_abort(
result = await hass.config_entries.flow.async_init(
config_flow.DOMAIN,
context={"source": SOURCE_ZEROCONF},
data={"hostname": "example.local.", "properties": {CONF_MAC: "aabbccddeeff"}},
data={
"host": "192.168.1.123",
"hostname": "example.local.",
"properties": {CONF_MAC: "aabbccddeeff"},
},
)

assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
Expand All @@ -177,7 +181,7 @@ async def test_full_user_flow_implementation(
) -> None:
"""Test the full manual user flow from start to finish."""
aioclient_mock.get(
"http://example.local:80/json/",
"http://192.168.1.123:80/json/",
text=load_fixture("wled/rgb.json"),
headers={"Content-Type": "application/json"},
)
Expand All @@ -190,12 +194,12 @@ async def test_full_user_flow_implementation(
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM

result = await hass.config_entries.flow.async_configure(
result["flow_id"], user_input={CONF_HOST: "example.local"}
result["flow_id"], user_input={CONF_HOST: "192.168.1.123"}
)

assert result["data"][CONF_HOST] == "example.local"
assert result["data"][CONF_HOST] == "192.168.1.123"
assert result["data"][CONF_MAC] == "aabbccddeeff"
assert result["title"] == "example.local"
assert result["title"] == "192.168.1.123"
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY


Expand All @@ -204,7 +208,7 @@ async def test_full_zeroconf_flow_implementation(
) -> None:
"""Test the full manual user flow from start to finish."""
aioclient_mock.get(
"http://example.local:80/json/",
"http://192.168.1.123:80/json/",
text=load_fixture("wled/rgb.json"),
headers={"Content-Type": "application/json"},
)
Expand All @@ -213,19 +217,17 @@ async def test_full_zeroconf_flow_implementation(
flow.hass = hass
flow.context = {"source": SOURCE_ZEROCONF}
result = await flow.async_step_zeroconf(
{"hostname": "example.local.", "properties": {}}
{"host": "192.168.1.123", "hostname": "example.local.", "properties": {}}
)

assert flow.context[CONF_HOST] == "example.local"
assert flow.context[CONF_HOST] == "192.168.1.123"
assert flow.context[CONF_NAME] == "example"
assert result["description_placeholders"] == {CONF_NAME: "example"}
assert result["step_id"] == "zeroconf_confirm"
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM

result = await flow.async_step_zeroconf_confirm(
user_input={CONF_HOST: "example.local"}
)
assert result["data"][CONF_HOST] == "example.local"
result = await flow.async_step_zeroconf_confirm(user_input={})
assert result["data"][CONF_HOST] == "192.168.1.123"
assert result["data"][CONF_MAC] == "aabbccddeeff"
assert result["title"] == "example"
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
2 changes: 1 addition & 1 deletion tests/components/wled/test_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async def test_config_entry_not_ready(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test the WLED configuration entry not ready."""
aioclient_mock.get("http://example.local:80/json/", exc=aiohttp.ClientError)
aioclient_mock.get("http://192.168.1.123:80/json/", exc=aiohttp.ClientError)

entry = await init_integration(hass, aioclient_mock)
assert entry.state == ENTRY_STATE_SETUP_RETRY
Expand Down
6 changes: 3 additions & 3 deletions tests/components/wled/test_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ async def test_light_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, caplog
) -> None:
"""Test error handling of the WLED lights."""
aioclient_mock.post("http://example.local:80/json/state", text="", status=400)
aioclient_mock.post("http://192.168.1.123:80/json/state", text="", status=400)
await init_integration(hass, aioclient_mock)

with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
Expand All @@ -162,7 +162,7 @@ async def test_light_connection_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test error handling of the WLED switches."""
aioclient_mock.post("http://example.local:80/json/state", exc=aiohttp.ClientError)
aioclient_mock.post("http://192.168.1.123:80/json/state", exc=aiohttp.ClientError)
await init_integration(hass, aioclient_mock)

with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
Expand Down Expand Up @@ -339,7 +339,7 @@ async def test_effect_service_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, caplog
) -> None:
"""Test error handling of the WLED effect service."""
aioclient_mock.post("http://example.local:80/json/state", text="", status=400)
aioclient_mock.post("http://192.168.1.123:80/json/state", text="", status=400)
await init_integration(hass, aioclient_mock)

with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
Expand Down
4 changes: 2 additions & 2 deletions tests/components/wled/test_switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ async def test_switch_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, caplog
) -> None:
"""Test error handling of the WLED switches."""
aioclient_mock.post("http://example.local:80/json/state", text="", status=400)
aioclient_mock.post("http://192.168.1.123:80/json/state", text="", status=400)
await init_integration(hass, aioclient_mock)

with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
Expand All @@ -160,7 +160,7 @@ async def test_switch_connection_error(
hass: HomeAssistant, aioclient_mock: AiohttpClientMocker
) -> None:
"""Test error handling of the WLED switches."""
aioclient_mock.post("http://example.local:80/json/state", exc=aiohttp.ClientError)
aioclient_mock.post("http://192.168.1.123:80/json/state", exc=aiohttp.ClientError)
await init_integration(hass, aioclient_mock)

with patch("homeassistant.components.wled.WLEDDataUpdateCoordinator.async_refresh"):
Expand Down