Clean weather tests (#119916)

This commit is contained in:
G Johansson 2024-06-19 19:55:20 +02:00 committed by GitHub
parent 8ad63a0020
commit 8e3b58dc28
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 74 deletions

View file

@ -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([

View file

@ -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,