async def test__not_get_plcnet_info(self, mock_device: Device, device_api: DeviceApi): """Test that devices know to not have a plcnet API don't query it.""" mock_device.mt_number = DEVICES_WITHOUT_PLCNET[0] with patch("devolo_plc_api.device.Device._get_zeroconf_info" ) as gzi, patch( "devolo_plc_api.device.Device._get_device_info"): mock_device.device = device_api await mock_device.async_connect() assert gzi.call_count == 0 assert not mock_device.plcnet
async def test_async_connect(self, mock_device: Device, device_api: DeviceApi, plcnet_api: PlcNetApi): """Test that connecting to a device calls methos to collect information from the APIs.""" with patch( "devolo_plc_api.device.Device._get_device_info") as gdi, patch( "devolo_plc_api.device.Device._get_plcnet_info") as gpi: mock_device.device = device_api mock_device.plcnet = plcnet_api await mock_device.async_connect() assert gdi.call_count == 1 assert gpi.call_count == 1 assert getattr(mock_device, "_connected") await mock_device.async_connect(session_instance=AsyncMock()) assert gdi.call_count == 2 assert gpi.call_count == 2 assert getattr(mock_device, "_connected")
def test_set_password(self, mock_device: Device, device_api: DeviceApi): """Test setting a device password is also reflected in the device API.""" mock_device.device = device_api mock_device.password = "******" assert mock_device.device.password == "super_secret"