Skip to content

Commit

Permalink
add python tests
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcmarrow committed Oct 18, 2023
1 parent d8e3a35 commit 1365f19
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/pytests/unit/utils/jinja/test_jinja_custom_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,3 +265,40 @@ def test_yaml():
def test_json():
_render_fail(JSON_SLS_ERROR)
assert _render(JSON_SLS) == JSON_SLS_RIGHT

PYTHON_SLS_ERROR = """
{%- set ports = {'http': 80} %}
huh:
test.configurable_test_state:
- changes: true
- result: true
- comment: https port is {{ [ports['https23'], ports['https']] | python }}
- comment2: https port is {{ [666 + 1, ports['https2']] | python }}
- comment3: https port is {{ [666 + 1, ports['https2']] | python }}
"""


PYTHON_SLS = """
{%- set ports = {'https': 80} %}
huh:
test.configurable_test_state:
- changes: true
- result: true
- comment: https port is {{ [666 + 1, ports['https']] | python }}
"""


PYTHON_SLS_RIGHT = """
huh:
test.configurable_test_state:
- changes: true
- result: true
- comment: https port is [667, 80]"""


def test_python():
_render_fail(PYTHON_SLS_ERROR)
assert _render(PYTHON_SLS) == PYTHON_SLS_RIGHT

0 comments on commit 1365f19

Please sign in to comment.