This commit is contained in:
Paulus Schoutsen committed 2019-07-31 12:25:30 -07:00
1 parent da05dfe708
commit 4de97abc3a
2676 files changed
+163166 -140084

No files matched your search

@@ -4,7 +4,12 @@ from unittest.mock import patch
from homeassistant import data_entry_flow
from homeassistant.components.rainmachine import DOMAIN, config_flow
from homeassistant.const import (
CONF_IP_ADDRESS, CONF_PASSWORD, CONF_PORT, CONF_SSL, CONF_SCAN_INTERVAL)
CONF_IP_ADDRESS,
CONF_PASSWORD,
CONF_PORT,
CONF_SSL,
CONF_SCAN_INTERVAL,
)
from tests.common import MockConfigEntry, mock_coro
@@ -12,8 +17,8 @@ from tests.common import MockConfigEntry, mock_coro
async def test_duplicate_error(hass):
"""Test that errors are shown when duplicates are added."""
conf = {
CONF_IP_ADDRESS: '192.168.1.100',
CONF_PASSWORD: 'password',
CONF_IP_ADDRESS: "192.168.1.100",
CONF_PASSWORD: "password",
CONF_PORT: 8080,
CONF_SSL: True,
}
@@ -23,7 +28,7 @@ async def test_duplicate_error(hass):
flow.hass = hass
result = await flow.async_step_user(user_input=conf)
assert result['errors'] == {CONF_IP_ADDRESS: 'identifier_exists'}
assert result["errors"] == {CONF_IP_ADDRESS: "identifier_exists"}
async def test_invalid_password(hass):
@@ -31,8 +36,8 @@ async def test_invalid_password(hass):
from regenmaschine.errors import RainMachineError
conf = {
CONF_IP_ADDRESS: '192.168.1.100',
CONF_PASSWORD: 'bad_password',
CONF_IP_ADDRESS: "192.168.1.100",
CONF_PASSWORD: "bad_password",
CONF_PORT: 8080,
CONF_SSL: True,
}
@@ -40,10 +45,11 @@ async def test_invalid_password(hass):
flow = config_flow.RainMachineFlowHandler()
flow.hass = hass
with patch('regenmaschine.login',
return_value=mock_coro(exception=RainMachineError)):
with patch(
"regenmaschine.login", return_value=mock_coro(exception=RainMachineError)
):
result = await flow.async_step_user(user_input=conf)
assert result['errors'] == {CONF_PASSWORD: 'invalid_credentials'}
assert result["errors"] == {CONF_PASSWORD: "invalid_credentials"}
async def test_show_form(hass):
@@ -53,15 +59,15 @@ async def test_show_form(hass):
result = await flow.async_step_user(user_input=None)
assert result['type'] == data_entry_flow.RESULT_TYPE_FORM
assert result['step_id'] == 'user'
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
assert result["step_id"] == "user"
async def test_step_import(hass):
"""Test that the import step works."""
conf = {
CONF_IP_ADDRESS: '192.168.1.100',
CONF_PASSWORD: 'password',
CONF_IP_ADDRESS: "192.168.1.100",
CONF_PASSWORD: "password",
CONF_PORT: 8080,
CONF_SSL: True,
}
@@ -69,14 +75,14 @@ async def test_step_import(hass):
flow = config_flow.RainMachineFlowHandler()
flow.hass = hass
with patch('regenmaschine.login', return_value=mock_coro(True)):
with patch("regenmaschine.login", return_value=mock_coro(True)):
result = await flow.async_step_import(import_config=conf)
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result['title'] == '192.168.1.100'
assert result['data'] == {
CONF_IP_ADDRESS: '192.168.1.100',
CONF_PASSWORD: 'password',
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "192.168.1.100"
assert result["data"] == {
CONF_IP_ADDRESS: "192.168.1.100",
CONF_PASSWORD: "password",
CONF_PORT: 8080,
CONF_SSL: True,
CONF_SCAN_INTERVAL: 60,
@@ -86,8 +92,8 @@ async def test_step_import(hass):
async def test_step_user(hass):
"""Test that the user step works."""
conf = {
CONF_IP_ADDRESS: '192.168.1.100',
CONF_PASSWORD: 'password',
CONF_IP_ADDRESS: "192.168.1.100",
CONF_PASSWORD: "password",
CONF_PORT: 8080,
CONF_SSL: True,
}
@@ -95,14 +101,14 @@ async def test_step_user(hass):
flow = config_flow.RainMachineFlowHandler()
flow.hass = hass
with patch('regenmaschine.login', return_value=mock_coro(True)):
with patch("regenmaschine.login", return_value=mock_coro(True)):
result = await flow.async_step_user(user_input=conf)
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result['title'] == '192.168.1.100'
assert result['data'] == {
CONF_IP_ADDRESS: '192.168.1.100',
CONF_PASSWORD: 'password',
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
assert result["title"] == "192.168.1.100"
assert result["data"] == {
CONF_IP_ADDRESS: "192.168.1.100",
CONF_PASSWORD: "password",
CONF_PORT: 8080,
CONF_SSL: True,
CONF_SCAN_INTERVAL: 60,