Add snapshot tests for tuya dj category (#148897)

This commit is contained in:
epenet 2025-07-16 18:34:28 +02:00 committed by GitHub
parent a5f0f6c8b9
commit fca05f6bcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 536 additions and 0 deletions

View File

@ -74,6 +74,10 @@ DEVICE_MOCKS = {
Platform.SENSOR, Platform.SENSOR,
Platform.SWITCH, Platform.SWITCH,
], ],
"dj_smart_light_bulb": [
# https://github.com/home-assistant/core/pull/126242
Platform.LIGHT
],
"dlq_earu_electric_eawcpt": [ "dlq_earu_electric_eawcpt": [
# https://github.com/home-assistant/core/issues/102769 # https://github.com/home-assistant/core/issues/102769
Platform.SENSOR, Platform.SENSOR,

View File

@ -180,4 +180,7 @@ async def mock_device(hass: HomeAssistant, mock_device_code: str) -> CustomerDev
for key, value in details["status_range"].items() for key, value in details["status_range"].items()
} }
device.status = details["status"] device.status = details["status"]
for key, value in device.status.items():
if device.status_range[key].type == "Json":
device.status[key] = json_dumps(value)
return device return device

View File

@ -0,0 +1,458 @@
{
"endpoint": "https://apigw.tuyaus.com",
"terminal_id": "REDACTED",
"mqtt_connected": true,
"disabled_by": null,
"disabled_polling": false,
"id": "REDACTED",
"name": "Garage light",
"category": "dj",
"product_id": "mki13ie507rlry4r",
"product_name": "Smart Light Bulb",
"online": true,
"sub": false,
"time_zone": "-07:00",
"active_time": "2024-06-15T19:53:11+00:00",
"create_time": "2024-06-15T19:53:11+00:00",
"update_time": "2024-06-15T19:53:11+00:00",
"function": {
"switch_led": {
"type": "Boolean",
"value": {}
},
"work_mode": {
"type": "Enum",
"value": {
"range": ["white", "colour", "scene", "music"]
}
},
"bright_value_v2": {
"type": "Integer",
"value": {
"min": 10,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
}
},
"colour_data_v2": {
"type": "Json",
"value": {
"h": {
"min": 0,
"scale": 0,
"unit": "",
"max": 360,
"step": 1
},
"s": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"v": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
}
}
},
"scene_data_v2": {
"type": "Json",
"value": {
"scene_num": {
"min": 1,
"scale": 0,
"max": 8,
"step": 1
},
"scene_units": {
"unit_change_mode": {
"range": ["static", "jump", "gradient"]
},
"unit_switch_duration": {
"min": 0,
"scale": 0,
"max": 100,
"step": 1
},
"unit_gradient_duration": {
"min": 0,
"scale": 0,
"max": 100,
"step": 1
},
"bright": {
"min": 0,
"scale": 0,
"max": 1000,
"step": 1
},
"temperature": {
"min": 0,
"scale": 0,
"max": 1000,
"step": 1
},
"h": {
"min": 0,
"scale": 0,
"unit": "",
"max": 360,
"step": 1
},
"s": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"v": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
}
}
}
},
"countdown_1": {
"type": "Integer",
"value": {
"unit": "",
"min": 0,
"max": 86400,
"scale": 0,
"step": 1
}
},
"music_data": {
"type": "Json",
"value": {
"change_mode": {
"range": ["direct", "gradient"]
},
"bright": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"temperature": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"h": {
"min": 0,
"scale": 0,
"unit": "",
"max": 360,
"step": 1
},
"s": {
"min": 0,
"scale": 0,
"unit": "",
"max": 255,
"step": 1
},
"v": {
"min": 0,
"scale": 0,
"unit": "",
"max": 255,
"step": 1
}
}
},
"control_data": {
"type": "Json",
"value": {
"change_mode": {
"range": ["direct", "gradient"]
},
"bright": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"temperature": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"h": {
"min": 0,
"scale": 0,
"unit": "",
"max": 360,
"step": 1
},
"s": {
"min": 0,
"scale": 0,
"unit": "",
"max": 255,
"step": 1
},
"v": {
"min": 0,
"scale": 0,
"unit": "",
"max": 255,
"step": 1
}
}
}
},
"status_range": {
"switch_led": {
"type": "Boolean",
"value": {}
},
"work_mode": {
"type": "Enum",
"value": {
"range": ["white", "colour", "scene", "music"]
}
},
"bright_value_v2": {
"type": "Integer",
"value": {
"min": 10,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
}
},
"colour_data_v2": {
"type": "Json",
"value": {
"h": {
"min": 0,
"scale": 0,
"unit": "",
"max": 360,
"step": 1
},
"s": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"v": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
}
}
},
"scene_data_v2": {
"type": "Json",
"value": {
"scene_num": {
"min": 1,
"scale": 0,
"max": 8,
"step": 1
},
"scene_units": {
"unit_change_mode": {
"range": ["static", "jump", "gradient"]
},
"unit_switch_duration": {
"min": 0,
"scale": 0,
"max": 100,
"step": 1
},
"unit_gradient_duration": {
"min": 0,
"scale": 0,
"max": 100,
"step": 1
},
"bright": {
"min": 0,
"scale": 0,
"max": 1000,
"step": 1
},
"temperature": {
"min": 0,
"scale": 0,
"max": 1000,
"step": 1
},
"h": {
"min": 0,
"scale": 0,
"unit": "",
"max": 360,
"step": 1
},
"s": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"v": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
}
}
}
},
"countdown_1": {
"type": "Integer",
"value": {
"unit": "",
"min": 0,
"max": 86400,
"scale": 0,
"step": 1
}
},
"music_data": {
"type": "Json",
"value": {
"change_mode": {
"range": ["direct", "gradient"]
},
"bright": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"temperature": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"h": {
"min": 0,
"scale": 0,
"unit": "",
"max": 360,
"step": 1
},
"s": {
"min": 0,
"scale": 0,
"unit": "",
"max": 255,
"step": 1
},
"v": {
"min": 0,
"scale": 0,
"unit": "",
"max": 255,
"step": 1
}
}
},
"control_data": {
"type": "Json",
"value": {
"change_mode": {
"range": ["direct", "gradient"]
},
"bright": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"temperature": {
"min": 0,
"scale": 0,
"unit": "",
"max": 1000,
"step": 1
},
"h": {
"min": 0,
"scale": 0,
"unit": "",
"max": 360,
"step": 1
},
"s": {
"min": 0,
"scale": 0,
"unit": "",
"max": 255,
"step": 1
},
"v": {
"min": 0,
"scale": 0,
"unit": "",
"max": 255,
"step": 1
}
}
}
},
"status": {
"switch_led": true,
"work_mode": "white",
"bright_value_v2": 546,
"colour_data_v2": {
"h": 243,
"s": 860,
"v": 541
},
"scene_data_v2": {
"scene_num": 1,
"scene_units": [
{
"bright": 200,
"h": 0,
"s": 0,
"temperature": 1000,
"unit_change_mode": "static",
"unit_gradient_duration": 13,
"unit_switch_duration": 14,
"v": 0
}
]
},
"countdown_1": 0,
"music_data": "",
"control_data": ""
},
"set_up": true,
"support_local": true
}

