Skip to content

Commit

Permalink
testing
Browse files Browse the repository at this point in the history
  • Loading branch information
wxtim committed Jan 30, 2024
1 parent da37214 commit 326eaa1
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/integration/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@

from pathlib import Path
import sqlite3
from typing import TYPE_CHECKING
import pytest

from cylc.flow.exceptions import ServiceFileError, WorkflowConfigError
from cylc.flow.parsec.exceptions import ListValueError
from cylc.flow.pathutil import get_workflow_run_pub_db_path

if TYPE_CHECKING:
from types import Any

Fixture = Any


@pytest.mark.parametrize(
'task_name,valid', [
Expand Down Expand Up @@ -341,3 +347,52 @@ def test_validate_incompatible_db(one_conf, flow, validate):
finally:
conn.close()
assert tables == ['suite_params']


def test_xtrig_validation_wall_clock(
flow: 'Fixture',
validate: 'Fixture',
):
"""If an xtrigger module has a `validate_config` it is called.
https://github.com/cylc/cylc-flow/issues/5448
"""
id_ = flow({
'scheduler': {'allow implicit tasks': True},
'scheduling': {
'initial cycle point': '1012',
'xtriggers': {'myxt': 'wall_clock(offset=PT755MH)'},
'graph': {'R1': '@myxt => foo'},
}
})
with pytest.raises(
WorkflowConfigError,
match=r'invalid offset: wall_clock\(offset=PT755MH\)'
):
validate(id_)


def test_xtrig_validation_custom(
flow: 'Fixture',
validate: 'Fixture',
):
"""If an xtrigger module has a `validate_config` it is called.
https://github.com/cylc/cylc-flow/issues/5448
"""
id_ = flow({
'scheduler': {'allow implicit tasks': True},
'scheduling': {
'initial cycle point': '1012',
'xtriggers': {'myxt': 'kustom_xt(feature=42)'},
'graph': {'R1': '@myxt => foo'},
}
})
# Write your own xtrigger with validation to file here and
# check that it works!
Path(id_)
with pytest.raises(
WorkflowConfigError,
match=r'invalid offset: wall_clock\(offset=PT755MH\)'
):
validate(id_)

0 comments on commit 326eaa1

Please sign in to comment.