Add coverage for bluetooth_proxy_feature_flags_compat (#734)
This commit is contained in:
parent
ea23a18ab5
commit
0d2f8f651d
|
@ -49,6 +49,7 @@ from aioesphomeapi.model import (
|
||||||
APIVersion,
|
APIVersion,
|
||||||
BinarySensorInfo,
|
BinarySensorInfo,
|
||||||
BinarySensorState,
|
BinarySensorState,
|
||||||
|
BluetoothProxyFeature,
|
||||||
ButtonInfo,
|
ButtonInfo,
|
||||||
CameraInfo,
|
CameraInfo,
|
||||||
ClimateInfo,
|
ClimateInfo,
|
||||||
|
@ -357,3 +358,45 @@ def test_user_service_conversion():
|
||||||
def test_build_unique_id(model):
|
def test_build_unique_id(model):
|
||||||
obj = model(object_id="id")
|
obj = model(object_id="id")
|
||||||
assert build_unique_id("mac", obj) == f"mac-{_TYPE_TO_NAME[type(obj)]}-id"
|
assert build_unique_id("mac", obj) == f"mac-{_TYPE_TO_NAME[type(obj)]}-id"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
("version", "flags"),
|
||||||
|
[
|
||||||
|
(1, BluetoothProxyFeature.PASSIVE_SCAN),
|
||||||
|
(
|
||||||
|
2,
|
||||||
|
BluetoothProxyFeature.PASSIVE_SCAN
|
||||||
|
| BluetoothProxyFeature.ACTIVE_CONNECTIONS,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
3,
|
||||||
|
BluetoothProxyFeature.PASSIVE_SCAN
|
||||||
|
| BluetoothProxyFeature.ACTIVE_CONNECTIONS
|
||||||
|
| BluetoothProxyFeature.REMOTE_CACHING,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
4,
|
||||||
|
BluetoothProxyFeature.PASSIVE_SCAN
|
||||||
|
| BluetoothProxyFeature.ACTIVE_CONNECTIONS
|
||||||
|
| BluetoothProxyFeature.REMOTE_CACHING
|
||||||
|
| BluetoothProxyFeature.PAIRING,
|
||||||
|
),
|
||||||
|
(
|
||||||
|
5,
|
||||||
|
BluetoothProxyFeature.PASSIVE_SCAN
|
||||||
|
| BluetoothProxyFeature.ACTIVE_CONNECTIONS
|
||||||
|
| BluetoothProxyFeature.REMOTE_CACHING
|
||||||
|
| BluetoothProxyFeature.PAIRING
|
||||||
|
| BluetoothProxyFeature.CACHE_CLEARING,
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_bluetooth_backcompat_for_device_info(
|
||||||
|
version: int, flags: BluetoothProxyFeature
|
||||||
|
) -> None:
|
||||||
|
info = DeviceInfo(
|
||||||
|
legacy_bluetooth_proxy_version=version, bluetooth_proxy_feature_flags=42
|
||||||
|
)
|
||||||
|
info.bluetooth_proxy_feature_flags_compat(APIVersion(1, 8)) is flags
|
||||||
|
info.bluetooth_proxy_feature_flags_compat(APIVersion(1, 9)) == 42
|
||||||
|
|
Loading…
Reference in New Issue