Test Failed
Pull Request — master (#3170)
by Matěj
02:13
created

test_jinja   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 8

3 Functions

Rating   Name   Duplication   Size   Complexity  
A get_definitions_with_substitution() 0 8 2
A test_macro_presence() 0 4 3
A test_macro_expansion() 0 6 3
1
import os
2
3
import pytest
4
5
import ssg.jinja
6
7
8
def get_definitions_with_substitution(subs_dict=None):
9
    if subs_dict is None:
10
        subs_dict = dict()
11
    subs_dict["jinja2_cache_enabled"] = "false"
12
13
    definitions = os.path.join(os.path.dirname(__file__), "data", "definitions.jinja")
14
    defs = ssg.jinja.extract_substitutions_dict_from_template(definitions, subs_dict)
15
    return defs
16
17
18
def test_macro_presence():
19
    actual_defs = get_definitions_with_substitution()
20
    assert "expand_to_bar" in actual_defs
21
    assert actual_defs["expand_to_bar"]() == "bar"
22
23
24
def test_macro_expansion():
25
    incomplete_defs = get_definitions_with_substitution()
26
    assert incomplete_defs["expand_to_global_var"]() == ""
27
28
    complete_defs = get_definitions_with_substitution(dict(global_var="value"))
29
    assert complete_defs["expand_to_global_var"]() == "value"
30