Skip to content

Commit 6cec298

Browse files
authored
Tests.move deprecations tests to integration battery (#5901)
tests/f: migrate to integration tests * f/deprecations/04-simple-graph * f/deprecations/00-pre-cylc8.t in
1 parent 4851bce commit 6cec298

File tree

5 files changed

+84
-112
lines changed

5 files changed

+84
-112
lines changed

tests/functional/deprecations/00-pre-cylc8.t

Lines changed: 0 additions & 40 deletions
This file was deleted.

tests/functional/deprecations/00-pre-cylc8/flow.cylc

Lines changed: 0 additions & 20 deletions
This file was deleted.

tests/functional/deprecations/04-simple-graph.t

Lines changed: 0 additions & 42 deletions
This file was deleted.

tests/integration/scripts/test_validate_integration.py

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,66 @@ async def test_validate_against_source_gets_old_tvars(
9494
flow_file.read_text().replace('P1Y = foo', 'P1Y = {{FOO}}'))
9595
with pytest.raises(Jinja2Error):
9696
validate(src_dir)
97+
98+
99+
def test_validate_simple_graph(flow, validate, caplog):
100+
"""Test deprecation notice for Cylc 7 simple graph (no recurrence section)
101+
"""
102+
id_ = flow({
103+
'scheduler': {'allow implicit tasks': True},
104+
'scheduling': {'dependencies': {'graph': 'foo'}}
105+
})
106+
validate(id_)
107+
expect = (
108+
'deprecated graph items were automatically upgraded '
109+
'in "workflow definition":'
110+
'\n * (8.0.0) [scheduling][dependencies][X]graph'
111+
' -> [scheduling][graph]X - for X in:\n graph'
112+
)
113+
assert expect in caplog.messages
114+
115+
116+
def test_pre_cylc8(flow, validate, caplog):
117+
"""Test all current non-silent workflow obsoletions and deprecations.
118+
"""
119+
id_ = flow({
120+
'cylc': {
121+
'events': {
122+
'reset timer': 10,
123+
'reset inactivity timer': 15,
124+
}
125+
},
126+
"scheduling": {
127+
"initial cycle point": "20150808T00",
128+
"final cycle point": "20150808T00",
129+
"graph": {
130+
"P1D": "foo => cat & dog"
131+
},
132+
"special tasks": {
133+
"external-trigger": 'cat("meow available")'
134+
}
135+
},
136+
'runtime': {
137+
'foo, cat, dog': {
138+
'suite state polling': {'template': ''},
139+
'events': {'reset timer': 20}
140+
}
141+
}
142+
}, defaults=False)
143+
validate(id_)
144+
for warning in (
145+
(
146+
' * (7.8.0) [runtime][foo, cat, dog][suite state polling]template'
147+
' - DELETED (OBSOLETE)'),
148+
' * (7.8.1) [cylc][events]reset timer - DELETED (OBSOLETE)',
149+
' * (7.8.1) [cylc][events]reset inactivity timer - DELETED (OBSOLETE)',
150+
(
151+
' * (7.8.1) [runtime][foo, cat, dog][events]reset timer'
152+
' - DELETED (OBSOLETE)'),
153+
(
154+
' * (8.0.0) [runtime][foo, cat, dog][suite state polling]'
155+
' -> [runtime][foo, cat, dog][workflow state polling]'
156+
' - value unchanged'),
157+
' * (8.0.0) [cylc] -> [scheduler] - value unchanged'
158+
):
159+
assert warning in caplog.messages

tests/integration/utils/flow_tools.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,16 @@ def _make_flow(
5656
conf: dict,
5757
name: Optional[str] = None,
5858
id_: Optional[str] = None,
59+
defaults: Optional[bool] = True,
5960
) -> str:
60-
"""Construct a workflow on the filesystem."""
61+
"""Construct a workflow on the filesystem.
62+
63+
Args:
64+
defaults: Set up a common defaults.
65+
* [scheduling]allow implicit tasks = true
66+
67+
Set false for Cylc 7 upgrader tests.
68+
"""
6169
if id_:
6270
flow_run_dir = (cylc_run_dir / id_)
6371
else:
@@ -66,15 +74,18 @@ def _make_flow(
6674
flow_run_dir = (test_dir / name)
6775
flow_run_dir.mkdir(parents=True, exist_ok=True)
6876
id_ = str(flow_run_dir.relative_to(cylc_run_dir))
69-
# set the default simulation runtime to zero (can be overridden)
70-
(
71-
conf.setdefault('runtime', {})
72-
.setdefault('root', {})
73-
.setdefault('simulation', {})
74-
.setdefault('default run length', 'PT0S')
75-
)
76-
# allow implicit tasks by default:
77-
conf.setdefault('scheduler', {}).setdefault('allow implicit tasks', 'True')
77+
if defaults:
78+
# set the default simulation runtime to zero (can be overridden)
79+
(
80+
conf.setdefault('runtime', {})
81+
.setdefault('root', {})
82+
.setdefault('simulation', {})
83+
.setdefault('default run length', 'PT0S')
84+
)
85+
# allow implicit tasks by default:
86+
conf.setdefault('scheduler', {}).setdefault(
87+
'allow implicit tasks', 'True')
88+
7889
with open((flow_run_dir / WorkflowFiles.FLOW_FILE), 'w+') as flow_file:
7990
flow_file.write(flow_config_str(conf))
8091
return id_

0 commit comments

Comments
 (0)