Debian Codegraph @

tests/integration/reftests/test_pre_initial.py

raw
1 # THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE.
2 # Copyright (C) NIWA & British Crown (Met Office) & Contributors.
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 async def test_basic(flow, scheduler, reftest):
18 """Test simplification of basic conditionals in pre-initial cycling"""
19 wid = flow({
20 'scheduling': {
21 'initial cycle point': '2010-01-01',
22 'final cycle point': '2010-01-02',
23 'graph': {
24 'T00': 'a[-P1D] & b => a',
25 },
26 },
27 })
28 schd = scheduler(wid, paused_start=False)
29
30 assert await reftest(schd) == {
31 ('20100101T0000Z/b', None),
32 ('20100102T0000Z/b', None),
33 ('20100101T0000Z/a', ('20091231T0000Z/a', '20100101T0000Z/b')),
34 ('20100102T0000Z/a', ('20100101T0000Z/a', '20100102T0000Z/b')),
35 }
36
37
38 async def test_advanced(flow, scheduler, reftest):
39 """Test nested conditional simplification for pre-initial cycling."""
40 wid = flow({
41 'scheduling': {
42 'initial cycle point': '2010-01-01',
43 'final cycle point': '2010-01-02',
44 'graph': {
45 'PT6H': '(a[-PT6H] & b) & c[-PT6H] => a & c',
46 },
47 },
48 })
49 schd = scheduler(wid, paused_start=False)
50
51 assert await reftest(schd) == {
52 ('20100101T0000Z/b', None),
53 ('20100101T0600Z/b', None),
54 (
55 '20100101T0000Z/a',
56 ('20091231T1800Z/a', '20091231T1800Z/c', '20100101T0000Z/b'),
57 ),
58 (
59 '20100101T0000Z/c',
60 ('20091231T1800Z/a', '20091231T1800Z/c', '20100101T0000Z/b'),
61 ),
62 ('20100101T1200Z/b', None),
63 (
64 '20100101T0600Z/a',
65 ('20100101T0000Z/a', '20100101T0000Z/c', '20100101T0600Z/b'),
66 ),
67 (
68 '20100101T0600Z/c',
69 ('20100101T0000Z/a', '20100101T0000Z/c', '20100101T0600Z/b'),
70 ),
71 ('20100101T1800Z/b', None),
72 (
73 '20100101T1200Z/a',
74 ('20100101T0600Z/a', '20100101T0600Z/c', '20100101T1200Z/b'),
75 ),
76 (
77 '20100101T1200Z/c',
78 ('20100101T0600Z/a', '20100101T0600Z/c', '20100101T1200Z/b'),
79 ),
80 ('20100102T0000Z/b', None),
81 (
82 '20100101T1800Z/c',
83 ('20100101T1200Z/a', '20100101T1200Z/c', '20100101T1800Z/b'),
84 ),
85 (
86 '20100101T1800Z/a',
87 ('20100101T1200Z/a', '20100101T1200Z/c', '20100101T1800Z/b'),
88 ),
89 (
90 '20100102T0000Z/a',
91 ('20100101T1800Z/a', '20100101T1800Z/c', '20100102T0000Z/b'),
92 ),
93 (
94 '20100102T0000Z/c',
95 ('20100101T1800Z/a', '20100101T1800Z/c', '20100102T0000Z/b'),
96 ),
97 }
98
99
100 async def test_drop(flow, scheduler, reftest):
101 """Test the case of dropping a conditional based on pre-initial cycling"""
102 wid = flow({
103 'scheduling': {
104 'initial cycle point': '2010-01-01',
105 'final cycle point': '2010-01-02',
106 'graph': {
107 'PT6H': 'a[-PT6H] & b[-PT6H] => a => b',
108 },
109 },
110 })
111 schd = scheduler(wid, paused_start=False)
112
113 assert await reftest(schd) == {
114 ('20100101T0000Z/a', ('20091231T1800Z/a', '20091231T1800Z/b')),
115 ('20100101T0000Z/b', ('20100101T0000Z/a',)),
116 ('20100101T0600Z/a', ('20100101T0000Z/a', '20100101T0000Z/b')),
117 ('20100101T0600Z/b', ('20100101T0600Z/a',)),
118 ('20100101T1200Z/a', ('20100101T0600Z/a', '20100101T0600Z/b')),
119 ('20100101T1200Z/b', ('20100101T1200Z/a',)),
120 ('20100101T1800Z/a', ('20100101T1200Z/a', '20100101T1200Z/b')),
121 ('20100101T1800Z/b', ('20100101T1800Z/a',)),
122 ('20100102T0000Z/a', ('20100101T1800Z/a', '20100101T1800Z/b')),
123 ('20100102T0000Z/b', ('20100102T0000Z/a',)),
124 }
125
126
127 async def test_over_bracketed(flow, scheduler, reftest, validate):
128 """Test nested conditional simplification for pre-initial cycling."""
129 wid = flow({
130 'scheduling': {
131 'initial cycle point': '2013-12-25T12:00Z',
132 'final cycle point': '2013-12-25T12:00Z',
133 'graph': {
134 'T12': '''
135 (a[-P1D]:fail? | b[-P1D]:fail? | c[-P1D]:fail?) => d
136 a? & b? & c? # Implied by implicit cycling now...
137 ''',
138 },
139 },
140 })
141 validate(wid)
142 schd = scheduler(wid, paused_start=False)
143
144 assert await reftest(schd) == {
145 ('20131225T1200Z/c', None),
146 (
147 '20131225T1200Z/d',
148 ('20131224T1200Z/a', '20131224T1200Z/b', '20131224T1200Z/c'),
149 ),
150 ('20131225T1200Z/a', None),
151 ('20131225T1200Z/b', None),
152 }