Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only the template engine sequence #262

Merged
merged 4 commits into from
Mar 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .moban.cd/changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ releases:
details:
- "`#253`: symbolic link in regression pack causes python setup.py to do recursive include"
- "`#209`: Alert moban user when `git` is not available and is used."
- "`#261`: since moban group template files per template type, this fill use first come first register to order moban group"
date: unreleased
version: 0.4.3
- changes:
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Removed
regression pack causes python setup.py to do recursive include
#. `#209 <https://github.com/moremoban/moban/issues/209>`_: Alert moban user
when `git` is not available and is used.
#. `#261 <https://github.com/moremoban/moban/issues/261>`_: since moban group
template files per template type, this fill use first come first register to
order moban group

0.4.2 - 08.03.2019
--------------------------------------------------------------------------------
Expand Down
7 changes: 5 additions & 2 deletions moban/mobanfile/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import re
import sys
from collections import defaultdict
from collections import OrderedDict

from lml.utils import do_import

Expand Down Expand Up @@ -112,7 +112,7 @@ def _iterate_list_of_dicts(list_of_dict):

def handle_targets(merged_options, targets):
list_of_templating_parameters = parse_targets(merged_options, targets)
jobs_for_each_engine = defaultdict(list)
jobs_for_each_engine = OrderedDict()

for target in list_of_templating_parameters:
forced_template_type = merged_options.get(
Expand All @@ -129,6 +129,9 @@ def handle_targets(merged_options, targets):
]
target.set_template_type(primary_template_type)

if primary_template_type not in jobs_for_each_engine:
jobs_for_each_engine[primary_template_type] = []

jobs_for_each_engine[primary_template_type].append(target)

count = 0
Expand Down
Empty file.
Empty file.
42 changes: 42 additions & 0 deletions tests/mobanfile/test_mobanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,45 @@ def test_handle_targets(fake_renderer):
)
],
)


@patch("moban.plugins.template.MobanEngine.render_to_files")
def test_handle_targets_sequence(fake_renderer):
from moban.mobanfile import handle_targets

TEMPLATE1 = "a.template.jj2"
OUTPUT1 = "filterme.handlebars" # in the future, this could dynamic output
OUTPUT2 = "filtered_output.txt"
CONFIGURATION = "child.yaml"
TEMPLATE_DIRS = [os.path.join("tests", "fixtures", "mobanfile")]
DEFAULT_TEMPLATE_TYPE = "jinja2"

options = dict(
configuration=CONFIGURATION,
template_type=DEFAULT_TEMPLATE_TYPE,
template_dir=TEMPLATE_DIRS,
configuration_dir=os.path.join("tests", "fixtures"),
)
short_hand_targets = [{OUTPUT1: TEMPLATE1}, {OUTPUT2: OUTPUT1}]
handle_targets(options, short_hand_targets)

call_args = list(fake_renderer.call_args_list)

eq_(
call_args[0][0][0][0],
TemplateTarget(
"a.template.jj2",
"child.yaml",
"filterme.handlebars",
template_type="jj2",
),
)
eq_(
call_args[1][0][0][0],
TemplateTarget(
"filterme.handlebars",
"child.yaml",
"filtered_output.txt",
template_type="handlebars",
),
)