Black
This commit is contained in:
1 parent
da05dfe708
commit
4de97abc3a
2676 files changed
+163166
-140084
No files matched your search
@@ -8,13 +8,20 @@ from asynctest import CoroutineMock, patch
|
||||
from pytest import fixture
|
||||
|
||||
from .consts import (
|
||||
DUMMY_AUTO_OFF_SET, DUMMY_DEVICE_ID, DUMMY_DEVICE_NAME,
|
||||
DUMMY_DEVICE_STATE, DUMMY_ELECTRIC_CURRENT, DUMMY_IP_ADDRESS,
|
||||
DUMMY_MAC_ADDRESS, DUMMY_PHONE_ID, DUMMY_POWER_CONSUMPTION,
|
||||
DUMMY_REMAINING_TIME)
|
||||
DUMMY_AUTO_OFF_SET,
|
||||
DUMMY_DEVICE_ID,
|
||||
DUMMY_DEVICE_NAME,
|
||||
DUMMY_DEVICE_STATE,
|
||||
DUMMY_ELECTRIC_CURRENT,
|
||||
DUMMY_IP_ADDRESS,
|
||||
DUMMY_MAC_ADDRESS,
|
||||
DUMMY_PHONE_ID,
|
||||
DUMMY_POWER_CONSUMPTION,
|
||||
DUMMY_REMAINING_TIME,
|
||||
)
|
||||
|
||||
|
||||
@patch('aioswitcher.devices.SwitcherV2Device')
|
||||
@patch("aioswitcher.devices.SwitcherV2Device")
|
||||
class MockSwitcherV2Device:
|
||||
"""Class for mocking the aioswitcher.devices.SwitcherV2Device object."""
|
||||
|
||||
@@ -83,7 +90,7 @@ class MockSwitcherV2Device:
|
||||
return self._last_state_change
|
||||
|
||||
|
||||
@fixture(name='mock_bridge')
|
||||
@fixture(name="mock_bridge")
|
||||
def mock_bridge_fixture() -> Generator[None, Any, None]:
|
||||
"""Fixture for mocking aioswitcher.bridge.SwitcherV2Bridge."""
|
||||
queue = Queue() # type: Queue
|
||||
@@ -96,12 +103,11 @@ def mock_bridge_fixture() -> Generator[None, Any, None]:
|
||||
mock_bridge = CoroutineMock()
|
||||
|
||||
patchers = [
|
||||
patch('aioswitcher.bridge.SwitcherV2Bridge.start', new=mock_bridge),
|
||||
patch('aioswitcher.bridge.SwitcherV2Bridge.stop', new=mock_bridge),
|
||||
patch('aioswitcher.bridge.SwitcherV2Bridge.queue', get=mock_queue),
|
||||
patch('aioswitcher.bridge.SwitcherV2Bridge.running',
|
||||
return_value=True)
|
||||
]
|
||||
patch("aioswitcher.bridge.SwitcherV2Bridge.start", new=mock_bridge),
|
||||
patch("aioswitcher.bridge.SwitcherV2Bridge.stop", new=mock_bridge),
|
||||
patch("aioswitcher.bridge.SwitcherV2Bridge.queue", get=mock_queue),
|
||||
patch("aioswitcher.bridge.SwitcherV2Bridge.running", return_value=True),
|
||||
]
|
||||
|
||||
for patcher in patchers:
|
||||
patcher.start()
|
||||
@@ -112,18 +118,19 @@ def mock_bridge_fixture() -> Generator[None, Any, None]:
|
||||
patcher.stop()
|
||||
|
||||
|
||||
@fixture(name='mock_failed_bridge')
|
||||
@fixture(name="mock_failed_bridge")
|
||||
def mock_failed_bridge_fixture() -> Generator[None, Any, None]:
|
||||
"""Fixture for mocking aioswitcher.bridge.SwitcherV2Bridge."""
|
||||
|
||||
async def mock_queue():
|
||||
"""Mock asyncio's Queue."""
|
||||
raise RuntimeError
|
||||
|
||||
patchers = [
|
||||
patch('aioswitcher.bridge.SwitcherV2Bridge.start', return_value=None),
|
||||
patch('aioswitcher.bridge.SwitcherV2Bridge.stop', return_value=None),
|
||||
patch('aioswitcher.bridge.SwitcherV2Bridge.queue', get=mock_queue)
|
||||
]
|
||||
patch("aioswitcher.bridge.SwitcherV2Bridge.start", return_value=None),
|
||||
patch("aioswitcher.bridge.SwitcherV2Bridge.stop", return_value=None),
|
||||
patch("aioswitcher.bridge.SwitcherV2Bridge.queue", get=mock_queue),
|
||||
]
|
||||
|
||||
for patcher in patchers:
|
||||
patcher.start()
|
||||
@@ -134,15 +141,15 @@ def mock_failed_bridge_fixture() -> Generator[None, Any, None]:
|
||||
patcher.stop()
|
||||
|
||||
|
||||
@fixture(name='mock_api')
|
||||
@fixture(name="mock_api")
|
||||
def mock_api_fixture() -> Generator[CoroutineMock, Any, None]:
|
||||
"""Fixture for mocking aioswitcher.api.SwitcherV2Api."""
|
||||
mock_api = CoroutineMock()
|
||||
|
||||
patchers = [
|
||||
patch('aioswitcher.api.SwitcherV2Api.connect', new=mock_api),
|
||||
patch('aioswitcher.api.SwitcherV2Api.disconnect', new=mock_api)
|
||||
]
|
||||
patch("aioswitcher.api.SwitcherV2Api.connect", new=mock_api),
|
||||
patch("aioswitcher.api.SwitcherV2Api.disconnect", new=mock_api),
|
||||
]
|
||||
|
||||
for patcher in patchers:
|
||||
patcher.start()
|
||||
|
||||
Reference in new issue
Block a user