diff --git a/tests/components/okok_scale/conftest.py b/tests/components/okok_scale/conftest.py index 7061026e541b..aa309394ba53 100644 --- a/tests/components/okok_scale/conftest.py +++ b/tests/components/okok_scale/conftest.py @@ -51,7 +51,7 @@ class MockBleakClient: return bytearray(OKOK_F0_GATT_DATA[id]) -@pytest.fixture +@pytest.fixture(autouse=True) def mock_bluetooth(enable_bluetooth: None) -> Generator[None]: """Auto mock bluetooth.""" diff --git a/tests/components/okok_scale/snapshots/test_sensor.ambr b/tests/components/okok_scale/snapshots/test_sensor.ambr index 2a37a669caf0..426ca7234561 100644 --- a/tests/components/okok_scale/snapshots/test_sensor.ambr +++ b/tests/components/okok_scale/snapshots/test_sensor.ambr @@ -1,4 +1,113 @@ # serializer version: 1 +# name: test_sensors[service_info0][sensor.okok_scale_2345_battery-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.okok_scale_2345_battery', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Battery', + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Battery', + 'platform': 'okok_scale', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '50:FB:19:01:23:45-battery', + 'unit_of_measurement': '%', + }) +# --- +# name: test_sensors[service_info0][sensor.okok_scale_2345_battery-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'battery', + : 'OKOK Scale (2345) Battery', + : , + : '%', + }), + 'context': , + 'entity_id': 'sensor.okok_scale_2345_battery', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '87', + }) +# --- +# name: test_sensors[service_info0][sensor.okok_scale_2345_impedance-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.okok_scale_2345_impedance', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Impedance', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Impedance', + 'platform': 'okok_scale', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'impedance', + 'unique_id': '50:FB:19:01:23:45-impedance', + 'unit_of_measurement': 'Ω', + }) +# --- +# name: test_sensors[service_info0][sensor.okok_scale_2345_impedance-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'OKOK Scale (2345) Impedance', + : , + : 'Ω', + }), + 'context': , + 'entity_id': 'sensor.okok_scale_2345_impedance', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '500', + }) +# --- # name: test_sensors[service_info0][sensor.okok_scale_2345_signal_strength-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ @@ -112,6 +221,61 @@ 'state': '85.2', }) # --- +# name: test_sensors[service_info1][sensor.okok_scale_89ab_battery-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.okok_scale_89ab_battery', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Battery', + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Battery', + 'platform': 'okok_scale', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '50:FB:19:67:89:AB-battery', + 'unit_of_measurement': '%', + }) +# --- +# name: test_sensors[service_info1][sensor.okok_scale_89ab_battery-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'battery', + : 'OKOK Scale (89AB) Battery', + : , + : '%', + }), + 'context': , + 'entity_id': 'sensor.okok_scale_89ab_battery', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '87', + }) +# --- # name: test_sensors[service_info1][sensor.okok_scale_89ab_impedance-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ @@ -279,6 +443,115 @@ 'state': '53.1', }) # --- +# name: test_sensors[service_info2][sensor.okok_scale_cdef_battery-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.okok_scale_cdef_battery', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Battery', + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Battery', + 'platform': 'okok_scale', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '80:F4:16:AB:CD:EF-battery', + 'unit_of_measurement': '%', + }) +# --- +# name: test_sensors[service_info2][sensor.okok_scale_cdef_battery-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'battery', + : 'OKOK Scale (CDEF) Battery', + : , + : '%', + }), + 'context': , + 'entity_id': 'sensor.okok_scale_cdef_battery', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '87', + }) +# --- +# name: test_sensors[service_info2][sensor.okok_scale_cdef_impedance-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.okok_scale_cdef_impedance', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Impedance', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Impedance', + 'platform': 'okok_scale', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'impedance', + 'unique_id': '80:F4:16:AB:CD:EF-impedance', + 'unit_of_measurement': 'Ω', + }) +# --- +# name: test_sensors[service_info2][sensor.okok_scale_cdef_impedance-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'OKOK Scale (CDEF) Impedance', + : , + : 'Ω', + }), + 'context': , + 'entity_id': 'sensor.okok_scale_cdef_impedance', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '500', + }) +# --- # name: test_sensors[service_info2][sensor.okok_scale_cdef_signal_strength-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ @@ -392,6 +665,115 @@ 'state': '160.8', }) # --- +# name: test_sensors[service_info3][sensor.okok_scale_4567_battery-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': , + 'entity_id': 'sensor.okok_scale_4567_battery', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Battery', + 'options': dict({ + }), + 'original_device_class': , + 'original_icon': None, + 'original_name': 'Battery', + 'platform': 'okok_scale', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': None, + 'unique_id': '50:FB:19:23:45:67-battery', + 'unit_of_measurement': '%', + }) +# --- +# name: test_sensors[service_info3][sensor.okok_scale_4567_battery-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'battery', + : 'OKOK Scale (4567) Battery', + : , + : '%', + }), + 'context': , + 'entity_id': 'sensor.okok_scale_4567_battery', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '87', + }) +# --- +# name: test_sensors[service_info3][sensor.okok_scale_4567_impedance-entry] + EntityRegistryEntrySnapshot({ + 'aliases': list([ + None, + ]), + 'area_id': None, + 'capabilities': dict({ + : , + }), + 'config_entry_id': , + 'config_subentry_id': , + 'device_class': None, + 'device_id': , + 'disabled_by': None, + 'domain': 'sensor', + 'entity_category': None, + 'entity_id': 'sensor.okok_scale_4567_impedance', + 'has_entity_name': True, + 'hidden_by': None, + 'icon': None, + 'id': , + 'labels': set({ + }), + 'name': None, + 'object_id_base': 'Impedance', + 'options': dict({ + }), + 'original_device_class': None, + 'original_icon': None, + 'original_name': 'Impedance', + 'platform': 'okok_scale', + 'previous_unique_id': None, + 'suggested_object_id': None, + 'supported_features': 0, + 'translation_key': 'impedance', + 'unique_id': '50:FB:19:23:45:67-impedance', + 'unit_of_measurement': 'Ω', + }) +# --- +# name: test_sensors[service_info3][sensor.okok_scale_4567_impedance-state] + StateSnapshot({ + 'attributes': ReadOnlyDict({ + : 'OKOK Scale (4567) Impedance', + : , + : 'Ω', + }), + 'context': , + 'entity_id': 'sensor.okok_scale_4567_impedance', + 'last_changed': , + 'last_reported': , + 'last_updated': , + 'state': '500', + }) +# --- # name: test_sensors[service_info3][sensor.okok_scale_4567_signal_strength-entry] EntityRegistryEntrySnapshot({ 'aliases': list([ diff --git a/tests/components/okok_scale/test_config_flow.py b/tests/components/okok_scale/test_config_flow.py index a87ca354f97b..1cc2ba0e5568 100644 --- a/tests/components/okok_scale/test_config_flow.py +++ b/tests/components/okok_scale/test_config_flow.py @@ -204,7 +204,6 @@ async def test_async_step_user_replace_ignored( assert result["result"].title == OKOK_F0_TITLE -@pytest.mark.usefixtures("mock_bluetooth") async def test_async_step_user_takes_precedence_over_discovery( hass: HomeAssistant, mock_setup_entry: AsyncMock ) -> None: diff --git a/tests/components/okok_scale/test_diagnostics.py b/tests/components/okok_scale/test_diagnostics.py index d64c84a45c1b..e904a5eda2d4 100644 --- a/tests/components/okok_scale/test_diagnostics.py +++ b/tests/components/okok_scale/test_diagnostics.py @@ -1,6 +1,5 @@ """Tests for the diagnostics data provided by the OKOK Scale integration.""" -import pytest from pytest_homeassistant.common import MockConfigEntry from pytest_homeassistant.components.bluetooth import ( inject_bluetooth_service_info_bleak, @@ -15,7 +14,6 @@ from homeassistant.core import HomeAssistant from . import OKOK_F0_SERVICE_INFO -@pytest.mark.usefixtures("mock_bluetooth") async def test_diagnostics( hass: HomeAssistant, hass_client: ClientSessionGenerator, diff --git a/tests/components/okok_scale/test_sensor.py b/tests/components/okok_scale/test_sensor.py index 3efc3b884700..977f872c09b3 100644 --- a/tests/components/okok_scale/test_sensor.py +++ b/tests/components/okok_scale/test_sensor.py @@ -108,7 +108,7 @@ async def test_sleepy_device_keeps_state(hass: HomeAssistant) -> None: assert mass_sensor.attributes[ATTR_ASSUMED_STATE] is True -@pytest.mark.usefixtures("entity_registry_enabled_by_default", "mock_bluetooth") +@pytest.mark.usefixtures("entity_registry_enabled_by_default") async def test_sensors_f0( hass: HomeAssistant, entity_registry: er.EntityRegistry,