mirror of
https://github.com/home-assistant/core.git
synced 2025-07-27 07:07:28 +00:00
Clean weather tests (#119916)
This commit is contained in:
parent
8ad63a0020
commit
8e3b58dc28
@ -1,18 +1,5 @@
|
|||||||
# serializer version: 1
|
# serializer version: 1
|
||||||
# name: test_get_forecast[daily-1-get_forecast]
|
# 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[daily-1-get_forecasts]
|
|
||||||
dict({
|
dict({
|
||||||
'weather.testing': dict({
|
'weather.testing': dict({
|
||||||
'forecast': list([
|
'forecast': list([
|
||||||
@ -27,20 +14,7 @@
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_get_forecast[hourly-2-get_forecast]
|
# 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[hourly-2-get_forecasts]
|
|
||||||
dict({
|
dict({
|
||||||
'weather.testing': dict({
|
'weather.testing': dict({
|
||||||
'forecast': list([
|
'forecast': list([
|
||||||
@ -55,21 +29,7 @@
|
|||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
# ---
|
# ---
|
||||||
# name: test_get_forecast[twice_daily-4-get_forecast]
|
# 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,
|
|
||||||
}),
|
|
||||||
]),
|
|
||||||
})
|
|
||||||
# ---
|
|
||||||
# name: test_get_forecast[twice_daily-4-get_forecasts]
|
|
||||||
dict({
|
dict({
|
||||||
'weather.testing': dict({
|
'weather.testing': dict({
|
||||||
'forecast': list([
|
'forecast': list([
|
||||||
|
@ -602,12 +602,6 @@ async def test_forecast_twice_daily_missing_is_daytime(
|
|||||||
assert msg["type"] == "result"
|
assert msg["type"] == "result"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
("service"),
|
|
||||||
[
|
|
||||||
SERVICE_GET_FORECASTS,
|
|
||||||
],
|
|
||||||
)
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("forecast_type", "supported_features"),
|
("forecast_type", "supported_features"),
|
||||||
[
|
[
|
||||||
@ -625,7 +619,6 @@ async def test_get_forecast(
|
|||||||
forecast_type: str,
|
forecast_type: str,
|
||||||
supported_features: int,
|
supported_features: int,
|
||||||
snapshot: SnapshotAssertion,
|
snapshot: SnapshotAssertion,
|
||||||
service: str,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test get forecast service."""
|
"""Test get forecast service."""
|
||||||
|
|
||||||
@ -656,7 +649,7 @@ async def test_get_forecast(
|
|||||||
|
|
||||||
response = await hass.services.async_call(
|
response = await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
service,
|
SERVICE_GET_FORECASTS,
|
||||||
{
|
{
|
||||||
"entity_id": entity0.entity_id,
|
"entity_id": entity0.entity_id,
|
||||||
"type": forecast_type,
|
"type": forecast_type,
|
||||||
@ -667,24 +660,9 @@ async def test_get_forecast(
|
|||||||
assert response == snapshot
|
assert response == snapshot
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
("service", "expected"),
|
|
||||||
[
|
|
||||||
(
|
|
||||||
SERVICE_GET_FORECASTS,
|
|
||||||
{
|
|
||||||
"weather.testing": {
|
|
||||||
"forecast": [],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
async def test_get_forecast_no_forecast(
|
async def test_get_forecast_no_forecast(
|
||||||
hass: HomeAssistant,
|
hass: HomeAssistant,
|
||||||
config_flow_fixture: None,
|
config_flow_fixture: None,
|
||||||
service: str,
|
|
||||||
expected: dict[str, list | dict[str, list]],
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test get forecast service."""
|
"""Test get forecast service."""
|
||||||
|
|
||||||
@ -705,7 +683,7 @@ async def test_get_forecast_no_forecast(
|
|||||||
|
|
||||||
response = await hass.services.async_call(
|
response = await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
service,
|
SERVICE_GET_FORECASTS,
|
||||||
{
|
{
|
||||||
"entity_id": entity0.entity_id,
|
"entity_id": entity0.entity_id,
|
||||||
"type": "daily",
|
"type": "daily",
|
||||||
@ -713,13 +691,13 @@ async def test_get_forecast_no_forecast(
|
|||||||
blocking=True,
|
blocking=True,
|
||||||
return_response=True,
|
return_response=True,
|
||||||
)
|
)
|
||||||
assert response == expected
|
assert response == {
|
||||||
|
"weather.testing": {
|
||||||
|
"forecast": [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
|
||||||
("service"),
|
|
||||||
[SERVICE_GET_FORECASTS],
|
|
||||||
)
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
("supported_features", "forecast_types"),
|
("supported_features", "forecast_types"),
|
||||||
[
|
[
|
||||||
@ -733,7 +711,6 @@ async def test_get_forecast_unsupported(
|
|||||||
config_flow_fixture: None,
|
config_flow_fixture: None,
|
||||||
forecast_types: list[str],
|
forecast_types: list[str],
|
||||||
supported_features: int,
|
supported_features: int,
|
||||||
service: str,
|
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Test get forecast service."""
|
"""Test get forecast service."""
|
||||||
|
|
||||||
@ -763,7 +740,7 @@ async def test_get_forecast_unsupported(
|
|||||||
with pytest.raises(HomeAssistantError):
|
with pytest.raises(HomeAssistantError):
|
||||||
await hass.services.async_call(
|
await hass.services.async_call(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
service,
|
SERVICE_GET_FORECASTS,
|
||||||
{
|
{
|
||||||
"entity_id": weather_entity.entity_id,
|
"entity_id": weather_entity.entity_id,
|
||||||
"type": forecast_type,
|
"type": forecast_type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user