mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 01:08:12 +00:00
Add basic testing framework to LG ThinQ (#127785)
Co-authored-by: jangwon.lee <jangwon.lee@lge.com> Co-authored-by: Joostlek <joostlek@outlook.com> Co-authored-by: YunseonPark-LGE <34848373+YunseonPark-LGE@users.noreply.github.com> Co-authored-by: LG-ThinQ-Integration <LG-ThinQ-Integration@lge.com> Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
2052579efc
commit
22f8f117fb
@ -1 +1,13 @@
|
||||
"""Tests for the lgthinq integration."""
|
||||
"""Tests for the LG ThinQ integration."""
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def setup_integration(hass: HomeAssistant, config_entry: MockConfigEntry) -> None:
|
||||
"""Fixture for setting up the component."""
|
||||
config_entry.add_to_hass(hass)
|
||||
|
||||
await hass.config_entries.async_setup(config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
@ -11,7 +11,7 @@ from homeassistant.const import CONF_ACCESS_TOKEN, CONF_COUNTRY
|
||||
|
||||
from .const import MOCK_CONNECT_CLIENT_ID, MOCK_COUNTRY, MOCK_PAT, MOCK_UUID
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
from tests.common import MockConfigEntry, load_json_object_fixture
|
||||
|
||||
|
||||
def mock_thinq_api_response(
|
||||
@ -45,6 +45,15 @@ def mock_config_entry() -> MockConfigEntry:
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_setup_entry() -> Generator[AsyncMock]:
|
||||
"""Mock setting up a config entry."""
|
||||
with patch(
|
||||
"homeassistant.components.lg_thinq.async_setup_entry", return_value=True
|
||||
) as mock_setup_entry:
|
||||
yield mock_setup_entry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_uuid() -> Generator[AsyncMock]:
|
||||
"""Mock a uuid."""
|
||||
@ -59,22 +68,37 @@ def mock_uuid() -> Generator[AsyncMock]:
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_thinq_api() -> Generator[AsyncMock]:
|
||||
def mock_thinq_api(mock_thinq_mqtt_client: AsyncMock) -> Generator[AsyncMock]:
|
||||
"""Mock a thinq api."""
|
||||
with (
|
||||
patch("thinqconnect.ThinQApi", autospec=True) as mock_api,
|
||||
patch("homeassistant.components.lg_thinq.ThinQApi", autospec=True) as mock_api,
|
||||
patch(
|
||||
"homeassistant.components.lg_thinq.config_flow.ThinQApi",
|
||||
new=mock_api,
|
||||
),
|
||||
):
|
||||
thinq_api = mock_api.return_value
|
||||
thinq_api.async_get_device_list = AsyncMock(
|
||||
return_value=mock_thinq_api_response(status=200, body={})
|
||||
thinq_api.async_get_device_list.return_value = [
|
||||
load_json_object_fixture("air_conditioner/device.json", DOMAIN)
|
||||
]
|
||||
thinq_api.async_get_device_profile.return_value = load_json_object_fixture(
|
||||
"air_conditioner/profile.json", DOMAIN
|
||||
)
|
||||
thinq_api.async_get_device_status.return_value = load_json_object_fixture(
|
||||
"air_conditioner/status.json", DOMAIN
|
||||
)
|
||||
yield thinq_api
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_thinq_mqtt_client() -> Generator[AsyncMock]:
|
||||
"""Mock a thinq api."""
|
||||
with patch(
|
||||
"homeassistant.components.lg_thinq.mqtt.ThinQMQTTClient", autospec=True
|
||||
) as mock_api:
|
||||
yield mock_api
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_invalid_thinq_api(mock_thinq_api: AsyncMock) -> AsyncMock:
|
||||
"""Mock an invalid thinq api."""
|
||||
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"deviceId": "MW2-2E247F93-B570-46A6-B827-920E9E10F966",
|
||||
"deviceInfo": {
|
||||
"deviceType": "DEVICE_AIR_CONDITIONER",
|
||||
"modelName": "PAC_910604_WW",
|
||||
"alias": "Test air conditioner",
|
||||
"reportable": true
|
||||
}
|
||||
}
|
154
tests/components/lg_thinq/fixtures/air_conditioner/profile.json
Normal file
154
tests/components/lg_thinq/fixtures/air_conditioner/profile.json
Normal file
@ -0,0 +1,154 @@
|
||||
{
|
||||
"notification": {
|
||||
"push": ["WATER_IS_FULL"]
|
||||
},
|
||||
"property": {
|
||||
"airConJobMode": {
|
||||
"currentJobMode": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "enum",
|
||||
"value": {
|
||||
"r": ["AIR_CLEAN", "COOL", "AIR_DRY"],
|
||||
"w": ["AIR_CLEAN", "COOL", "AIR_DRY"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"airFlow": {
|
||||
"windStrength": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "enum",
|
||||
"value": {
|
||||
"r": ["LOW", "HIGH", "MID"],
|
||||
"w": ["LOW", "HIGH", "MID"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"airQualitySensor": {
|
||||
"PM1": {
|
||||
"mode": ["r"],
|
||||
"type": "number"
|
||||
},
|
||||
"PM10": {
|
||||
"mode": ["r"],
|
||||
"type": "number"
|
||||
},
|
||||
"PM2": {
|
||||
"mode": ["r"],
|
||||
"type": "number"
|
||||
},
|
||||
"humidity": {
|
||||
"mode": ["r"],
|
||||
"type": "number"
|
||||
},
|
||||
"monitoringEnabled": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "enum",
|
||||
"value": {
|
||||
"r": ["ON_WORKING", "ALWAYS"],
|
||||
"w": ["ON_WORKING", "ALWAYS"]
|
||||
}
|
||||
},
|
||||
"oder": {
|
||||
"mode": ["r"],
|
||||
"type": "number"
|
||||
},
|
||||
"totalPollution": {
|
||||
"mode": ["r"],
|
||||
"type": "number"
|
||||
}
|
||||
},
|
||||
"operation": {
|
||||
"airCleanOperationMode": {
|
||||
"mode": ["w"],
|
||||
"type": "enum",
|
||||
"value": {
|
||||
"w": ["START", "STOP"]
|
||||
}
|
||||
},
|
||||
"airConOperationMode": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "enum",
|
||||
"value": {
|
||||
"r": ["POWER_ON", "POWER_OFF"],
|
||||
"w": ["POWER_ON", "POWER_OFF"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"powerSave": {
|
||||
"powerSaveEnabled": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "boolean",
|
||||
"value": {
|
||||
"r": [false, true],
|
||||
"w": [false, true]
|
||||
}
|
||||
}
|
||||
},
|
||||
"temperature": {
|
||||
"coolTargetTemperature": {
|
||||
"mode": ["w"],
|
||||
"type": "range",
|
||||
"value": {
|
||||
"w": {
|
||||
"max": 30,
|
||||
"min": 18,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"currentTemperature": {
|
||||
"mode": ["r"],
|
||||
"type": "number"
|
||||
},
|
||||
"targetTemperature": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "range",
|
||||
"value": {
|
||||
"r": {
|
||||
"max": 30,
|
||||
"min": 18,
|
||||
"step": 1
|
||||
},
|
||||
"w": {
|
||||
"max": 30,
|
||||
"min": 18,
|
||||
"step": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"unit": {
|
||||
"mode": ["r"],
|
||||
"type": "enum",
|
||||
"value": {
|
||||
"r": ["C", "F"]
|
||||
}
|
||||
}
|
||||
},
|
||||
"timer": {
|
||||
"relativeHourToStart": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "number"
|
||||
},
|
||||
"relativeHourToStop": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "number"
|
||||
},
|
||||
"relativeMinuteToStart": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "number"
|
||||
},
|
||||
"relativeMinuteToStop": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "number"
|
||||
},
|
||||
"absoluteHourToStart": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "number"
|
||||
},
|
||||
"absoluteMinuteToStart": {
|
||||
"mode": ["r", "w"],
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
{
|
||||
"airConJobMode": {
|
||||
"currentJobMode": "COOL"
|
||||
},
|
||||
"airFlow": {
|
||||
"windStrength": "MID"
|
||||
},
|
||||
"airQualitySensor": {
|
||||
"PM1": 12,
|
||||
"PM10": 7,
|
||||
"PM2": 24,
|
||||
"humidity": 40,
|
||||
"monitoringEnabled": "ON_WORKING",
|
||||
"totalPollution": 3,
|
||||
"totalPollutionLevel": "GOOD"
|
||||
},
|
||||
"filterInfo": {
|
||||
"filterLifetime": 540,
|
||||
"usedTime": 180
|
||||
},
|
||||
"operation": {
|
||||
"airConOperationMode": "POWER_ON"
|
||||
},
|
||||
"powerSave": {
|
||||
"powerSaveEnabled": false
|
||||
},
|
||||
"sleepTimer": {
|
||||
"relativeStopTimer": "UNSET"
|
||||
},
|
||||
"temperature": {
|
||||
"currentTemperature": 25,
|
||||
"targetTemperature": 19,
|
||||
"unit": "C"
|
||||
},
|
||||
"timer": {
|
||||
"relativeStartTimer": "UNSET",
|
||||
"relativeStopTimer": "UNSET",
|
||||
"absoluteStartTimer": "SET",
|
||||
"absoluteStopTimer": "UNSET",
|
||||
"absoluteHourToStart": 13,
|
||||
"absoluteMinuteToStart": 14
|
||||
}
|
||||
}
|
86
tests/components/lg_thinq/snapshots/test_climate.ambr
Normal file
86
tests/components/lg_thinq/snapshots/test_climate.ambr
Normal file
@ -0,0 +1,86 @@
|
||||
# serializer version: 1
|
||||
# name: test_all_entities[climate.test_air_conditioner-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'fan_modes': list([
|
||||
'low',
|
||||
'high',
|
||||
'mid',
|
||||
]),
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.DRY: 'dry'>,
|
||||
]),
|
||||
'max_temp': 30,
|
||||
'min_temp': 18,
|
||||
'preset_modes': list([
|
||||
'air_clean',
|
||||
]),
|
||||
'target_temp_step': 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'climate',
|
||||
'entity_category': None,
|
||||
'entity_id': 'climate.test_air_conditioner',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': None,
|
||||
'platform': 'lg_thinq',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 409>,
|
||||
'translation_key': <ExtendedProperty.CLIMATE_AIR_CONDITIONER: 'climate_air_conditioner'>,
|
||||
'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_climate_air_conditioner',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[climate.test_air_conditioner-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'current_humidity': 40,
|
||||
'current_temperature': 25,
|
||||
'fan_mode': 'mid',
|
||||
'fan_modes': list([
|
||||
'low',
|
||||
'high',
|
||||
'mid',
|
||||
]),
|
||||
'friendly_name': 'Test air conditioner',
|
||||
'hvac_modes': list([
|
||||
<HVACMode.OFF: 'off'>,
|
||||
<HVACMode.COOL: 'cool'>,
|
||||
<HVACMode.DRY: 'dry'>,
|
||||
]),
|
||||
'max_temp': 30,
|
||||
'min_temp': 18,
|
||||
'preset_mode': None,
|
||||
'preset_modes': list([
|
||||
'air_clean',
|
||||
]),
|
||||
'supported_features': <ClimateEntityFeature: 409>,
|
||||
'target_temp_step': 1,
|
||||
'temperature': 19,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'climate.test_air_conditioner',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'cool',
|
||||
})
|
||||
# ---
|
55
tests/components/lg_thinq/snapshots/test_event.ambr
Normal file
55
tests/components/lg_thinq/snapshots/test_event.ambr
Normal file
@ -0,0 +1,55 @@
|
||||
# serializer version: 1
|
||||
# name: test_all_entities[event.test_air_conditioner_notification-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'event_types': list([
|
||||
'water_is_full',
|
||||
]),
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'event',
|
||||
'entity_category': None,
|
||||
'entity_id': 'event.test_air_conditioner_notification',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Notification',
|
||||
'platform': 'lg_thinq',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': <ThinQPropertyEx.NOTIFICATION: 'notification'>,
|
||||
'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_notification',
|
||||
'unit_of_measurement': None,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[event.test_air_conditioner_notification-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'event_type': None,
|
||||
'event_types': list([
|
||||
'water_is_full',
|
||||
]),
|
||||
'friendly_name': 'Test air conditioner Notification',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'event.test_air_conditioner_notification',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
113
tests/components/lg_thinq/snapshots/test_number.ambr
Normal file
113
tests/components/lg_thinq/snapshots/test_number.ambr
Normal file
@ -0,0 +1,113 @@
|
||||
# serializer version: 1
|
||||
# name: test_all_entities[number.test_air_conditioner_schedule_turn_off-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 100.0,
|
||||
'min': 0.0,
|
||||
'mode': <NumberMode.BOX: 'box'>,
|
||||
'step': 1.0,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.test_air_conditioner_schedule_turn_off',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Schedule turn-off',
|
||||
'platform': 'lg_thinq',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': <Property.RELATIVE_HOUR_TO_STOP: 'relative_hour_to_stop'>,
|
||||
'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_relative_hour_to_stop',
|
||||
'unit_of_measurement': <UnitOfTime.HOURS: 'h'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[number.test_air_conditioner_schedule_turn_off-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'Test air conditioner Schedule turn-off',
|
||||
'max': 100.0,
|
||||
'min': 0.0,
|
||||
'mode': <NumberMode.BOX: 'box'>,
|
||||
'step': 1.0,
|
||||
'unit_of_measurement': <UnitOfTime.HOURS: 'h'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.test_air_conditioner_schedule_turn_off',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[number.test_air_conditioner_schedule_turn_on-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'max': 100.0,
|
||||
'min': 0.0,
|
||||
'mode': <NumberMode.BOX: 'box'>,
|
||||
'step': 1.0,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'number',
|
||||
'entity_category': None,
|
||||
'entity_id': 'number.test_air_conditioner_schedule_turn_on',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': None,
|
||||
'original_icon': None,
|
||||
'original_name': 'Schedule turn-on',
|
||||
'platform': 'lg_thinq',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': <Property.RELATIVE_HOUR_TO_START: 'relative_hour_to_start'>,
|
||||
'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_relative_hour_to_start',
|
||||
'unit_of_measurement': <UnitOfTime.HOURS: 'h'>,
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[number.test_air_conditioner_schedule_turn_on-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'friendly_name': 'Test air conditioner Schedule turn-on',
|
||||
'max': 100.0,
|
||||
'min': 0.0,
|
||||
'mode': <NumberMode.BOX: 'box'>,
|
||||
'step': 1.0,
|
||||
'unit_of_measurement': <UnitOfTime.HOURS: 'h'>,
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'number.test_air_conditioner_schedule_turn_on',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': 'unknown',
|
||||
})
|
||||
# ---
|
205
tests/components/lg_thinq/snapshots/test_sensor.ambr
Normal file
205
tests/components/lg_thinq/snapshots/test_sensor.ambr
Normal file
@ -0,0 +1,205 @@
|
||||
# serializer version: 1
|
||||
# name: test_all_entities[sensor.test_air_conditioner_humidity-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.test_air_conditioner_humidity',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.HUMIDITY: 'humidity'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'Humidity',
|
||||
'platform': 'lg_thinq',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': None,
|
||||
'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_humidity',
|
||||
'unit_of_measurement': '%',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.test_air_conditioner_humidity-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'humidity',
|
||||
'friendly_name': 'Test air conditioner Humidity',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': '%',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.test_air_conditioner_humidity',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '40',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.test_air_conditioner_pm1-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.test_air_conditioner_pm1',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.PM1: 'pm1'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'PM1',
|
||||
'platform': 'lg_thinq',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': None,
|
||||
'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_pm1',
|
||||
'unit_of_measurement': 'µg/m³',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.test_air_conditioner_pm1-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'pm1',
|
||||
'friendly_name': 'Test air conditioner PM1',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': 'µg/m³',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.test_air_conditioner_pm1',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '12',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.test_air_conditioner_pm10-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.test_air_conditioner_pm10',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.PM10: 'pm10'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'PM10',
|
||||
'platform': 'lg_thinq',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': None,
|
||||
'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_pm10',
|
||||
'unit_of_measurement': 'µg/m³',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.test_air_conditioner_pm10-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'pm10',
|
||||
'friendly_name': 'Test air conditioner PM10',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': 'µg/m³',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.test_air_conditioner_pm10',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '7',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.test_air_conditioner_pm2_5-entry]
|
||||
EntityRegistryEntrySnapshot({
|
||||
'aliases': set({
|
||||
}),
|
||||
'area_id': None,
|
||||
'capabilities': dict({
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
'device_class': None,
|
||||
'device_id': <ANY>,
|
||||
'disabled_by': None,
|
||||
'domain': 'sensor',
|
||||
'entity_category': None,
|
||||
'entity_id': 'sensor.test_air_conditioner_pm2_5',
|
||||
'has_entity_name': True,
|
||||
'hidden_by': None,
|
||||
'icon': None,
|
||||
'id': <ANY>,
|
||||
'labels': set({
|
||||
}),
|
||||
'name': None,
|
||||
'options': dict({
|
||||
}),
|
||||
'original_device_class': <SensorDeviceClass.PM25: 'pm25'>,
|
||||
'original_icon': None,
|
||||
'original_name': 'PM2.5',
|
||||
'platform': 'lg_thinq',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': 0,
|
||||
'translation_key': None,
|
||||
'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_pm2',
|
||||
'unit_of_measurement': 'µg/m³',
|
||||
})
|
||||
# ---
|
||||
# name: test_all_entities[sensor.test_air_conditioner_pm2_5-state]
|
||||
StateSnapshot({
|
||||
'attributes': ReadOnlyDict({
|
||||
'device_class': 'pm25',
|
||||
'friendly_name': 'Test air conditioner PM2.5',
|
||||
'state_class': <SensorStateClass.MEASUREMENT: 'measurement'>,
|
||||
'unit_of_measurement': 'µg/m³',
|
||||
}),
|
||||
'context': <ANY>,
|
||||
'entity_id': 'sensor.test_air_conditioner_pm2_5',
|
||||
'last_changed': <ANY>,
|
||||
'last_reported': <ANY>,
|
||||
'last_updated': <ANY>,
|
||||
'state': '24',
|
||||
})
|
||||
# ---
|
29
tests/components/lg_thinq/test_climate.py
Normal file
29
tests/components/lg_thinq/test_climate.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Tests for the LG Thinq climate platform."""
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_all_entities(
|
||||
hass: HomeAssistant,
|
||||
snapshot: SnapshotAssertion,
|
||||
mock_thinq_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test all entities."""
|
||||
with patch("homeassistant.components.lg_thinq.PLATFORMS", [Platform.CLIMATE]):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
@ -14,7 +14,10 @@ from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_config_flow(
|
||||
hass: HomeAssistant, mock_thinq_api: AsyncMock, mock_uuid: AsyncMock
|
||||
hass: HomeAssistant,
|
||||
mock_thinq_api: AsyncMock,
|
||||
mock_uuid: AsyncMock,
|
||||
mock_setup_entry: AsyncMock,
|
||||
) -> None:
|
||||
"""Test that an thinq entry is normally created."""
|
||||
result = await hass.config_entries.flow.async_init(
|
||||
|
29
tests/components/lg_thinq/test_event.py
Normal file
29
tests/components/lg_thinq/test_event.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Tests for the LG Thinq event platform."""
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_all_entities(
|
||||
hass: HomeAssistant,
|
||||
snapshot: SnapshotAssertion,
|
||||
mock_thinq_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test all entities."""
|
||||
with patch("homeassistant.components.lg_thinq.PLATFORMS", [Platform.EVENT]):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
26
tests/components/lg_thinq/test_init.py
Normal file
26
tests/components/lg_thinq/test_init.py
Normal file
@ -0,0 +1,26 @@
|
||||
"""Tests for the LG ThinQ integration."""
|
||||
|
||||
from unittest.mock import AsyncMock
|
||||
|
||||
from homeassistant.config_entries import ConfigEntryState
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
||||
from tests.common import MockConfigEntry
|
||||
|
||||
|
||||
async def test_load_unload_entry(
|
||||
hass: HomeAssistant,
|
||||
mock_thinq_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
) -> None:
|
||||
"""Test load and unload entry."""
|
||||
mock_config_entry.add_to_hass(hass)
|
||||
assert await hass.config_entries.async_setup(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.LOADED
|
||||
|
||||
await hass.config_entries.async_remove(mock_config_entry.entry_id)
|
||||
await hass.async_block_till_done()
|
||||
|
||||
assert mock_config_entry.state is ConfigEntryState.NOT_LOADED
|
29
tests/components/lg_thinq/test_number.py
Normal file
29
tests/components/lg_thinq/test_number.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Tests for the LG Thinq number platform."""
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_all_entities(
|
||||
hass: HomeAssistant,
|
||||
snapshot: SnapshotAssertion,
|
||||
mock_thinq_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test all entities."""
|
||||
with patch("homeassistant.components.lg_thinq.PLATFORMS", [Platform.NUMBER]):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
29
tests/components/lg_thinq/test_sensor.py
Normal file
29
tests/components/lg_thinq/test_sensor.py
Normal file
@ -0,0 +1,29 @@
|
||||
"""Tests for the LG Thinq sensor platform."""
|
||||
|
||||
from unittest.mock import AsyncMock, patch
|
||||
|
||||
import pytest
|
||||
from syrupy import SnapshotAssertion
|
||||
|
||||
from homeassistant.const import Platform
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from . import setup_integration
|
||||
|
||||
from tests.common import MockConfigEntry, snapshot_platform
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("entity_registry_enabled_by_default")
|
||||
async def test_all_entities(
|
||||
hass: HomeAssistant,
|
||||
snapshot: SnapshotAssertion,
|
||||
mock_thinq_api: AsyncMock,
|
||||
mock_config_entry: MockConfigEntry,
|
||||
entity_registry: er.EntityRegistry,
|
||||
) -> None:
|
||||
"""Test all entities."""
|
||||
with patch("homeassistant.components.lg_thinq.PLATFORMS", [Platform.SENSOR]):
|
||||
await setup_integration(hass, mock_config_entry)
|
||||
|
||||
await snapshot_platform(hass, entity_registry, snapshot, mock_config_entry.entry_id)
|
Loading…
x
Reference in New Issue
Block a user