Removed uncaught exceptions from Dyson (#34112)
* fixed what seems to be a typo * added load_mock_device in common.py so it loads all the required things into the mocks so they don't throw exceptions for mocks not being able to convert to int * reverted change in homeassistant/components/dyson/sensor.py added both values to the mock device (volatil and volatile)
This commit is contained in:
7 files changed
+52
-94
No files matched your search
@@ -4,13 +4,15 @@ from unittest import mock
|
||||
|
||||
from homeassistant.components import dyson
|
||||
|
||||
from .common import load_mock_device
|
||||
|
||||
from tests.common import get_test_home_assistant
|
||||
|
||||
|
||||
def _get_dyson_account_device_available():
|
||||
"""Return a valid device provide by Dyson web services."""
|
||||
device = mock.Mock()
|
||||
device.serial = "XX-XXXXX-XX"
|
||||
load_mock_device(device)
|
||||
device.connect = mock.Mock(return_value=True)
|
||||
device.auto_connect = mock.Mock(return_value=True)
|
||||
return device
|
||||
@@ -19,7 +21,7 @@ def _get_dyson_account_device_available():
|
||||
def _get_dyson_account_device_not_available():
|
||||
"""Return an invalid device provide by Dyson web services."""
|
||||
device = mock.Mock()
|
||||
device.serial = "XX-XXXXX-XX"
|
||||
load_mock_device(device)
|
||||
device.connect = mock.Mock(return_value=False)
|
||||
device.auto_connect = mock.Mock(return_value=False)
|
||||
return device
|
||||
@@ -28,7 +30,7 @@ def _get_dyson_account_device_not_available():
|
||||
def _get_dyson_account_device_error():
|
||||
"""Return an invalid device raising OSError while connecting."""
|
||||
device = mock.Mock()
|
||||
device.serial = "XX-XXXXX-XX"
|
||||
load_mock_device(device)
|
||||
device.connect = mock.Mock(side_effect=OSError("Network error"))
|
||||
return device
|
||||
|
||||
|
||||
Reference in new issue
Block a user