mirror of
https://github.com/home-assistant/core.git
synced 2025-11-10 11:29:46 +00:00
Improve bluesound conftest function (#154828)
This commit is contained in:
@@ -1,9 +1,11 @@
|
|||||||
"""Common fixtures for the Bluesound tests."""
|
"""Common fixtures for the Bluesound tests."""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from collections.abc import AsyncGenerator, Generator
|
from collections.abc import AsyncGenerator, Generator
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
import ipaddress
|
import ipaddress
|
||||||
from typing import Any
|
from typing import Any, Self
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
from pyblu import Input, Player, Preset, Status, SyncStatus
|
from pyblu import Input, Player, Preset, Status, SyncStatus
|
||||||
@@ -27,8 +29,8 @@ class PlayerMockData:
|
|||||||
status_long_polling_mock: LongPollingMock[Status]
|
status_long_polling_mock: LongPollingMock[Status]
|
||||||
sync_status_long_polling_mock: LongPollingMock[SyncStatus]
|
sync_status_long_polling_mock: LongPollingMock[SyncStatus]
|
||||||
|
|
||||||
@staticmethod
|
@classmethod
|
||||||
async def generate(host: str) -> "PlayerMockData":
|
async def generate(cls, host: str) -> Self:
|
||||||
"""Generate player mock data."""
|
"""Generate player mock data."""
|
||||||
host_ip = ipaddress.ip_address(host)
|
host_ip = ipaddress.ip_address(host)
|
||||||
assert host_ip.version == 4
|
assert host_ip.version == 4
|
||||||
@@ -110,7 +112,7 @@ class PlayerMockData:
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
return PlayerMockData(
|
return cls(
|
||||||
host, player, status_long_polling_mock, sync_status_long_polling_mock
|
host, player, status_long_polling_mock, sync_status_long_polling_mock
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user