| 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_360_calendar(flow, scheduler, reftest): |
| 18 |
"""Test 360 day calendar.""" |
| 19 |
wid = flow({ |
| 20 |
'scheduling': { |
| 21 |
'initial cycle point': '2013-02-28', |
| 22 |
'final cycle point': '2013-03-01', |
| 23 |
'cycling mode': '360day', |
| 24 |
'graph': { |
| 25 |
'P1D': 'foo[-P1D] => foo' |
| 26 |
}, |
| 27 |
}, |
| 28 |
}) |
| 29 |
schd = scheduler(wid, paused_start=False) |
| 30 |
|
| 31 |
assert await reftest(schd) == { |
| 32 |
('20130228T0000Z/foo', ('20130227T0000Z/foo',)), |
| 33 |
('20130229T0000Z/foo', ('20130228T0000Z/foo',)), |
| 34 |
('20130230T0000Z/foo', ('20130229T0000Z/foo',)), |
| 35 |
('20130301T0000Z/foo', ('20130230T0000Z/foo',)), |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
async def test_365_calendar(flow, scheduler, reftest): |
| 40 |
"""Test 365 day calendar.""" |
| 41 |
wid = flow({ |
| 42 |
'scheduling': { |
| 43 |
'initial cycle point': '2012-02-28', |
| 44 |
'final cycle point': '2012-03-01', |
| 45 |
'cycling mode': '365day', |
| 46 |
'graph': { |
| 47 |
'P1D': 'foo[-P1D] => foo' |
| 48 |
}, |
| 49 |
}, |
| 50 |
}) |
| 51 |
schd = scheduler(wid, paused_start=False) |
| 52 |
|
| 53 |
assert await reftest(schd) == { |
| 54 |
('20120228T0000Z/foo', ('20120227T0000Z/foo',)), |
| 55 |
('20120301T0000Z/foo', ('20120228T0000Z/foo',)), |
| 56 |
} |
| 57 |
|
| 58 |
|
| 59 |
async def test_366_calendar(flow, scheduler, reftest): |
| 60 |
"""Test 366 day calendar.""" |
| 61 |
wid = flow({ |
| 62 |
'scheduling': { |
| 63 |
'initial cycle point': '2013-02-28', |
| 64 |
'final cycle point': '2013-03-01', |
| 65 |
'cycling mode': '366day', |
| 66 |
'graph': { |
| 67 |
'P1D': 'foo[-P1D] => foo' |
| 68 |
}, |
| 69 |
}, |
| 70 |
}) |
| 71 |
schd = scheduler(wid, paused_start=False) |
| 72 |
|
| 73 |
assert await reftest(schd) == { |
| 74 |
('20130228T0000Z/foo', ('20130227T0000Z/foo',)), |
| 75 |
('20130229T0000Z/foo', ('20130228T0000Z/foo',)), |
| 76 |
('20130301T0000Z/foo', ('20130229T0000Z/foo',)), |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
async def test_icp_fcp_notation(flow, scheduler, reftest): |
| 81 |
"""Test initial and final cycle point special notation (^, $)""" |
| 82 |
wid = flow({ |
| 83 |
'scheduling': { |
| 84 |
'initial cycle point': '2016-01-01', |
| 85 |
'final cycle point': '2016-01-02', |
| 86 |
'graph': { |
| 87 |
'R1': 'foo', |
| 88 |
'R1/^': 'bar', |
| 89 |
'R1/^+PT1H': 'baz', |
| 90 |
'R1/$-PT1H': 'boo', |
| 91 |
'R1/$': 'foo[^] & bar[^] & baz[^+PT1H] & boo[^+PT23H] => bot' |
| 92 |
}, |
| 93 |
}, |
| 94 |
}) |
| 95 |
schd = scheduler(wid, paused_start=False) |
| 96 |
|
| 97 |
assert await reftest(schd) == { |
| 98 |
('20160101T0000Z/foo', None), |
| 99 |
('20160101T0000Z/bar', None), |
| 100 |
('20160101T0100Z/baz', None), |
| 101 |
('20160101T2300Z/boo', None), |
| 102 |
( |
| 103 |
'20160102T0000Z/bot', |
| 104 |
( |
| 105 |
'20160101T0000Z/bar', |
| 106 |
'20160101T0000Z/foo', |
| 107 |
'20160101T0100Z/baz', |
| 108 |
'20160101T2300Z/boo', |
| 109 |
), |
| 110 |
), |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
async def test_recurrence_format_1(flow, scheduler, reftest): |
| 115 |
"""Test ISO 8601 recurrence format no. 1 with unbounded repetitions.""" |
| 116 |
wid = flow({ |
| 117 |
'scheduler': { |
| 118 |
'cycle point format': 'CCYY-MM-DD', |
| 119 |
}, |
| 120 |
'scheduling': { |
| 121 |
'initial cycle point': '2010-01-01', |
| 122 |
'final cycle point': '2010-01-10', |
| 123 |
'graph': { |
| 124 |
'R/2010-01-01/2010-01-04': 'worf', # 3-day interval |
| 125 |
}, |
| 126 |
}, |
| 127 |
}) |
| 128 |
schd = scheduler(wid, paused_start=False) |
| 129 |
|
| 130 |
assert await reftest(schd) == { |
| 131 |
('2010-01-01/worf', None), |
| 132 |
('2010-01-04/worf', None), |
| 133 |
('2010-01-07/worf', None), |
| 134 |
('2010-01-10/worf', None), |
| 135 |
} |