Skip to content

Commit

Permalink
Add unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Apr 3, 2024
1 parent c06d52d commit e17337e
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unit/test_id_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
from pathlib import Path
import pytest
from shutil import copytree, rmtree

from cylc.flow import CYLC_LOG
from cylc.flow.async_util import pipe
Expand Down Expand Up @@ -248,6 +249,32 @@ async def test_parse_ids_infer_run_name(tmp_run_dir):
)
assert list(workflows) == ['bar']

# Now test we can see workflows in alternate cylc-run directories
# e.g. for `cylc workflow-state` or xtriggers targetting another user.
cylc_run_dir = get_cylc_run_dir()
alt_cylc_run_dir = cylc_run_dir + "_alt"

# copy the cylc-run dir to alt location and delete the original.
copytree(cylc_run_dir, alt_cylc_run_dir, symlinks=True)
rmtree(cylc_run_dir)

# It can no longer parse IDs in the original cylc-run location.
with pytest.raises(InputError):
workflows, *_ = await parse_ids_async(
'bar//',
constraint='workflows',
infer_latest_runs=True,
)

# But it can if we specify the alternate location.
workflows, *_ = await parse_ids_async(
'bar//',
constraint='workflows',
infer_latest_runs=True,
alt_run_dir=alt_cylc_run_dir
)
assert list(workflows) == ['bar/run2']


@pytest.fixture
def patch_expand_workflow_tokens(monkeypatch):
Expand Down

0 comments on commit e17337e

Please sign in to comment.