diff --git a/tests/configs/service_reload_while_on.yaml b/tests/configs/service_reload_while_on.yaml new file mode 100644 index 0000000..671b9a2 --- /dev/null +++ b/tests/configs/service_reload_while_on.yaml @@ -0,0 +1,74 @@ +irrigation_unlimited: + granularity: 10 + refresh_interval: 2000 + testing: + enabled: true + speed: 1.0 + output_events: false + show_log: false + autoplay: false + times: + - name: "1-Reload while on" + start: "2021-01-04 06:00" + end: "2021-01-04 07:00" + results: + - { t: "2021-01-04 06:05:00", c: 1, z: 0, s: 1 } + - { t: "2021-01-04 06:05:00", c: 1, z: 1, s: 1 } + - { t: "2021-01-04 06:10:00", c: 1, z: 2, s: 1 } + - { t: "2021-01-04 06:10:00", c: 2, z: 0, s: 1 } + - { t: "2021-01-04 06:10:00", c: 2, z: 1, s: 1 } + - { t: "2021-01-04 06:15:00", c: 1, z: 1, s: 0 } + - { t: "2021-01-04 06:15:00", c: 1, z: 3, s: 1 } + - { t: "2021-01-04 06:15:00", c: 2, z: 2, s: 1 } + - { t: "2021-01-04 06:15:00", c: 3, z: 0, s: 1 } + - { t: "2021-01-04 06:15:00", c: 3, z: 1, s: 1 } + - { t: "2021-01-04 06:16:10", c: 1, z: 3, s: 0 } + - { t: "2021-01-04 06:16:10", c: 1, z: 2, s: 0 } + - { t: "2021-01-04 06:16:10", c: 3, z: 1, s: 0 } + - { t: "2021-01-04 06:16:10", c: 3, z: 0, s: 0 } + - { t: "2021-01-04 06:16:10", c: 2, z: 1, s: 0 } + - { t: "2021-01-04 06:16:10", c: 2, z: 2, s: 0 } + - { t: "2021-01-04 06:16:10", c: 2, z: 0, s: 0 } + controllers: + - name: "Contoller 1" + zones: + - name: "C1-Z1" + schedules: + - time: "06:05" + duration: "00:10" + - name: "C1-Z2" + schedules: + - time: "06:10" + duration: "00:10" + - name: "C1-Z3" + schedules: + - time: "06:15" + duration: "00:10" + - name: "Controller 2" + zones: + - name: "C2-Z1" + schedules: + - time: "06:10" + duration: "00:10" + - name: "C2-Z2" + schedules: + - time: "06:15" + duration: "00:10" + - name: "C2-Z3" + schedules: + - time: "06:20" + duration: "00:10" + - name: "Controller 3" + zones: + - name: "C3-Z1" + schedules: + - time: "06:15" + duration: "00:10" + - name: "C3-Z2" + schedules: + - time: "06:20" + duration: "00:10" + - name: "C3-Z3" + schedules: + - time: "06:25" + duration: "00:10" diff --git a/tests/test_reload.py b/tests/test_reload.py index 67ec848..8f078a7 100644 --- a/tests/test_reload.py +++ b/tests/test_reload.py @@ -2,6 +2,7 @@ from unittest.mock import patch import pytest +from datetime import datetime import homeassistant.core as ha from homeassistant.config import load_yaml_config_file from homeassistant.setup import async_setup_component @@ -143,3 +144,53 @@ async def test_service_reload_extend_shrink( start_time = await begin_test(1, coordinator) await finish_test(hass, coordinator, start_time, True) check_summary(full_path, coordinator) + + +async def test_service_reload_shrink_while_on( + hass: ha.HomeAssistant, + skip_start, + skip_dependencies, + skip_history, +): + """Test reload service call reducing entities while on.""" + + await async_setup_component(hass, DOMAIN, CONFIG_SCHEMA(MOCK_CONFIG)) + await hass.async_block_till_done() + coordinator: IUCoordinator = hass.data[DOMAIN][COORDINATOR] + + full_path = test_config_dir + "service_reload_while_on.yaml" + with patch( + "homeassistant.core.Config.path", + return_value=full_path, + ): + await hass.services.async_call( + DOMAIN, + SERVICE_RELOAD, + None, + True, + ) + # Reload while entities are on. + start_time = await begin_test(1, coordinator) + await run_until( + hass, + coordinator, + start_time, + datetime.fromisoformat("2021-01-04 06:16:00+00:00"), + True, + ) + full_path = test_config_dir + "service_reload_1.yaml" + with patch( + "homeassistant.core.Config.path", + return_value=full_path, + ): + await hass.services.async_call( + DOMAIN, + SERVICE_RELOAD, + None, + True, + ) + + # The reload mid stream has blown away our test and results. So + # don't attempt to finish or check results, there are none. + # await finish_test(hass, coordinator, start_time, True) + # check_summary(full_path, coordinator)