Fix adding Virtual DSM system in synology_dsm (#42523)
parent
529b849efe
commit
0959777b81
|
@ -275,7 +275,6 @@ def _login_and_fetch_syno_info(api, otp_code):
|
|||
if (
|
||||
not api.information.serial
|
||||
or api.utilisation.cpu_user_load is None
|
||||
or not api.storage.disks_ids
|
||||
or not api.storage.volumes_ids
|
||||
or not api.network.macs
|
||||
):
|
||||
|
|
|
@ -81,6 +81,20 @@ def mock_controller_service_2sa():
|
|||
yield service_mock
|
||||
|
||||
|
||||
@pytest.fixture(name="service_vdsm")
|
||||
def mock_controller_service_vdsm():
|
||||
"""Mock a successful service."""
|
||||
with patch(
|
||||
"homeassistant.components.synology_dsm.config_flow.SynologyDSM"
|
||||
) as service_mock:
|
||||
service_mock.return_value.information.serial = SERIAL
|
||||
service_mock.return_value.utilisation.cpu_user_load = 1
|
||||
service_mock.return_value.storage.disks_ids = []
|
||||
service_mock.return_value.storage.volumes_ids = ["volume_1"]
|
||||
service_mock.return_value.network.macs = MACS
|
||||
yield service_mock
|
||||
|
||||
|
||||
@pytest.fixture(name="service_failed")
|
||||
def mock_controller_service_failed():
|
||||
"""Mock a failed service."""
|
||||
|
@ -196,6 +210,40 @@ async def test_user_2sa(hass: HomeAssistantType, service_2sa: MagicMock):
|
|||
assert result["data"].get(CONF_VOLUMES) is None
|
||||
|
||||
|
||||
async def test_user_vdsm(hass: HomeAssistantType, service_vdsm: MagicMock):
|
||||
"""Test user config."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN, context={"source": SOURCE_USER}, data=None
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_FORM
|
||||
assert result["step_id"] == "user"
|
||||
|
||||
# test with all provided
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
DOMAIN,
|
||||
context={"source": SOURCE_USER},
|
||||
data={
|
||||
CONF_HOST: HOST,
|
||||
CONF_PORT: PORT,
|
||||
CONF_SSL: SSL,
|
||||
CONF_USERNAME: USERNAME,
|
||||
CONF_PASSWORD: PASSWORD,
|
||||
},
|
||||
)
|
||||
assert result["type"] == data_entry_flow.RESULT_TYPE_CREATE_ENTRY
|
||||
assert result["result"].unique_id == SERIAL
|
||||
assert result["title"] == HOST
|
||||
assert result["data"][CONF_HOST] == HOST
|
||||
assert result["data"][CONF_PORT] == PORT
|
||||
assert result["data"][CONF_SSL] == SSL
|
||||
assert result["data"][CONF_USERNAME] == USERNAME
|
||||
assert result["data"][CONF_PASSWORD] == PASSWORD
|
||||
assert result["data"][CONF_MAC] == MACS
|
||||
assert result["data"].get("device_token") is None
|
||||
assert result["data"].get(CONF_DISKS) is None
|
||||
assert result["data"].get(CONF_VOLUMES) is None
|
||||
|
||||
|
||||
async def test_import(hass: HomeAssistantType, service: MagicMock):
|
||||
"""Test import step."""
|
||||
# import with minimum setup
|
||||
|
|
Loading…
Reference in New Issue