Fix openuv.config_flow unit test (#16419)

This commit is contained in:
Jason Hu 2018-09-04 12:18:35 -07:00 committed by Pascal Vizeli
parent 746f4ac158
commit 3afc983c05

View file

@ -26,7 +26,6 @@ async def test_duplicate_error(hass):
assert result['errors'] == {'base': 'identifier_exists'}
@patch('pyopenuv.util.validate_api_key', return_value=mock_coro(False))
async def test_invalid_api_key(hass):
"""Test that an invalid API key throws an error."""
conf = {
@ -39,6 +38,8 @@ async def test_invalid_api_key(hass):
flow = config_flow.OpenUvFlowHandler()
flow.hass = hass
with patch('pyopenuv.util.validate_api_key',
return_value=mock_coro(False)):
result = await flow.async_step_user(user_input=conf)
assert result['errors'] == {'base': 'invalid_api_key'}
@ -54,7 +55,6 @@ async def test_show_form(hass):
assert result['step_id'] == 'user'
@patch('pyopenuv.util.validate_api_key', return_value=mock_coro(True))
async def test_step_import(hass):
"""Test that the import step works."""
conf = {
@ -64,6 +64,8 @@ async def test_step_import(hass):
flow = config_flow.OpenUvFlowHandler()
flow.hass = hass
with patch('pyopenuv.util.validate_api_key',
return_value=mock_coro(True)):
result = await flow.async_step_import(import_config=conf)
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
@ -72,7 +74,6 @@ async def test_step_import(hass):
assert result['data'] == conf
@patch('pyopenuv.util.validate_api_key', return_value=mock_coro(True))
async def test_step_user(hass):
"""Test that the user step works."""
conf = {
@ -85,6 +86,8 @@ async def test_step_user(hass):
flow = config_flow.OpenUvFlowHandler()
flow.hass = hass
with patch('pyopenuv.util.validate_api_key',
return_value=mock_coro(True)):
result = await flow.async_step_user(user_input=conf)
assert result['type'] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY