Use snapshots in weather tests (#102297)
This commit is contained in:
parent
2d833fd6ea
commit
dae742fba0
4 changed files with 175 additions and 108 deletions
41
tests/components/weather/snapshots/test_init.ambr
Normal file
41
tests/components/weather/snapshots/test_init.ambr
Normal file
|
@ -0,0 +1,41 @@
|
|||
# serializer version: 1
|
||||
# name: test_get_forecast[daily-1]
|
||||
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]
|
||||
dict({
|
||||
'forecast': list([
|
||||
dict({
|
||||
'cloud_coverage': None,
|
||||
'temperature': 38.0,
|
||||
'templow': 38.0,
|
||||
'uv_index': None,
|
||||
'wind_bearing': None,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
# ---
|
||||
# name: test_get_forecast[twice_daily-4]
|
||||
dict({
|
||||
'forecast': list([
|
||||
dict({
|
||||
'cloud_coverage': None,
|
||||
'is_daytime': True,
|
||||
'temperature': 38.0,
|
||||
'templow': 38.0,
|
||||
'uv_index': None,
|
||||
'wind_bearing': None,
|
||||
}),
|
||||
]),
|
||||
})
|
||||
# ---
|
|
@ -4,6 +4,7 @@ from datetime import datetime
|
|||
from typing import Any
|
||||
|
||||
import pytest
|
||||
from syrupy.assertion import SnapshotAssertion
|
||||
|
||||
from homeassistant.components.weather import (
|
||||
ATTR_CONDITION_SUNNY,
|
||||
|
@ -854,14 +855,13 @@ async def test_forecast_twice_daily_missing_is_daytime(
|
|||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
("forecast_type", "supported_features", "extra"),
|
||||
("forecast_type", "supported_features"),
|
||||
[
|
||||
("daily", WeatherEntityFeature.FORECAST_DAILY, {}),
|
||||
("hourly", WeatherEntityFeature.FORECAST_HOURLY, {}),
|
||||
("daily", WeatherEntityFeature.FORECAST_DAILY),
|
||||
("hourly", WeatherEntityFeature.FORECAST_HOURLY),
|
||||
(
|
||||
"twice_daily",
|
||||
WeatherEntityFeature.FORECAST_TWICE_DAILY,
|
||||
{"is_daytime": True},
|
||||
),
|
||||
],
|
||||
)
|
||||
|
@ -870,7 +870,7 @@ async def test_get_forecast(
|
|||
enable_custom_integrations: None,
|
||||
forecast_type: str,
|
||||
supported_features: int,
|
||||
extra: dict[str, Any],
|
||||
snapshot: SnapshotAssertion,
|
||||
) -> None:
|
||||
"""Test get forecast service."""
|
||||
|
||||
|
@ -891,18 +891,7 @@ async def test_get_forecast(
|
|||
blocking=True,
|
||||
return_response=True,
|
||||
)
|
||||
assert response == {
|
||||
"forecast": [
|
||||
{
|
||||
"cloud_coverage": None,
|
||||
"temperature": 38.0,
|
||||
"templow": 38.0,
|
||||
"uv_index": None,
|
||||
"wind_bearing": None,
|
||||
}
|
||||
| extra
|
||||
],
|
||||
}
|
||||
assert response == snapshot
|
||||
|
||||
|
||||
async def test_get_forecast_no_forecast(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue