Skip to content

Commit

Permalink
Tests.move deprecations tests to integration battery (#5901)
Browse files Browse the repository at this point in the history
tests/f: migrate to integration tests

* f/deprecations/04-simple-graph
* f/deprecations/00-pre-cylc8.t in
  • Loading branch information
wxtim authored Jan 16, 2024
1 parent 4851bce commit 6cec298
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 112 deletions.
40 changes: 0 additions & 40 deletions tests/functional/deprecations/00-pre-cylc8.t

This file was deleted.

20 changes: 0 additions & 20 deletions tests/functional/deprecations/00-pre-cylc8/flow.cylc

This file was deleted.

42 changes: 0 additions & 42 deletions tests/functional/deprecations/04-simple-graph.t

This file was deleted.

63 changes: 63 additions & 0 deletions tests/integration/scripts/test_validate_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,66 @@ async def test_validate_against_source_gets_old_tvars(
flow_file.read_text().replace('P1Y = foo', 'P1Y = {{FOO}}'))
with pytest.raises(Jinja2Error):
validate(src_dir)


def test_validate_simple_graph(flow, validate, caplog):
"""Test deprecation notice for Cylc 7 simple graph (no recurrence section)
"""
id_ = flow({
'scheduler': {'allow implicit tasks': True},
'scheduling': {'dependencies': {'graph': 'foo'}}
})
validate(id_)
expect = (
'deprecated graph items were automatically upgraded '
'in "workflow definition":'
'\n * (8.0.0) [scheduling][dependencies][X]graph'
' -> [scheduling][graph]X - for X in:\n graph'
)
assert expect in caplog.messages


def test_pre_cylc8(flow, validate, caplog):
"""Test all current non-silent workflow obsoletions and deprecations.
"""
id_ = flow({
'cylc': {
'events': {
'reset timer': 10,
'reset inactivity timer': 15,
}
},
"scheduling": {
"initial cycle point": "20150808T00",
"final cycle point": "20150808T00",
"graph": {
"P1D": "foo => cat & dog"
},
"special tasks": {
"external-trigger": 'cat("meow available")'
}
},
'runtime': {
'foo, cat, dog': {
'suite state polling': {'template': ''},
'events': {'reset timer': 20}
}
}
}, defaults=False)
validate(id_)
for warning in (
(
' * (7.8.0) [runtime][foo, cat, dog][suite state polling]template'
' - DELETED (OBSOLETE)'),
' * (7.8.1) [cylc][events]reset timer - DELETED (OBSOLETE)',
' * (7.8.1) [cylc][events]reset inactivity timer - DELETED (OBSOLETE)',
(
' * (7.8.1) [runtime][foo, cat, dog][events]reset timer'
' - DELETED (OBSOLETE)'),
(
' * (8.0.0) [runtime][foo, cat, dog][suite state polling]'
' -> [runtime][foo, cat, dog][workflow state polling]'
' - value unchanged'),
' * (8.0.0) [cylc] -> [scheduler] - value unchanged'
):
assert warning in caplog.messages
31 changes: 21 additions & 10 deletions tests/integration/utils/flow_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,16 @@ def _make_flow(
conf: dict,
name: Optional[str] = None,
id_: Optional[str] = None,
defaults: Optional[bool] = True,
) -> str:
"""Construct a workflow on the filesystem."""
"""Construct a workflow on the filesystem.
Args:
defaults: Set up a common defaults.
* [scheduling]allow implicit tasks = true
Set false for Cylc 7 upgrader tests.
"""
if id_:
flow_run_dir = (cylc_run_dir / id_)
else:
Expand All @@ -66,15 +74,18 @@ def _make_flow(
flow_run_dir = (test_dir / name)
flow_run_dir.mkdir(parents=True, exist_ok=True)
id_ = str(flow_run_dir.relative_to(cylc_run_dir))
# set the default simulation runtime to zero (can be overridden)
(
conf.setdefault('runtime', {})
.setdefault('root', {})
.setdefault('simulation', {})
.setdefault('default run length', 'PT0S')
)
# allow implicit tasks by default:
conf.setdefault('scheduler', {}).setdefault('allow implicit tasks', 'True')
if defaults:
# set the default simulation runtime to zero (can be overridden)
(
conf.setdefault('runtime', {})
.setdefault('root', {})
.setdefault('simulation', {})
.setdefault('default run length', 'PT0S')
)
# allow implicit tasks by default:
conf.setdefault('scheduler', {}).setdefault(
'allow implicit tasks', 'True')

with open((flow_run_dir / WorkflowFiles.FLOW_FILE), 'w+') as flow_file:
flow_file.write(flow_config_str(conf))
return id_
Expand Down

0 comments on commit 6cec298

Please sign in to comment.