1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Rewrite dyson fan test (#45295)

* Improve device fixture to take parameter

* Remove unused code in dyson/fan

* Rewrite dyson fan test
This commit is contained in:
Xiaonan Shen
2021-01-19 17:12:38 +08:00
committed by GitHub
parent 07c3981de7
commit c929fbeea3
4 changed files with 357 additions and 897 deletions

View File

@@ -18,8 +18,12 @@ BASE_PATH = "homeassistant.components.dyson"
@pytest.fixture
async def device(hass: HomeAssistant, request) -> DysonDevice:
"""Fixture to provide Dyson 360 Eye device."""
device = request.module.get_device()
platform = request.module.PLATFORM_DOMAIN
get_device = request.module.get_device
if hasattr(request, "param"):
device = get_device(request.param)
else:
device = get_device()
with patch(f"{BASE_PATH}.DysonAccount.login", return_value=True), patch(
f"{BASE_PATH}.DysonAccount.devices", return_value=[device]
), patch(f"{BASE_PATH}.DYSON_PLATFORMS", [platform]):