|
2 | 2 |
|
3 | 3 | from decimal import Decimal
|
4 | 4 |
|
| 5 | +from freezegun import freeze_time |
5 | 6 | from homeassistant.components.weather import (
|
6 | 7 | ATTR_CONDITION_CLEAR_NIGHT,
|
7 | 8 | ATTR_CONDITION_CLOUDY,
|
@@ -283,3 +284,29 @@ async def test_real_snow(hass: HomeAssistant, mocked_data):
|
283 | 284 |
|
284 | 285 | assert await config_entry.async_unload(hass)
|
285 | 286 | await hass.async_block_till_done()
|
| 287 | + |
| 288 | + |
| 289 | +@freeze_time("2023-02-05T15:30:00+00:00") |
| 290 | +@pytest.mark.fixture("clear_night_fix.json") |
| 291 | +async def test_sunny_during_day(hass: HomeAssistant, mocked_data): |
| 292 | + """When the API returns sunny when the sun isn't set, the weather state should be sunny""" |
| 293 | + config_entry = await setup_component(hass) |
| 294 | + |
| 295 | + state = hass.states.get("weather.knmi_home") |
| 296 | + assert state.state == ATTR_CONDITION_SUNNY |
| 297 | + |
| 298 | + assert await config_entry.async_unload(hass) |
| 299 | + await hass.async_block_till_done() |
| 300 | + |
| 301 | + |
| 302 | +@freeze_time("2023-02-05T03:30:00+01:00") |
| 303 | +@pytest.mark.fixture("clear_night_fix.json") |
| 304 | +async def test_clear_night_during_night(hass: HomeAssistant, mocked_data): |
| 305 | + """When the API returns sunny when the sun is set, the weather state should be clear night""" |
| 306 | + config_entry = await setup_component(hass) |
| 307 | + |
| 308 | + state = hass.states.get("weather.knmi_home") |
| 309 | + assert state.state == ATTR_CONDITION_CLEAR_NIGHT |
| 310 | + |
| 311 | + assert await config_entry.async_unload(hass) |
| 312 | + await hass.async_block_till_done() |
0 commit comments