Skip to content

Commit ec7e10e

Browse files
committed
Add tests to make sure we dont regress this again
1 parent 51399e6 commit ec7e10e

2 files changed

Lines changed: 114 additions & 0 deletions

File tree

tests/snapshots/test_hub.ambr

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,98 @@
411411
}),
412412
])
413413
# ---
414+
# name: test_select_main_topic[complex_naming]
415+
list([
416+
EntityRegistryEntrySnapshot({
417+
'aliases': list([
418+
None,
419+
]),
420+
'area_id': None,
421+
'capabilities': dict({
422+
'options': list([
423+
'charger_only',
424+
'inverter_only',
425+
'on',
426+
'off',
427+
]),
428+
}),
429+
'config_entry_id': <ANY>,
430+
'config_subentry_id': <ANY>,
431+
'device_class': None,
432+
'device_id': <ANY>,
433+
'disabled_by': None,
434+
'domain': 'select',
435+
'entity_category': None,
436+
'entity_id': 'select.victron_mqtt_123_vebus_289_vebus_inverter_mode',
437+
'has_entity_name': True,
438+
'hidden_by': None,
439+
'icon': None,
440+
'id': <ANY>,
441+
'labels': set({
442+
}),
443+
'name': None,
444+
'object_id_base': None,
445+
'options': dict({
446+
}),
447+
'original_device_class': None,
448+
'original_icon': None,
449+
'original_name': None,
450+
'platform': 'victron_mqtt',
451+
'previous_unique_id': None,
452+
'suggested_object_id': 'victron_mqtt_123_vebus_289_vebus_inverter_mode',
453+
'supported_features': 0,
454+
'translation_key': 'vebus_inverter_mode',
455+
'unique_id': 'select.victron_mqtt_123_vebus_289_vebus_inverter_mode',
456+
'unit_of_measurement': None,
457+
}),
458+
])
459+
# ---
460+
# name: test_select_main_topic[simple_naming]
461+
list([
462+
EntityRegistryEntrySnapshot({
463+
'aliases': list([
464+
None,
465+
]),
466+
'area_id': None,
467+
'capabilities': dict({
468+
'options': list([
469+
'charger_only',
470+
'inverter_only',
471+
'on',
472+
'off',
473+
]),
474+
}),
475+
'config_entry_id': <ANY>,
476+
'config_subentry_id': <ANY>,
477+
'device_class': None,
478+
'device_id': <ANY>,
479+
'disabled_by': None,
480+
'domain': 'select',
481+
'entity_category': None,
482+
'entity_id': 'select.ve_bus_id_289',
483+
'has_entity_name': True,
484+
'hidden_by': None,
485+
'icon': None,
486+
'id': <ANY>,
487+
'labels': set({
488+
}),
489+
'name': None,
490+
'object_id_base': None,
491+
'options': dict({
492+
}),
493+
'original_device_class': None,
494+
'original_icon': None,
495+
'original_name': None,
496+
'platform': 'victron_mqtt',
497+
'previous_unique_id': None,
498+
'suggested_object_id': None,
499+
'supported_features': 0,
500+
'translation_key': 'vebus_inverter_mode',
501+
'unique_id': 'select.victron_mqtt_vebus_289_vebus_inverter_mode',
502+
'unit_of_measurement': None,
503+
}),
504+
])
505+
# ---
414506
# name: test_sensor[complex_naming]
415507
list([
416508
EntityRegistryEntrySnapshot({

tests/test_hub.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,28 @@ async def test_select(
373373
assert entities == snapshot
374374

375375

376+
async def test_select_main_topic(
377+
hass: HomeAssistant,
378+
snapshot: SnapshotAssertion,
379+
init_integration,
380+
) -> None:
381+
"""Test select entity with main_topic=True still gets translation_key."""
382+
victron_hub, mock_config_entry = init_integration
383+
384+
# Inject a select metric where main_topic=True (vebus inverter mode)
385+
await inject_message(victron_hub, "N/123/vebus/289/Mode", '{"value": 3}')
386+
await finalize_injection(victron_hub)
387+
388+
entity_registry = er.async_get(hass)
389+
entities = er.async_entries_for_config_entry(
390+
entity_registry, mock_config_entry.entry_id
391+
)
392+
393+
# Should have created one entity
394+
assert len(entities) == 1
395+
assert entities == snapshot
396+
397+
376398
async def test_button(
377399
hass: HomeAssistant,
378400
snapshot: SnapshotAssertion,

0 commit comments

Comments
 (0)