Remove deprecated yaml from foscam (#61761)
This commit is contained in:
parent
8cda315cd1
commit
dfcadd600c
4 changed files with 4 additions and 254 deletions
|
@ -245,176 +245,3 @@ async def test_user_unknown_exception(hass):
|
|||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["errors"] == {"base": "unknown"}
|
||||
|
||||
|
||||
async def test_import_user_valid(hass):
|
||||
"""Test valid config from import."""
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.foscam.config_flow.FoscamCamera",
|
||||
) as mock_foscam_camera, patch(
|
||||
"homeassistant.components.foscam.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
setup_mock_foscam_camera(mock_foscam_camera)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data=VALID_CONFIG,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["title"] == CAMERA_NAME
|
||||
assert result["data"] == VALID_CONFIG
|
||||
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_import_user_valid_with_name(hass):
|
||||
"""Test valid config with extra name from import."""
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.foscam.config_flow.FoscamCamera",
|
||||
) as mock_foscam_camera, patch(
|
||||
"homeassistant.components.foscam.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
setup_mock_foscam_camera(mock_foscam_camera)
|
||||
|
||||
name = CAMERA_NAME + " 1234"
|
||||
with_name = VALID_CONFIG.copy()
|
||||
with_name[config_flow.CONF_NAME] = name
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data=with_name,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["title"] == name
|
||||
assert result["data"] == VALID_CONFIG
|
||||
|
||||
assert len(mock_setup_entry.mock_calls) == 1
|
||||
|
||||
|
||||
async def test_import_invalid_auth(hass):
|
||||
"""Test we handle invalid auth from import."""
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.foscam.config_flow.FoscamCamera",
|
||||
) as mock_foscam_camera:
|
||||
setup_mock_foscam_camera(mock_foscam_camera)
|
||||
|
||||
invalid_user = VALID_CONFIG.copy()
|
||||
invalid_user[config_flow.CONF_USERNAME] = "invalid"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data=invalid_user,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "invalid_auth"
|
||||
|
||||
|
||||
async def test_import_cannot_connect(hass):
|
||||
"""Test we handle cannot connect error from import."""
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.foscam.config_flow.FoscamCamera",
|
||||
) as mock_foscam_camera:
|
||||
setup_mock_foscam_camera(mock_foscam_camera)
|
||||
|
||||
invalid_host = VALID_CONFIG.copy()
|
||||
invalid_host[config_flow.CONF_HOST] = "127.0.0.1"
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data=invalid_host,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "cannot_connect"
|
||||
|
||||
|
||||
async def test_import_invalid_response(hass):
|
||||
"""Test we handle invalid response error from import."""
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.foscam.config_flow.FoscamCamera",
|
||||
) as mock_foscam_camera:
|
||||
setup_mock_foscam_camera(mock_foscam_camera)
|
||||
|
||||
invalid_response = VALID_CONFIG.copy()
|
||||
invalid_response[config_flow.CONF_USERNAME] = INVALID_RESPONSE_CONFIG[
|
||||
config_flow.CONF_USERNAME
|
||||
]
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data=invalid_response,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "invalid_response"
|
||||
|
||||
|
||||
async def test_import_already_configured(hass):
|
||||
"""Test we handle already configured from import."""
|
||||
|
||||
entry = MockConfigEntry(
|
||||
domain=config_flow.DOMAIN,
|
||||
data=VALID_CONFIG,
|
||||
)
|
||||
entry.add_to_hass(hass)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.foscam.config_flow.FoscamCamera",
|
||||
) as mock_foscam_camera:
|
||||
setup_mock_foscam_camera(mock_foscam_camera)
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data=VALID_CONFIG,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "already_configured"
|
||||
|
||||
|
||||
async def test_import_unknown_exception(hass):
|
||||
"""Test we handle unknown exceptions from import."""
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.foscam.config_flow.FoscamCamera",
|
||||
) as mock_foscam_camera:
|
||||
mock_foscam_camera.side_effect = Exception("test")
|
||||
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
config_flow.DOMAIN,
|
||||
context={"source": config_entries.SOURCE_IMPORT},
|
||||
data=VALID_CONFIG,
|
||||
)
|
||||
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_ABORT
|
||||
assert result["reason"] == "unknown"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue