Skip to content

Commit

Permalink
Fix.do not allow multiple templating sections (#133)
Browse files Browse the repository at this point in the history
* test for having multiple templating sections including [template variables]
* make sure failure occurs if more than one template variable section is defined.
  • Loading branch information
wxtim authored Apr 7, 2022
1 parent c235c4b commit 5d72591
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
[130](https://github.com/cylc/cylc-rose/pull/130) - Fix bug preventing
``cylc reinstall`` using Rose fileinstall.

[133](https://github.com/cylc/cylc-rose/pull/133) - Fix bug allowing setting
multiple template variable sections.

## __cylc-rose-1.0.2 (<span actions:bind='release-date'>Released 2022-03-24</span>)__

Expand Down
6 changes: 1 addition & 5 deletions cylc/rose/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,8 @@ def get_rose_vars_from_config_node(config, config_node, environ):


def identify_templating_section(config_node):

defined_sections = SECTIONS.intersection(set(config_node.value.keys()))
if (
'jinja2:suite.rc' in defined_sections
and 'empy:suite.rc' in defined_sections
):
if len(defined_sections) > 1:
raise MultipleTemplatingEnginesError(
"You should not define more than one templating section. "
f"You defined:\n\t{'; '.join(defined_sections)}"
Expand Down
11 changes: 10 additions & 1 deletion tests/test_config_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,16 @@ def test_dump_rose_log(monkeypatch, tmp_path):
),
None,
MultipleTemplatingEnginesError,
id="FAILS - clashing template sections set",
id="FAILS - empy and jinja2 sections set",
),
pytest.param(
(
(['empy:suite.rc', 'foo'], 'Hello World'),
(['template variables', 'foo'], 'Hello World'),
),
None,
MultipleTemplatingEnginesError,
id="FAILS - empy and template variables sections set",
),
pytest.param(
(
Expand Down

0 comments on commit 5d72591

Please sign in to comment.