Skip to content

Commit

Permalink
Ensure that a :suite.rc is added to the template language when crea…
Browse files Browse the repository at this point in the history
…ting defines.
  • Loading branch information
wxtim committed Aug 22, 2023
1 parent 6442245 commit b539443
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ creating a new release entry be sure to copy & paste the span tag with the
updated. Only the first match gets replaced, so it's fine to leave the old
ones in. -->

## __cylc-rose-1.3.1 (<span actions:bind='release-date'>Upcoming</span>)__

### Fixes

[#248](https://github.com/cylc/cylc-rose/pull/248) - Make sure that rose stem sets variables in `[jinja2:suite.rc]` not `[jinja2]`.

## __cylc-rose-1.3.0 (<span actions:bind='release-date'>Released 2023-07-21</span>)__

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion cylc/rose/stem.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def process(self):
# Get the name of the template section to be used:
template_type = get_rose_vars(
Path(url) / "rose-stem")["templating_detected"]
self.template_section = f'[{template_type}]'
self.template_section = f'[{template_type}:suite.rc]'

# Versions of variables with hostname prepended for working copies
url_host = self._prepend_localhost(url)
Expand Down
31 changes: 30 additions & 1 deletion tests/unit/test_rose_stem_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@
from types import SimpleNamespace

from cylc.rose.stem import (
_get_rose_stem_opts,
ProjectNotFoundException,
RoseStemVersionException,
RoseSuiteConfNotFoundException,
StemRunner,
get_source_opt_from_args
get_source_opt_from_args,
)

from metomi.rose.reporter import Reporter
Expand Down Expand Up @@ -291,3 +292,31 @@ def test__deduce_mirror():
}
project = 'someproject'
StemRunner._deduce_mirror(source_dict, project)


def test_process_template_engine_set_correctly(monkeypatch):
"""Defines are correctly assigned a [<template language>:suite.rc]
section.
https://github.com/cylc/cylc-rose/issues/246
"""
# Mimic expected result from get_rose_vars method:
monkeypatch.setattr(
'cylc.rose.stem.get_rose_vars',
lambda _: {'templating_detected': 'empy'}
)
monkeypatch.setattr(
'sys.argv',
['foo', 'bar']
)

# We are not interested in these checks, just in the defines
# created by the process method.
stemrunner = StemRunner(_get_rose_stem_opts()[1])
stemrunner._ascertain_project = lambda _: ['', '', '', '', '']
stemrunner._this_suite = lambda: '.'
stemrunner._check_suite_version = lambda _: '1'
stemrunner.process()

for define in stemrunner.opts.defines:
assert define.startswith('[empy:suite.rc]')

0 comments on commit b539443

Please sign in to comment.