Skip to content

Commit

Permalink
Replace parse_workflow_arg with parse_reg. (cylc#84)
Browse files Browse the repository at this point in the history
* Replace `parse_workflow_arg` with `parse_reg`.
Fixed a test with an over-specific dependence on error output.
Alphabetized imports.

* fix mypy fail
  • Loading branch information
wxtim authored Aug 24, 2021
1 parent 0cd8560 commit 9cd5448
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
9 changes: 5 additions & 4 deletions cylc/rose/platform_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
# -----------------------------------------------------------------------------
"""Interfaces for Cylc Platforms for use by rose apps.
"""
from optparse import Values
from pathlib import Path
from typing import Optional, Dict, Any

from cylc.flow.config import WorkflowConfig
from cylc.flow.rundb import CylcWorkflowDAO
from cylc.flow.workflow_files import parse_workflow_arg
from cylc.flow.workflow_files import parse_reg
from cylc.flow.platforms import get_platform


Expand All @@ -41,8 +42,8 @@ def get_platform_from_task_def(
Returns:
Platform Dictionary.
"""
flow_name, flow_file = parse_workflow_arg(None, flow)
config = WorkflowConfig(flow, flow_file, None)
flow_name, flow_file = parse_reg(flow, src=True)
config = WorkflowConfig(flow, flow_file, Values())
# Get entire task spec to allow Cylc 7 platform from host guessing.
task_spec = config.pcfg.get(['runtime', task])
platform = get_platform(task_spec)
Expand All @@ -65,7 +66,7 @@ def get_platforms_from_task_jobs(
Returns:
Platform Dictionary.
"""
flow_name, flow_file = parse_workflow_arg(None, flow)
flow_name, flow_file = parse_reg(flow, src=True)
dbfilepath = Path(flow_file).parent / '.service/db'
dao = CylcWorkflowDAO(dbfilepath)
task_platform_map: Dict = {}
Expand Down
26 changes: 11 additions & 15 deletions tests/functional/test_pre_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
"""Functional tests for top-level function record_cylc_install_options and
"""

from pathlib import Path
import pytest
import os
import pytest
import re

from itertools import product
from pathlib import Path
from pytest import param
from shlex import split
from subprocess import run

Expand All @@ -35,21 +37,15 @@ def envar_exporter(dict_):
@pytest.mark.parametrize(
'srcdir, expect',
[
(
param(
'07_cli_override',
(
b'Jinja2Error: Jinja2 Assertion Error: failed 1.1\nContext '
b'lines:\n\n# 1. This should fail unless cylc validate --set '
b'CLI_VAR=42\n{{ assert(CLI_VAR=="Wobble", "failed 1.1") }}\t'
b'<-- Exception\n'
),
b'CLI_VAR=="Wobble", "failed 1.1"',
id='template variable not set'
),
(
param(
'08_template_engine_conflict',
(
b'TemplateVarLanguageClash: Plugins set templating engine = '
b'empy which does not match #!jinja2 set in flow.cylc.\n'
)
b'TemplateVarLanguageClash: .*= empy.* #!jinja2.*',
id='template engine conflict'
)
]
)
Expand All @@ -60,7 +56,7 @@ def test_validate_fail(srcdir, expect):
)
assert sub.returncode != 0
if expect:
assert sub.stderr == expect
assert re.findall(expect, sub.stderr)


@pytest.mark.parametrize(
Expand Down

0 comments on commit 9cd5448

Please sign in to comment.