| Total Complexity | 8 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |