Skip to content

Commit

Permalink
fix(tests): use regex to avoid focal whitespace in jinja debug test (c…
Browse files Browse the repository at this point in the history
  • Loading branch information
blackboxsw authored May 28, 2024
1 parent 0fdbeef commit de1966e
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions tests/unittests/test_builtin_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import copy
import errno
import os
from textwrap import dedent
import re

import pytest

Expand Down Expand Up @@ -356,19 +356,6 @@ def test_render_jinja_payload_logs_jinja_vars_on_debug(self, caplog):
"## template: jinja\n#!/bin/sh\necho hi from {{ v1.hostname }}"
)
instance_data = {"v1": {"hostname": "foo"}, "instance-id": "iid"}
expected_log = dedent(
"""\
Converted jinja variables
{
"hostname": "foo",
"instance-id": "iid",
"instance_id": "iid",
"v1": {
"hostname": "foo"
}
}
"""
)
assert (
render_jinja_payload(
payload=payload,
Expand All @@ -378,7 +365,12 @@ def test_render_jinja_payload_logs_jinja_vars_on_debug(self, caplog):
)
== "#!/bin/sh\necho hi from foo"
)
assert expected_log in caplog.text
expected_log = (
'.*Converted jinja variables\\n.*{\\n.*"hostname": "foo",\\n.*'
'"instance-id": "iid",\\n.*"instance_id": "iid",\\n.*'
'"v1": {\\n.*"hostname": "foo"\\n.*}'
)
assert re.match(expected_log, caplog.text, re.DOTALL)

@skipUnlessJinja()
def test_render_jinja_payload_replaces_missing_variables_and_warns(
Expand Down

0 comments on commit de1966e

Please sign in to comment.