From 1fbf93fd36d0b18858725027983730dd856f59b6 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Wed, 29 May 2024 14:11:58 +0200 Subject: [PATCH] Add SnapshotAssertion type hints in tests (#118371) --- tests/components/blueprint/test_importer.py | 14 +++++++++++--- tests/components/conversation/test_init.py | 7 ++++++- tests/components/wyoming/test_stt.py | 3 ++- tests/components/wyoming/test_tts.py | 11 ++++++++--- 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/tests/components/blueprint/test_importer.py b/tests/components/blueprint/test_importer.py index 275ee08863e..2b1d697fce5 100644 --- a/tests/components/blueprint/test_importer.py +++ b/tests/components/blueprint/test_importer.py @@ -4,6 +4,7 @@ import json from pathlib import Path import pytest +from syrupy import SnapshotAssertion from homeassistant.components.blueprint import importer from homeassistant.core import HomeAssistant @@ -53,7 +54,9 @@ def test_get_github_import_url() -> None: ) -def test_extract_blueprint_from_community_topic(community_post, snapshot) -> None: +def test_extract_blueprint_from_community_topic( + community_post, snapshot: SnapshotAssertion +) -> None: """Test extracting blueprint.""" imported_blueprint = importer._extract_blueprint_from_community_topic( "http://example.com", json.loads(community_post) @@ -94,7 +97,10 @@ def test_extract_blueprint_from_community_topic_wrong_lang() -> None: async def test_fetch_blueprint_from_community_url( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, community_post, snapshot + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + community_post, + snapshot: SnapshotAssertion, ) -> None: """Test fetching blueprint from url.""" aioclient_mock.get( @@ -148,7 +154,9 @@ async def test_fetch_blueprint_from_github_url( async def test_fetch_blueprint_from_github_gist_url( - hass: HomeAssistant, aioclient_mock: AiohttpClientMocker, snapshot + hass: HomeAssistant, + aioclient_mock: AiohttpClientMocker, + snapshot: SnapshotAssertion, ) -> None: """Test fetching blueprint from url.""" aioclient_mock.get( diff --git a/tests/components/conversation/test_init.py b/tests/components/conversation/test_init.py index 64832761364..e1e6683f142 100644 --- a/tests/components/conversation/test_init.py +++ b/tests/components/conversation/test_init.py @@ -502,7 +502,12 @@ async def test_http_processing_intent_conversion_not_expose_new( @pytest.mark.parametrize("sentence", ["turn on kitchen", "turn kitchen on"]) @pytest.mark.parametrize("conversation_id", ["my_new_conversation", None]) async def test_turn_on_intent( - hass: HomeAssistant, init_components, conversation_id, sentence, agent_id, snapshot + hass: HomeAssistant, + init_components, + conversation_id, + sentence, + agent_id, + snapshot: SnapshotAssertion, ) -> None: """Test calling the turn on intent.""" hass.states.async_set("light.kitchen", "off") diff --git a/tests/components/wyoming/test_stt.py b/tests/components/wyoming/test_stt.py index 900ee8d544c..bd83c31c561 100644 --- a/tests/components/wyoming/test_stt.py +++ b/tests/components/wyoming/test_stt.py @@ -4,6 +4,7 @@ from __future__ import annotations from unittest.mock import patch +from syrupy import SnapshotAssertion from wyoming.asr import Transcript from homeassistant.components import stt @@ -29,7 +30,7 @@ async def test_support(hass: HomeAssistant, init_wyoming_stt) -> None: async def test_streaming_audio( - hass: HomeAssistant, init_wyoming_stt, metadata, snapshot + hass: HomeAssistant, init_wyoming_stt, metadata, snapshot: SnapshotAssertion ) -> None: """Test streaming audio.""" entity = stt.async_get_speech_to_text_entity(hass, "stt.test_asr") diff --git a/tests/components/wyoming/test_tts.py b/tests/components/wyoming/test_tts.py index 4063418e566..263804787b1 100644 --- a/tests/components/wyoming/test_tts.py +++ b/tests/components/wyoming/test_tts.py @@ -7,6 +7,7 @@ from unittest.mock import patch import wave import pytest +from syrupy import SnapshotAssertion from wyoming.audio import AudioChunk, AudioStop from homeassistant.components import tts, wyoming @@ -38,7 +39,9 @@ async def test_support(hass: HomeAssistant, init_wyoming_tts) -> None: assert not entity.async_get_supported_voices("de-DE") -async def test_get_tts_audio(hass: HomeAssistant, init_wyoming_tts, snapshot) -> None: +async def test_get_tts_audio( + hass: HomeAssistant, init_wyoming_tts, snapshot: SnapshotAssertion +) -> None: """Test get audio.""" audio = bytes(100) audio_events = [ @@ -79,7 +82,7 @@ async def test_get_tts_audio(hass: HomeAssistant, init_wyoming_tts, snapshot) -> async def test_get_tts_audio_different_formats( - hass: HomeAssistant, init_wyoming_tts, snapshot + hass: HomeAssistant, init_wyoming_tts, snapshot: SnapshotAssertion ) -> None: """Test changing preferred audio format.""" audio = bytes(16000 * 2 * 1) # one second @@ -190,7 +193,9 @@ async def test_get_tts_audio_audio_oserror( ) -async def test_voice_speaker(hass: HomeAssistant, init_wyoming_tts, snapshot) -> None: +async def test_voice_speaker( + hass: HomeAssistant, init_wyoming_tts, snapshot: SnapshotAssertion +) -> None: """Test using a different voice and speaker.""" audio = bytes(100) audio_events = [