Add port to plugwise (#40017)
This commit is contained in:
4 files changed
+53
-7
No files matched your search
@@ -3,7 +3,11 @@ from Plugwise_Smile.Smile import Smile
|
||||
import pytest
|
||||
|
||||
from homeassistant import config_entries, data_entry_flow, setup
|
||||
from homeassistant.components.plugwise.const import DEFAULT_SCAN_INTERVAL, DOMAIN
|
||||
from homeassistant.components.plugwise.const import (
|
||||
DEFAULT_PORT,
|
||||
DEFAULT_SCAN_INTERVAL,
|
||||
DOMAIN,
|
||||
)
|
||||
from homeassistant.config_entries import SOURCE_USER, SOURCE_ZEROCONF
|
||||
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PASSWORD, CONF_SCAN_INTERVAL
|
||||
|
||||
@@ -13,8 +17,11 @@ from tests.common import MockConfigEntry
|
||||
TEST_HOST = "1.1.1.1"
|
||||
TEST_HOSTNAME = "smileabcdef"
|
||||
TEST_PASSWORD = "test_password"
|
||||
TEST_PORT = 81
|
||||
|
||||
TEST_DISCOVERY = {
|
||||
"host": TEST_HOST,
|
||||
"port": DEFAULT_PORT,
|
||||
"hostname": f"{TEST_HOSTNAME}.local.",
|
||||
"server": f"{TEST_HOSTNAME}.local.",
|
||||
"properties": {
|
||||
@@ -68,6 +75,7 @@ async def test_form(hass):
|
||||
assert result2["data"] == {
|
||||
"host": TEST_HOST,
|
||||
"password": TEST_PASSWORD,
|
||||
"port": DEFAULT_PORT,
|
||||
}
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
@@ -106,6 +114,7 @@ async def test_zeroconf_form(hass):
|
||||
assert result2["data"] == {
|
||||
"host": TEST_HOST,
|
||||
"password": TEST_PASSWORD,
|
||||
"port": DEFAULT_PORT,
|
||||
}
|
||||
|
||||
assert len(mock_setup.mock_calls) == 1
|
||||
@@ -176,6 +185,24 @@ async def test_form_cannot_connect(hass, mock_smile):
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_cannot_connect_port(hass, mock_smile):
|
||||
"""Test we handle cannot connect to port error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||
)
|
||||
|
||||
mock_smile.connect.side_effect = Smile.ConnectionFailedError
|
||||
mock_smile.gateway_id = "0a636a4fc1704ab4a24e4f7e37fb187a"
|
||||
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
result["flow_id"],
|
||||
{"host": TEST_HOST, "password": TEST_PASSWORD, "port": TEST_PORT},
|
||||
)
|
||||
|
||||
assert result2["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result2["errors"] == {"base": "cannot_connect"}
|
||||
|
||||
|
||||
async def test_form_other_problem(hass, mock_smile):
|
||||
"""Test we handle cannot connect error."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
||||
Reference in new issue
Block a user