From fb133664e4b3e0bfd32e3b231e084a8c30a81288 Mon Sep 17 00:00:00 2001 From: tronikos Date: Thu, 26 Jun 2025 01:50:47 -0700 Subject: [PATCH] Include subentries in Google Generative AI diagnostics (#147558) --- .../diagnostics.py | 1 + .../conftest.py | 2 + .../snapshots/test_diagnostics.ambr | 40 ++++++++++++++----- .../test_diagnostics.py | 6 +-- 4 files changed, 35 insertions(+), 14 deletions(-) diff --git a/homeassistant/components/google_generative_ai_conversation/diagnostics.py b/homeassistant/components/google_generative_ai_conversation/diagnostics.py index 13643da7e00..34b9f762355 100644 --- a/homeassistant/components/google_generative_ai_conversation/diagnostics.py +++ b/homeassistant/components/google_generative_ai_conversation/diagnostics.py @@ -21,6 +21,7 @@ async def async_get_config_entry_diagnostics( "title": entry.title, "data": entry.data, "options": entry.options, + "subentries": dict(entry.subentries), }, TO_REDACT, ) diff --git a/tests/components/google_generative_ai_conversation/conftest.py b/tests/components/google_generative_ai_conversation/conftest.py index afea41bbb26..331afc723ae 100644 --- a/tests/components/google_generative_ai_conversation/conftest.py +++ b/tests/components/google_generative_ai_conversation/conftest.py @@ -34,12 +34,14 @@ def mock_config_entry(hass: HomeAssistant) -> MockConfigEntry: "data": {}, "subentry_type": "conversation", "title": DEFAULT_CONVERSATION_NAME, + "subentry_id": "ulid-conversation", "unique_id": None, }, { "data": {}, "subentry_type": "tts", "title": DEFAULT_TTS_NAME, + "subentry_id": "ulid-tts", "unique_id": None, }, ], diff --git a/tests/components/google_generative_ai_conversation/snapshots/test_diagnostics.ambr b/tests/components/google_generative_ai_conversation/snapshots/test_diagnostics.ambr index a31827c7acc..48091d83a00 100644 --- a/tests/components/google_generative_ai_conversation/snapshots/test_diagnostics.ambr +++ b/tests/components/google_generative_ai_conversation/snapshots/test_diagnostics.ambr @@ -5,17 +5,35 @@ 'api_key': '**REDACTED**', }), 'options': dict({ - 'chat_model': 'models/gemini-2.5-flash', - 'dangerous_block_threshold': 'BLOCK_MEDIUM_AND_ABOVE', - 'harassment_block_threshold': 'BLOCK_MEDIUM_AND_ABOVE', - 'hate_block_threshold': 'BLOCK_MEDIUM_AND_ABOVE', - 'max_tokens': 1500, - 'prompt': 'Speak like a pirate', - 'recommended': False, - 'sexual_block_threshold': 'BLOCK_MEDIUM_AND_ABOVE', - 'temperature': 1.0, - 'top_k': 64, - 'top_p': 0.95, + }), + 'subentries': dict({ + 'ulid-conversation': dict({ + 'data': dict({ + 'chat_model': 'models/gemini-2.5-flash', + 'dangerous_block_threshold': 'BLOCK_MEDIUM_AND_ABOVE', + 'harassment_block_threshold': 'BLOCK_MEDIUM_AND_ABOVE', + 'hate_block_threshold': 'BLOCK_MEDIUM_AND_ABOVE', + 'max_tokens': 1500, + 'prompt': 'Speak like a pirate', + 'recommended': False, + 'sexual_block_threshold': 'BLOCK_MEDIUM_AND_ABOVE', + 'temperature': 1.0, + 'top_k': 64, + 'top_p': 0.95, + }), + 'subentry_id': 'ulid-conversation', + 'subentry_type': 'conversation', + 'title': 'Google AI Conversation', + 'unique_id': None, + }), + 'ulid-tts': dict({ + 'data': dict({ + }), + 'subentry_id': 'ulid-tts', + 'subentry_type': 'tts', + 'title': 'Google AI TTS', + 'unique_id': None, + }), }), 'title': 'Google Generative AI Conversation', }) diff --git a/tests/components/google_generative_ai_conversation/test_diagnostics.py b/tests/components/google_generative_ai_conversation/test_diagnostics.py index ebc1b5e52a5..0f193238669 100644 --- a/tests/components/google_generative_ai_conversation/test_diagnostics.py +++ b/tests/components/google_generative_ai_conversation/test_diagnostics.py @@ -35,10 +35,10 @@ async def test_diagnostics( snapshot: SnapshotAssertion, ) -> None: """Test diagnostics.""" - mock_config_entry.add_to_hass(hass) - hass.config_entries.async_update_entry( + hass.config_entries.async_update_subentry( mock_config_entry, - options={ + next(iter(mock_config_entry.subentries.values())), + data={ CONF_RECOMMENDED: False, CONF_PROMPT: "Speak like a pirate", CONF_TEMPERATURE: RECOMMENDED_TEMPERATURE,