View File

@ -56,6 +56,77 @@
'state': 'on', 'state': 'on',
}) })
# --- # ---
# name: test_platform_setup_and_discovery[dj_smart_light_bulb][light.garage_light-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'supported_color_modes': list([
<ColorMode.HS: 'hs'>,
]),
}),
'config_entry_id': <ANY>,
'config_subentry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'light',
'entity_category': None,
'entity_id': 'light.garage_light',
'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': 'tuya',
'previous_unique_id': None,
'suggested_object_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'tuya.REDACTEDswitch_led',
'unit_of_measurement': None,
})
# ---
# name: test_platform_setup_and_discovery[dj_smart_light_bulb][light.garage_light-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'brightness': 138,
'color_mode': <ColorMode.HS: 'hs'>,
'friendly_name': 'Garage light',
'hs_color': tuple(
243.0,
86.0,
),
'rgb_color': tuple(
47,
36,
255,
),
'supported_color_modes': list([
<ColorMode.HS: 'hs'>,
]),
'supported_features': <LightEntityFeature: 0>,
'xy_color': tuple(
0.148,
0.055,
),
}),
'context': <ANY>,
'entity_id': 'light.garage_light',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': 'on',
})
# ---
# name: test_platform_setup_and_discovery[gyd_night_light][light.colorful_pir_night_light-entry] # name: test_platform_setup_and_discovery[gyd_night_light][light.colorful_pir_night_light-entry]
EntityRegistryEntrySnapshot({ EntityRegistryEntrySnapshot({
'aliases': set({ 'aliases': set({