Skip to content

Commit

Permalink
Style tweaks.
Browse files Browse the repository at this point in the history
  • Loading branch information
hjoliver committed Apr 3, 2024
1 parent 678ca20 commit 75fd78b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 2 additions & 3 deletions cylc/flow/scripts/workflow_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,10 @@ def main(parser: COP, options: 'Values', workflow_id: str) -> None:
raise InputError(f"invalid status '{options.status}'")

workflow_id = infer_latest_run_from_id(workflow_id, options.alt_run_dir)
run_dir = expand_path(options.alt_run_dir or get_cylc_run_dir())

pollargs = {
'workflow_id': workflow_id,
'run_dir': run_dir,
'run_dir': expand_path(options.alt_run_dir or get_cylc_run_dir()),
'task': options.task,
'cycle': options.cycle,
'status': options.status,
Expand All @@ -249,7 +248,7 @@ def main(parser: COP, options: 'Values', workflow_id: str) -> None:
connected, formatted_pt = spoller.connect()

if not connected:
raise CylcError("cannot connect to the workflow_id DB")
raise CylcError(f"Cannot connect to the {workflow_id} DB")

Check warning on line 251 in cylc/flow/scripts/workflow_state.py

View check run for this annotation

Codecov / codecov/patch

cylc/flow/scripts/workflow_state.py#L251

Added line #L251 was not covered by tests

if options.status and options.task and options.cycle:
# check a task status
Expand Down
9 changes: 6 additions & 3 deletions tests/unit/xtriggers/test_workflow_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from cylc.flow.xtriggers.workflow_state import workflow_state
from ..conftest import MonkeyMock


def test_inferred_run(tmp_run_dir: Callable, monkeymock: MonkeyMock):
"""Test that the workflow_state xtrigger infers the run number"""
id_ = 'isildur'
Expand All @@ -44,7 +45,6 @@ def test_inferred_run(tmp_run_dir: Callable, monkeymock: MonkeyMock):
mock_db_checker.assert_called_once_with(cylc_run_dir, expected_workflow_id)
assert results['workflow'] == expected_workflow_id


# 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"
Expand All @@ -59,10 +59,13 @@ def test_inferred_run(tmp_run_dir: Callable, monkeymock: MonkeyMock):

# But it can via an explicit alternate run directory.
mock_db_checker.reset_mock()
_, results = workflow_state(id_, task='precious', point='3000', cylc_run_dir=alt_cylc_run_dir)
mock_db_checker.assert_called_once_with(alt_cylc_run_dir, expected_workflow_id)
_, results = workflow_state(
id_, task='precious', point='3000', cylc_run_dir=alt_cylc_run_dir)
mock_db_checker.assert_called_once_with(
alt_cylc_run_dir, expected_workflow_id)
assert results['workflow'] == expected_workflow_id


def test_back_compat(tmp_run_dir):
"""Test workflow_state xtrigger backwards compatibility with Cylc 7
database."""
Expand Down

0 comments on commit 75fd78b

Please sign in to comment.