diff --git a/tests/configs/service_reload_1.yaml b/tests/configs/service_reload_1.yaml index 04e1500..9376adf 100644 --- a/tests/configs/service_reload_1.yaml +++ b/tests/configs/service_reload_1.yaml @@ -1,3 +1,4 @@ +# A config with one of everything; controllers, zones, schedules, sequences irrigation_unlimited: granularity: 10 refresh_interval: 2000 @@ -16,6 +17,14 @@ irrigation_unlimited: - { t: "2021-01-04 06:05:00", c: 1, 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: 0, s: 0 } + - name: "2-Reload sequence" + start: "2021-01-04 07:00" + end: "2021-01-04 08:00" + results: + - {t: '2021-01-04 07:05:00', c: 1, z: 0, s: 1} + - {t: '2021-01-04 07:05:00', c: 1, z: 1, s: 1} + - {t: '2021-01-04 07:15:00', c: 1, z: 1, s: 0} + - {t: '2021-01-04 07:15:00', c: 1, z: 0, s: 0} controllers: - name: "Contoller 1" zones: @@ -23,3 +32,10 @@ irrigation_unlimited: schedules: - time: "06:05" duration: "00:10" + sequences: + - name: "C1-S1" + schedules: + - time: "07:05" + zones: + - zone_id: 1 + duration: "00:10" diff --git a/tests/configs/service_reload_2.yaml b/tests/configs/service_reload_2.yaml index 3984a63..ff75cb9 100644 --- a/tests/configs/service_reload_2.yaml +++ b/tests/configs/service_reload_2.yaml @@ -1,3 +1,4 @@ +# A config with two of everything; controllers, zones, schedules, sequences irrigation_unlimited: granularity: 10 refresh_interval: 2000 @@ -10,7 +11,7 @@ irrigation_unlimited: times: - name: '1-Reload' start: '2021-01-04 06:00' - end: '2021-01-04 07:00' + end: '2021-01-04 08: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} @@ -24,6 +25,46 @@ irrigation_unlimited: - {t: '2021-01-04 06:20:00', c: 2, z: 1, s: 0} - {t: '2021-01-04 06:25:00', c: 2, z: 2, s: 0} - {t: '2021-01-04 06:25:00', c: 2, z: 0, s: 0} + - {t: '2021-01-04 07:05:00', c: 1, z: 0, s: 1} + - {t: '2021-01-04 07:05:00', c: 1, z: 1, s: 1} + - {t: '2021-01-04 07:10:00', c: 1, z: 2, s: 1} + - {t: '2021-01-04 07:10:00', c: 2, z: 0, s: 1} + - {t: '2021-01-04 07:10:00', c: 2, z: 1, s: 1} + - {t: '2021-01-04 07:15:00', c: 1, z: 1, s: 0} + - {t: '2021-01-04 07:15:00', c: 2, z: 2, s: 1} + - {t: '2021-01-04 07:20:00', c: 1, z: 2, s: 0} + - {t: '2021-01-04 07:20:00', c: 1, z: 0, s: 0} + - {t: '2021-01-04 07:20:00', c: 2, z: 1, s: 0} + - {t: '2021-01-04 07:25:00', c: 2, z: 2, s: 0} + - {t: '2021-01-04 07:25:00', c: 2, z: 0, s: 0} + - name: '2-Reload sequences' + start: '2021-01-04 08:00' + end: '2021-01-04 10:00' + results: + - {t: '2021-01-04 08:05:00', c: 1, z: 0, s: 1} + - {t: '2021-01-04 08:05:00', c: 1, z: 1, s: 1} + - {t: '2021-01-04 08:05:00', c: 2, z: 0, s: 1} + - {t: '2021-01-04 08:05:00', c: 2, z: 1, s: 1} + - {t: '2021-01-04 08:15:00', c: 1, z: 2, s: 1} + - {t: '2021-01-04 08:15:00', c: 2, z: 2, s: 1} + - {t: '2021-01-04 08:20:00', c: 1, z: 1, s: 0} + - {t: '2021-01-04 08:20:00', c: 2, z: 1, s: 0} + - {t: '2021-01-04 08:40:00', c: 1, z: 2, s: 0} + - {t: '2021-01-04 08:40:00', c: 1, z: 0, s: 0} + - {t: '2021-01-04 08:40:00', c: 2, z: 2, s: 0} + - {t: '2021-01-04 08:40:00', c: 2, z: 0, s: 0} + - {t: '2021-01-04 09:05:00', c: 1, z: 0, s: 1} + - {t: '2021-01-04 09:05:00', c: 1, z: 1, s: 1} + - {t: '2021-01-04 09:05:00', c: 2, z: 0, s: 1} + - {t: '2021-01-04 09:05:00', c: 2, z: 1, s: 1} + - {t: '2021-01-04 09:15:00', c: 1, z: 2, s: 1} + - {t: '2021-01-04 09:15:00', c: 2, z: 2, s: 1} + - {t: '2021-01-04 09:20:00', c: 1, z: 1, s: 0} + - {t: '2021-01-04 09:25:00', c: 2, z: 1, s: 0} + - {t: '2021-01-04 09:40:00', c: 1, z: 2, s: 0} + - {t: '2021-01-04 09:40:00', c: 1, z: 0, s: 0} + - {t: '2021-01-04 09:45:00', c: 2, z: 2, s: 0} + - {t: '2021-01-04 09:45:00', c: 2, z: 0, s: 0} controllers: - name: "Contoller 1" zones: @@ -31,17 +72,63 @@ irrigation_unlimited: schedules: - time: "06:05" duration: "00:10" + - time: "07:05" + duration: "00:10" - name: "C1-Z2" schedules: - time: "06:10" duration: "00:10" + - time: "07:10" + duration: "00:10" + sequences: + - name: "C1-S1" + schedules: + - time: "08:05" + - time: "09:05" + zones: + - zone_id: 1 + duration: "00:10" + - zone_id: 2 + duration: "00:15" + - name: "C1-S2" + schedules: + - time: "08:10" + - time: "09:10" + zones: + - zone_id: 1 + duration: "00:10" + - zone_id: 2 + duration: "00:20" - name: "Controller 2" zones: - name: "C2-Z1" schedules: - time: "06:10" duration: "00:10" + - time: "07:10" + duration: "00:10" - name: "C2-Z2" schedules: - time: "06:15" duration: "00:10" + - time: "07:15" + duration: "00:10" + sequences: + - name: "C2-S1" + schedules: + - time: "08:05" + - time: "09:05" + zones: + - zone_id: 1 + duration: "00:10" + - zone_id: 2 + duration: "00:15" + - name: "C2-S2" + schedules: + - time: "08:10" + - time: "09:15" + zones: + - zone_id: 1 + duration: "00:10" + - zone_id: 2 + duration: "00:20" diff --git a/tests/configs/service_reload_3.yaml b/tests/configs/service_reload_3.yaml index ab2de56..74655d8 100644 --- a/tests/configs/service_reload_3.yaml +++ b/tests/configs/service_reload_3.yaml @@ -1,3 +1,4 @@ +# A config with three of everything; controllers, zones, schedules, sequences irrigation_unlimited: granularity: 10 refresh_interval: 2000 @@ -10,7 +11,7 @@ irrigation_unlimited: times: - name: "1-Reload" start: "2021-01-04 06:00" - end: "2021-01-04 07:00" + end: "2021-01-04 09: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 } @@ -36,6 +37,130 @@ irrigation_unlimited: - { t: "2021-01-04 06:30:00", c: 3, z: 2, s: 0 } - { t: "2021-01-04 06:35:00", c: 3, z: 3, s: 0 } - { t: "2021-01-04 06:35:00", c: 3, z: 0, s: 0 } + - { t: "2021-01-04 07:05:00", c: 1, z: 0, s: 1 } + - { t: "2021-01-04 07:05:00", c: 1, z: 1, s: 1 } + - { t: "2021-01-04 07:10:00", c: 1, z: 2, s: 1 } + - { t: "2021-01-04 07:10:00", c: 2, z: 0, s: 1 } + - { t: "2021-01-04 07:10:00", c: 2, z: 1, s: 1 } + - { t: "2021-01-04 07:15:00", c: 1, z: 1, s: 0 } + - { t: "2021-01-04 07:15:00", c: 1, z: 3, s: 1 } + - { t: "2021-01-04 07:15:00", c: 2, z: 2, s: 1 } + - { t: "2021-01-04 07:15:00", c: 3, z: 0, s: 1 } + - { t: "2021-01-04 07:15:00", c: 3, z: 1, s: 1 } + - { t: "2021-01-04 07:20:00", c: 1, z: 2, s: 0 } + - { t: "2021-01-04 07:20:00", c: 2, z: 1, s: 0 } + - { t: "2021-01-04 07:20:00", c: 2, z: 3, s: 1 } + - { t: "2021-01-04 07:20:00", c: 3, z: 2, s: 1 } + - { t: "2021-01-04 07:25:00", c: 1, z: 3, s: 0 } + - { t: "2021-01-04 07:25:00", c: 1, z: 0, s: 0 } + - { t: "2021-01-04 07:25:00", c: 2, z: 2, s: 0 } + - { t: "2021-01-04 07:25:00", c: 3, z: 1, s: 0 } + - { t: "2021-01-04 07:25:00", c: 3, z: 3, s: 1 } + - { t: "2021-01-04 07:30:00", c: 2, z: 3, s: 0 } + - { t: "2021-01-04 07:30:00", c: 2, z: 0, s: 0 } + - { t: "2021-01-04 07:30:00", c: 3, z: 2, s: 0 } + - { t: "2021-01-04 07:35:00", c: 3, z: 3, s: 0 } + - { t: "2021-01-04 07:35:00", c: 3, z: 0, s: 0 } + - { t: "2021-01-04 08:05:00", c: 1, z: 0, s: 1 } + - { t: "2021-01-04 08:05:00", c: 1, z: 1, s: 1 } + - { t: "2021-01-04 08:10:00", c: 1, z: 2, s: 1 } + - { t: "2021-01-04 08:10:00", c: 2, z: 0, s: 1 } + - { t: "2021-01-04 08:10:00", c: 2, z: 1, s: 1 } + - { t: "2021-01-04 08:15:00", c: 1, z: 1, s: 0 } + - { t: "2021-01-04 08:15:00", c: 1, z: 3, s: 1 } + - { t: "2021-01-04 08:15:00", c: 2, z: 2, s: 1 } + - { t: "2021-01-04 08:15:00", c: 3, z: 0, s: 1 } + - { t: "2021-01-04 08:15:00", c: 3, z: 1, s: 1 } + - { t: "2021-01-04 08:20:00", c: 1, z: 2, s: 0 } + - { t: "2021-01-04 08:20:00", c: 2, z: 1, s: 0 } + - { t: "2021-01-04 08:20:00", c: 2, z: 3, s: 1 } + - { t: "2021-01-04 08:20:00", c: 3, z: 2, s: 1 } + - { t: "2021-01-04 08:25:00", c: 1, z: 3, s: 0 } + - { t: "2021-01-04 08:25:00", c: 1, z: 0, s: 0 } + - { t: "2021-01-04 08:25:00", c: 2, z: 2, s: 0 } + - { t: "2021-01-04 08:25:00", c: 3, z: 1, s: 0 } + - { t: "2021-01-04 08:25:00", c: 3, z: 3, s: 1 } + - { t: "2021-01-04 08:30:00", c: 2, z: 3, s: 0 } + - { t: "2021-01-04 08:30:00", c: 2, z: 0, s: 0 } + - { t: "2021-01-04 08:30:00", c: 3, z: 2, s: 0 } + - { t: "2021-01-04 08:35:00", c: 3, z: 3, s: 0 } + - { t: "2021-01-04 08:35:00", c: 3, z: 0, s: 0 } + - name: "2-Reload sequences" + start: "2021-01-04 09:00" + end: "2021-01-04 12:00" + results: + - {t: '2021-01-04 09:05:00', c: 1, z: 0, s: 1} + - {t: '2021-01-04 09:05:00', c: 1, z: 1, s: 1} + - {t: '2021-01-04 09:10:00', c: 1, z: 2, s: 1} + - {t: '2021-01-04 09:10:00', c: 2, z: 0, s: 1} + - {t: '2021-01-04 09:10:00', c: 2, z: 1, s: 1} + - {t: '2021-01-04 09:15:00', c: 2, z: 2, s: 1} + - {t: '2021-01-04 09:15:00', c: 3, z: 0, s: 1} + - {t: '2021-01-04 09:15:00', c: 3, z: 1, s: 1} + - {t: '2021-01-04 09:20:00', c: 1, z: 1, s: 0} + - {t: '2021-01-04 09:20:00', c: 1, z: 3, s: 1} + - {t: '2021-01-04 09:20:00', c: 3, z: 2, s: 1} + - {t: '2021-01-04 09:25:00', c: 2, z: 1, s: 0} + - {t: '2021-01-04 09:25:00', c: 2, z: 3, s: 1} + - {t: '2021-01-04 09:30:00', c: 1, z: 2, s: 0} + - {t: '2021-01-04 09:30:00', c: 3, z: 1, s: 0} + - {t: '2021-01-04 09:30:00', c: 3, z: 3, s: 1} + - {t: '2021-01-04 09:35:00', c: 2, z: 2, s: 0} + - {t: '2021-01-04 09:40:00', c: 3, z: 2, s: 0} + - {t: '2021-01-04 09:45:00', c: 1, z: 3, s: 0} + - {t: '2021-01-04 09:45:00', c: 1, z: 0, s: 0} + - {t: '2021-01-04 09:50:00', c: 2, z: 3, s: 0} + - {t: '2021-01-04 09:50:00', c: 2, z: 0, s: 0} + - {t: '2021-01-04 09:55:00', c: 3, z: 3, s: 0} + - {t: '2021-01-04 09:55:00', c: 3, z: 0, s: 0} + - {t: '2021-01-04 10:05:00', c: 1, z: 0, s: 1} + - {t: '2021-01-04 10:05:00', c: 1, z: 1, s: 1} + - {t: '2021-01-04 10:10:00', c: 1, z: 2, s: 1} + - {t: '2021-01-04 10:10:00', c: 2, z: 0, s: 1} + - {t: '2021-01-04 10:10:00', c: 2, z: 1, s: 1} + - {t: '2021-01-04 10:15:00', c: 2, z: 2, s: 1} + - {t: '2021-01-04 10:15:00', c: 3, z: 0, s: 1} + - {t: '2021-01-04 10:15:00', c: 3, z: 1, s: 1} + - {t: '2021-01-04 10:20:00', c: 1, z: 1, s: 0} + - {t: '2021-01-04 10:20:00', c: 1, z: 3, s: 1} + - {t: '2021-01-04 10:20:00', c: 3, z: 2, s: 1} + - {t: '2021-01-04 10:25:00', c: 2, z: 1, s: 0} + - {t: '2021-01-04 10:25:00', c: 2, z: 3, s: 1} + - {t: '2021-01-04 10:30:00', c: 1, z: 2, s: 0} + - {t: '2021-01-04 10:30:00', c: 3, z: 1, s: 0} + - {t: '2021-01-04 10:30:00', c: 3, z: 3, s: 1} + - {t: '2021-01-04 10:35:00', c: 2, z: 2, s: 0} + - {t: '2021-01-04 10:40:00', c: 3, z: 2, s: 0} + - {t: '2021-01-04 10:45:00', c: 1, z: 3, s: 0} + - {t: '2021-01-04 10:45:00', c: 1, z: 0, s: 0} + - {t: '2021-01-04 10:50:00', c: 2, z: 3, s: 0} + - {t: '2021-01-04 10:50:00', c: 2, z: 0, s: 0} + - {t: '2021-01-04 10:55:00', c: 3, z: 3, s: 0} + - {t: '2021-01-04 10:55:00', c: 3, z: 0, s: 0} + - {t: '2021-01-04 11:05:00', c: 1, z: 0, s: 1} + - {t: '2021-01-04 11:05:00', c: 1, z: 1, s: 1} + - {t: '2021-01-04 11:10:00', c: 1, z: 2, s: 1} + - {t: '2021-01-04 11:10:00', c: 2, z: 0, s: 1} + - {t: '2021-01-04 11:10:00', c: 2, z: 1, s: 1} + - {t: '2021-01-04 11:15:00', c: 2, z: 2, s: 1} + - {t: '2021-01-04 11:15:00', c: 3, z: 0, s: 1} + - {t: '2021-01-04 11:15:00', c: 3, z: 1, s: 1} + - {t: '2021-01-04 11:20:00', c: 1, z: 1, s: 0} + - {t: '2021-01-04 11:20:00', c: 1, z: 3, s: 1} + - {t: '2021-01-04 11:20:00', c: 3, z: 2, s: 1} + - {t: '2021-01-04 11:25:00', c: 2, z: 1, s: 0} + - {t: '2021-01-04 11:25:00', c: 2, z: 3, s: 1} + - {t: '2021-01-04 11:30:00', c: 1, z: 2, s: 0} + - {t: '2021-01-04 11:30:00', c: 3, z: 1, s: 0} + - {t: '2021-01-04 11:30:00', c: 3, z: 3, s: 1} + - {t: '2021-01-04 11:35:00', c: 2, z: 2, s: 0} + - {t: '2021-01-04 11:40:00', c: 3, z: 2, s: 0} + - {t: '2021-01-04 11:45:00', c: 1, z: 3, s: 0} + - {t: '2021-01-04 11:45:00', c: 1, z: 0, s: 0} + - {t: '2021-01-04 11:50:00', c: 2, z: 3, s: 0} + - {t: '2021-01-04 11:50:00', c: 2, z: 0, s: 0} + - {t: '2021-01-04 11:55:00', c: 3, z: 3, s: 0} + - {t: '2021-01-04 11:55:00', c: 3, z: 0, s: 0} controllers: - name: "Contoller 1" zones: @@ -43,39 +168,186 @@ irrigation_unlimited: schedules: - time: "06:05" duration: "00:10" + - time: "07:05" + duration: "00:10" + - time: "08:05" + duration: "00:10" - name: "C1-Z2" schedules: - time: "06:10" duration: "00:10" + - time: "07:10" + duration: "00:10" + - time: "08:10" + duration: "00:10" - name: "C1-Z3" schedules: - time: "06:15" duration: "00:10" + - time: "07:15" + duration: "00:10" + - time: "08:15" + duration: "00:10" + sequences: + - name: "C1-S1" + schedules: + - time: "09:05" + - time: "10:05" + - time: "11:05" + zones: + - zone_id: 1 + duration: "00:05" + - zone_id: 2 + duration: "00:10" + - zone_id: 3 + duration: "00:15" + - name: "C1-S2" + schedules: + - time: "09:10" + - time: "10:10" + - time: "11:10" + zones: + - zone_id: 1 + duration: "00:05" + - zone_id: 2 + duration: "00:10" + - zone_id: 3 + duration: "00:15" + - name: "C1-S3" + schedules: + - time: "09:15" + - time: "10:15" + - time: "11:15" + zones: + - zone_id: 1 + duration: "00:05" + - zone_id: 2 + duration: "00:10" + - zone_id: 3 + duration: "00:15" - name: "Controller 2" zones: - name: "C2-Z1" schedules: - time: "06:10" duration: "00:10" + - time: "07:10" + duration: "00:10" + - time: "08:10" + duration: "00:10" - name: "C2-Z2" schedules: - time: "06:15" duration: "00:10" + - time: "07:15" + duration: "00:10" + - time: "08:15" + duration: "00:10" - name: "C2-Z3" schedules: - time: "06:20" duration: "00:10" + - time: "07:20" + duration: "00:10" + - time: "08:20" + duration: "00:10" + sequences: + - name: "C2-S1" + schedules: + - time: "09:10" + - time: "10:10" + - time: "11:10" + zones: + - zone_id: 1 + duration: "00:05" + - zone_id: 2 + duration: "00:10" + - zone_id: 3 + duration: "00:15" + - name: "C2-S2" + schedules: + - time: "09:15" + - time: "10:15" + - time: "11:15" + zones: + - zone_id: 1 + duration: "00:05" + - zone_id: 2 + duration: "00:10" + - zone_id: 3 + duration: "00:15" + - name: "C2-S3" + schedules: + - time: "09:20" + - time: "10:20" + - time: "11:20" + zones: + - zone_id: 1 + duration: "00:05" + - zone_id: 2 + duration: "00:10" + - zone_id: 3 + duration: "00:15" - name: "Controller 3" zones: - name: "C3-Z1" schedules: - time: "06:15" duration: "00:10" + - time: "07:15" + duration: "00:10" + - time: "08:15" + duration: "00:10" - name: "C3-Z2" schedules: - time: "06:20" duration: "00:10" + - time: "07:20" + duration: "00:10" + - time: "08:20" + duration: "00:10" - name: "C3-Z3" schedules: - time: "06:25" duration: "00:10" + - time: "07:25" + duration: "00:10" + - time: "08:25" + duration: "00:10" + sequences: + - name: "C3-S1" + schedules: + - time: "09:15" + - time: "10:15" + - time: "11:15" + zones: + - zone_id: 1 + duration: "00:05" + - zone_id: 2 + duration: "00:10" + - zone_id: 3 + duration: "00:15" + - name: "C3-S2" + schedules: + - time: "09:20" + - time: "10:20" + - time: "11:20" + zones: + - zone_id: 1 + duration: "00:05" + - zone_id: 2 + duration: "00:10" + - zone_id: 3 + duration: "00:15" + - name: "C3-S3" + schedules: + - time: "09:25" + - time: "10:25" + - time: "11:25" + zones: + - zone_id: 1 + duration: "00:05" + - zone_id: 2 + duration: "00:10" + - zone_id: 3 + duration: "00:15" diff --git a/tests/test_reload.py b/tests/test_reload.py index fa21364..a2dbe9e 100644 --- a/tests/test_reload.py +++ b/tests/test_reload.py @@ -134,7 +134,7 @@ async def test_service_reload_while_on( await exam.reload("service_reload_1.yaml") assert exam.coordinator.controllers[0].is_on is False assert exam.coordinator.controllers[0].zones[0].is_on is False - await exam.run_test(1) + await exam.run_all() exam.check_summary() @@ -159,18 +159,15 @@ async def test_service_reload_extend_shrink( async with IUExam(hass, "mock_config.yaml") as exam: await exam.reload("service_reload_2.yaml") - await exam.begin_test(1) - await exam.finish_test() + await exam.run_all() exam.check_summary() await exam.reload("service_reload_3.yaml") - await exam.begin_test(1) - await exam.finish_test() + await exam.run_all() exam.check_summary() await exam.reload("service_reload_1.yaml") - await exam.begin_test(1) - await exam.finish_test() + await exam.run_all() exam.check_summary()