mirror of
https://github.com/home-assistant/core.git
synced 2025-12-24 12:59:34 +00:00
ScreenLogic cleanups (#48136)
* ScreenLogic cleanup. Bump screenlogicpy to 0.2.0. Move heating functions from water_heater to climate platform. Address notes from original PR. * Fix temperature attribute * Addressing notes. Bump screenlogicpy to 0.2.1. Made device_types constants. Made (known) equipment flags constants. Used dict.get() in places where None is the default. Return fast with good _last_preset. * Update homeassistant/components/screenlogic/climate.py Let base entity handle state property. Co-authored-by: J. Nick Koston <nick@koston.org> * Patch integration setup functions. * Exception, ATTR_TEMPERATURE notes Co-authored-by: J. Nick Koston <nick@koston.org>
This commit is contained in:
@@ -101,9 +101,40 @@ async def test_flow_discover_error(hass):
|
||||
assert result["errors"] == {}
|
||||
assert result["step_id"] == "gateway_entry"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.screenlogic.async_setup", return_value=True
|
||||
) as mock_setup, patch(
|
||||
"homeassistant.components.screenlogic.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry, patch(
|
||||
"homeassistant.components.screenlogic.config_flow.login.create_socket",
|
||||
return_value=True,
|
||||
), patch(
|
||||
"homeassistant.components.screenlogic.config_flow.login.gateway_connect",
|
||||
return_value="00-C0-33-01-01-01",
|
||||
):
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
CONF_PORT: 80,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["title"] == "Pentair: 01-01-01"
|
||||
assert result3["data"] == {
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
CONF_PORT: 80,
|
||||
}
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_dhcp(hass):
|
||||
"""Test DHCP discovery flow."""
|
||||
await setup.async_setup_component(hass, "persistent_notification", {})
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": "dhcp"},
|
||||
@@ -116,6 +147,36 @@ async def test_dhcp(hass):
|
||||
assert result["type"] == "form"
|
||||
assert result["step_id"] == "gateway_entry"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.screenlogic.async_setup", return_value=True
|
||||
) as mock_setup, patch(
|
||||
"homeassistant.components.screenlogic.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry, patch(
|
||||
"homeassistant.components.screenlogic.config_flow.login.create_socket",
|
||||
return_value=True,
|
||||
), patch(
|
||||
"homeassistant.components.screenlogic.config_flow.login.gateway_connect",
|
||||
return_value="00-C0-33-01-01-01",
|
||||
):
|
||||
result3 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
CONF_PORT: 80,
|
||||
},
|
||||
)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result3["type"] == "create_entry"
|
||||
assert result3["title"] == "Pentair: 01-01-01"
|
||||
assert result3["data"] == {
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
CONF_PORT: 80,
|
||||
}
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_manual_entry(hass):
|
||||
"""Test we get the form."""
|
||||
@@ -148,6 +209,11 @@ async def test_form_manual_entry(hass):
|
||||
assert result2["step_id"] == "gateway_entry"
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.screenlogic.async_setup", return_value=True
|
||||
) as mock_setup, patch(
|
||||
"homeassistant.components.screenlogic.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry, patch(
|
||||
"homeassistant.components.screenlogic.config_flow.login.create_socket",
|
||||
return_value=True,
|
||||
), patch(
|
||||
@@ -169,6 +235,8 @@ async def test_form_manual_entry(hass):
|
||||
CONF_IP_ADDRESS: "1.1.1.1",
|
||||
CONF_PORT: 80,
|
||||
}
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_form_cannot_connect(hass):
|
||||
@@ -195,9 +263,18 @@ async def test_form_cannot_connect(hass):
|
||||
|
||||
async def test_option_flow(hass):
|
||||
"""Test config flow options."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data={}, options=None)
|
||||
entry = MockConfigEntry(domain=DOMAIN)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.screenlogic.async_setup", return_value=True
|
||||
), patch(
|
||||
"homeassistant.components.screenlogic.async_setup_entry",
|
||||
return_value=True,
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
@@ -213,9 +290,18 @@ async def test_option_flow(hass):
|
||||
|
||||
async def test_option_flow_defaults(hass):
|
||||
"""Test config flow options."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data={}, options=None)
|
||||
entry = MockConfigEntry(domain=DOMAIN)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.screenlogic.async_setup", return_value=True
|
||||
), patch(
|
||||
"homeassistant.components.screenlogic.async_setup_entry",
|
||||
return_value=True,
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
@@ -232,9 +318,18 @@ async def test_option_flow_defaults(hass):
|
||||
|
||||
async def test_option_flow_input_floor(hass):
|
||||
"""Test config flow options."""
|
||||
entry = MockConfigEntry(domain=DOMAIN, data={}, options=None)
|
||||
entry = MockConfigEntry(domain=DOMAIN)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.screenlogic.async_setup", return_value=True
|
||||
), patch(
|
||||
"homeassistant.components.screenlogic.async_setup_entry",
|
||||
return_value=True,
|
||||
):
|
||||
await hass.config_entries.async_setup(entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
result = await hass.config_entries.options.async_init(entry.entry_id)
|
||||
|
||||
assert result["type"] == "form"
|
||||
|
||||
Reference in New Issue
Block a user