From 8e3b58dc28af49baea8adaf11937f0a76e3ffd92 Mon Sep 17 00:00:00 2001 From: G Johansson Date: Wed, 19 Jun 2024 19:55:20 +0200 Subject: [PATCH] Clean weather tests (#119916) --- .../weather/snapshots/test_init.ambr | 46 ++----------------- tests/components/weather/test_init.py | 39 ++++------------ 2 files changed, 11 insertions(+), 74 deletions(-) diff --git a/tests/components/weather/snapshots/test_init.ambr b/tests/components/weather/snapshots/test_init.ambr index 1aa78f6bf35..dbb18d5485a 100644 --- a/tests/components/weather/snapshots/test_init.ambr +++ b/tests/components/weather/snapshots/test_init.ambr @@ -1,18 +1,5 @@ # serializer version: 1 -# name: test_get_forecast[daily-1-get_forecast] - dict({ - 'forecast': list([ - dict({ - 'cloud_coverage': None, - 'temperature': 38.0, - 'templow': 38.0, - 'uv_index': None, - 'wind_bearing': None, - }), - ]), - }) -# --- -# name: test_get_forecast[daily-1-get_forecasts] +# name: test_get_forecast[daily-1] dict({ 'weather.testing': dict({ 'forecast': list([ @@ -27,20 +14,7 @@ }), }) # --- -# name: test_get_forecast[hourly-2-get_forecast] - dict({ - 'forecast': list([ - dict({ - 'cloud_coverage': None, - 'temperature': 38.0, - 'templow': 38.0, - 'uv_index': None, - 'wind_bearing': None, - }), - ]), - }) -# --- -# name: test_get_forecast[hourly-2-get_forecasts] +# name: test_get_forecast[hourly-2] dict({ 'weather.testing': dict({ 'forecast': list([ @@ -55,21 +29,7 @@ }), }) # --- -# name: test_get_forecast[twice_daily-4-get_forecast] - dict({ - 'forecast': list([ - dict({ - 'cloud_coverage': None, - 'is_daytime': True, - 'temperature': 38.0, - 'templow': 38.0, - 'uv_index': None, - 'wind_bearing': None, - }), - ]), - }) -# --- -# name: test_get_forecast[twice_daily-4-get_forecasts] +# name: test_get_forecast[twice_daily-4] dict({ 'weather.testing': dict({ 'forecast': list([ diff --git a/tests/components/weather/test_init.py b/tests/components/weather/test_init.py index 78f454b4f95..8ea8895a2a3 100644 --- a/tests/components/weather/test_init.py +++ b/tests/components/weather/test_init.py @@ -602,12 +602,6 @@ async def test_forecast_twice_daily_missing_is_daytime( assert msg["type"] == "result" -@pytest.mark.parametrize( - ("service"), - [ - SERVICE_GET_FORECASTS, - ], -) @pytest.mark.parametrize( ("forecast_type", "supported_features"), [ @@ -625,7 +619,6 @@ async def test_get_forecast( forecast_type: str, supported_features: int, snapshot: SnapshotAssertion, - service: str, ) -> None: """Test get forecast service.""" @@ -656,7 +649,7 @@ async def test_get_forecast( response = await hass.services.async_call( DOMAIN, - service, + SERVICE_GET_FORECASTS, { "entity_id": entity0.entity_id, "type": forecast_type, @@ -667,24 +660,9 @@ async def test_get_forecast( assert response == snapshot -@pytest.mark.parametrize( - ("service", "expected"), - [ - ( - SERVICE_GET_FORECASTS, - { - "weather.testing": { - "forecast": [], - } - }, - ), - ], -) async def test_get_forecast_no_forecast( hass: HomeAssistant, config_flow_fixture: None, - service: str, - expected: dict[str, list | dict[str, list]], ) -> None: """Test get forecast service.""" @@ -705,7 +683,7 @@ async def test_get_forecast_no_forecast( response = await hass.services.async_call( DOMAIN, - service, + SERVICE_GET_FORECASTS, { "entity_id": entity0.entity_id, "type": "daily", @@ -713,13 +691,13 @@ async def test_get_forecast_no_forecast( blocking=True, return_response=True, ) - assert response == expected + assert response == { + "weather.testing": { + "forecast": [], + } + } -@pytest.mark.parametrize( - ("service"), - [SERVICE_GET_FORECASTS], -) @pytest.mark.parametrize( ("supported_features", "forecast_types"), [ @@ -733,7 +711,6 @@ async def test_get_forecast_unsupported( config_flow_fixture: None, forecast_types: list[str], supported_features: int, - service: str, ) -> None: """Test get forecast service.""" @@ -763,7 +740,7 @@ async def test_get_forecast_unsupported( with pytest.raises(HomeAssistantError): await hass.services.async_call( DOMAIN, - service, + SERVICE_GET_FORECASTS, { "entity_id": weather_entity.entity_id, "type": forecast_type,