-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
114 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# THIS FILE IS PART OF THE CYLC WORKFLOW ENGINE. | ||
# Copyright (C) NIWA & British Crown (Met Office) & Contributors. | ||
# | ||
# This program is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
# Test aspects of the `cylc workflow-state` command. | ||
|
||
import pytest | ||
from shutil import copytree, rmtree | ||
|
||
from cylc.flow.exceptions import InputError | ||
from cylc.flow.pathutil import get_cylc_run_dir | ||
from cylc.flow.scripts.workflow_state import get_workflow | ||
|
||
|
||
def test_get_workflow(tmp_run_dir): | ||
"""It should infer the run name for auto-numbered installations.""" | ||
# it doesn't do anything for a named run | ||
tmp_run_dir('foo/run1', installed=True) | ||
cylc_run_dir = get_cylc_run_dir() | ||
|
||
assert get_workflow('foo') == ('foo/run1', cylc_run_dir) | ||
|
||
# Now test we can see workflows in alternate cylc-run directories | ||
# e.g. for `cylc workflow-state` or xtriggers targetting another user. | ||
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): | ||
get_workflow('foo') | ||
|
||
# But it can if we specify the alternate location. | ||
assert get_workflow('foo', alt_cylc_run_dir) == ( | ||
'foo/run1', alt_cylc_run_dir) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters