Fix tests & lint
This commit is contained in:
1 parent
28e9f1d0b8
commit
dad11f8208
14 files changed
+112
-87
No files matched your search
@@ -1,6 +1,8 @@
|
||||
"""Define tests for the OpenUV config flow."""
|
||||
from unittest.mock import patch
|
||||
|
||||
from regenmaschine.errors import RainMachineError
|
||||
|
||||
from homeassistant import data_entry_flow
|
||||
from homeassistant.components.rainmachine import DOMAIN, config_flow
|
||||
from homeassistant.const import (
|
||||
@@ -33,8 +35,6 @@ async def test_duplicate_error(hass):
|
||||
|
||||
async def test_invalid_password(hass):
|
||||
"""Test that an invalid password throws an error."""
|
||||
from regenmaschine.errors import RainMachineError
|
||||
|
||||
conf = {
|
||||
CONF_IP_ADDRESS: "192.168.1.100",
|
||||
CONF_PASSWORD: "bad_password",
|
||||
@@ -46,7 +46,8 @@ async def test_invalid_password(hass):
|
||||
flow.hass = hass
|
||||
|
||||
with patch(
|
||||
"regenmaschine.login", return_value=mock_coro(exception=RainMachineError)
|
||||
"homeassistant.components.rainmachine.config_flow.login",
|
||||
return_value=mock_coro(exception=RainMachineError),
|
||||
):
|
||||
result = await flow.async_step_user(user_input=conf)
|
||||
assert result["errors"] == {CONF_PASSWORD: "invalid_credentials"}
|
||||
@@ -75,7 +76,10 @@ async def test_step_import(hass):
|
||||
flow = config_flow.RainMachineFlowHandler()
|
||||
flow.hass = hass
|
||||
|
||||
with patch("regenmaschine.login", return_value=mock_coro(True)):
|
||||
with patch(
|
||||
"homeassistant.components.rainmachine.config_flow.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
|
||||
@@ -101,7 +105,10 @@ async def test_step_user(hass):
|
||||
flow = config_flow.RainMachineFlowHandler()
|
||||
flow.hass = hass
|
||||
|
||||
with patch("regenmaschine.login", return_value=mock_coro(True)):
|
||||
with patch(
|
||||
"homeassistant.components.rainmachine.config_flow.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
|
||||
|
||||
Reference in new issue
Block a user