Use ansible filters in e2e tests
There are a lot of filters ansible provides that are not present in upstream Jinja2.
Jinja2 Ansible Filters doesn't include heavy ansible filters(typical example is combine).
This commit defines and imports ansible filters as extensions in jinja2.
diff --git a/atmosphere/tests/e2e/test_operator.py b/atmosphere/tests/e2e/test_operator.py
index 0cd0951..8f67887 100644
--- a/atmosphere/tests/e2e/test_operator.py
+++ b/atmosphere/tests/e2e/test_operator.py
@@ -5,6 +5,7 @@
import pytest
import tomli_w
import yaml
+from ansible.plugins.filter import core
from jinja2 import Environment, FileSystemLoader
from python_on_whales import docker
from tenacity import Retrying, retry_if_exception_type, stop_after_delay, wait_fixed
@@ -26,10 +27,10 @@
env = Environment(
loader=FileSystemLoader("roles/atmosphere/templates"),
- extensions=["jinja2_base64_filters.Base64Filters"],
+ extensions=["jinja2_base64_filters.Base64Filters", "jinja2_base64_filters.Base64Filters"],
)
env.filters["vexxhost.atmosphere.to_toml"] = tomli_w.dumps
- env.filters["to_json"] = json.dumps
+ env.filters["combine"] = core.combine
args = {
"atmosphere_image": docker_image,
diff --git a/poetry.lock b/poetry.lock
index 24424df..61c01fa 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -515,6 +515,21 @@
i18n = ["Babel (>=2.7)"]
[[package]]
+name = "jinja2-ansible-filters"
+version = "1.3.2"
+description = "A port of Ansible's jinja2 filters without requiring ansible core."
+category = "dev"
+optional = false
+python-versions = "*"
+
+[package.dependencies]
+Jinja2 = "*"
+PyYAML = "*"
+
+[package.extras]
+test = ["pytest", "pytest-cov"]
+
+[[package]]
name = "jinja2-base64-filters"
version = "0.1.4"
description = "Tiny jinja2 extension to add b64encode and b64decode filters."
@@ -1566,7 +1581,7 @@
[metadata]
lock-version = "1.1"
python-versions = "^3.10"
-content-hash = "4cfb74eb377030e130db915104c6c87052f28fcd1c6908b06e8e85ffadce6700"
+content-hash = "ea6918532c497f47184907982ab02e01360dc9c956db64eca185eb248f647720"
[metadata.files]
aiohttp = [
@@ -2051,6 +2066,7 @@
{file = "greenlet-2.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d5b0ff9878333823226d270417f24f4d06f235cb3e54d1103b71ea537a6a86ce"},
{file = "greenlet-2.0.1-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:be9e0fb2ada7e5124f5282d6381903183ecc73ea019568d6d63d33f25b2a9000"},
{file = "greenlet-2.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0b493db84d124805865adc587532ebad30efa68f79ad68f11b336e0a51ec86c2"},
+ {file = "greenlet-2.0.1-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:0459d94f73265744fee4c2d5ec44c6f34aa8a31017e6e9de770f7bcf29710be9"},
{file = "greenlet-2.0.1-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:a20d33124935d27b80e6fdacbd34205732660e0a1d35d8b10b3328179a2b51a1"},
{file = "greenlet-2.0.1-cp37-cp37m-win32.whl", hash = "sha256:ea688d11707d30e212e0110a1aac7f7f3f542a259235d396f88be68b649e47d1"},
{file = "greenlet-2.0.1-cp37-cp37m-win_amd64.whl", hash = "sha256:afe07421c969e259e9403c3bb658968702bc3b78ec0b6fde3ae1e73440529c23"},
@@ -2059,6 +2075,7 @@
{file = "greenlet-2.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:659f167f419a4609bc0516fb18ea69ed39dbb25594934bd2dd4d0401660e8a1e"},
{file = "greenlet-2.0.1-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:356e4519d4dfa766d50ecc498544b44c0249b6de66426041d7f8b751de4d6b48"},
{file = "greenlet-2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:811e1d37d60b47cb8126e0a929b58c046251f28117cb16fcd371eed61f66b764"},
+ {file = "greenlet-2.0.1-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:d38ffd0e81ba8ef347d2be0772e899c289b59ff150ebbbbe05dc61b1246eb4e0"},
{file = "greenlet-2.0.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:0109af1138afbfb8ae647e31a2b1ab030f58b21dd8528c27beaeb0093b7938a9"},
{file = "greenlet-2.0.1-cp38-cp38-win32.whl", hash = "sha256:88c8d517e78acdf7df8a2134a3c4b964415b575d2840a2746ddb1cc6175f8608"},
{file = "greenlet-2.0.1-cp38-cp38-win_amd64.whl", hash = "sha256:d6ee1aa7ab36475035eb48c01efae87d37936a8173fc4d7b10bb02c2d75dd8f6"},
@@ -2067,6 +2084,7 @@
{file = "greenlet-2.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:505138d4fa69462447a562a7c2ef723c6025ba12ac04478bc1ce2fcc279a2db5"},
{file = "greenlet-2.0.1-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:cce1e90dd302f45716a7715517c6aa0468af0bf38e814ad4eab58e88fc09f7f7"},
{file = "greenlet-2.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9e9744c657d896c7b580455e739899e492a4a452e2dd4d2b3e459f6b244a638d"},
+ {file = "greenlet-2.0.1-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:662e8f7cad915ba75d8017b3e601afc01ef20deeeabf281bd00369de196d7726"},
{file = "greenlet-2.0.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:41b825d65f31e394b523c84db84f9383a2f7eefc13d987f308f4663794d2687e"},
{file = "greenlet-2.0.1-cp39-cp39-win32.whl", hash = "sha256:db38f80540083ea33bdab614a9d28bcec4b54daa5aff1668d7827a9fc769ae0a"},
{file = "greenlet-2.0.1-cp39-cp39-win_amd64.whl", hash = "sha256:b23d2a46d53210b498e5b701a1913697671988f4bf8e10f935433f6e7c332fb6"},
@@ -2092,6 +2110,10 @@
{file = "Jinja2-3.1.2-py3-none-any.whl", hash = "sha256:6088930bfe239f0e6710546ab9c19c9ef35e29792895fed6e6e31a023a182a61"},
{file = "Jinja2-3.1.2.tar.gz", hash = "sha256:31351a702a408a9e7595a8fc6150fc3f43bb6bf7e319770cbc0db9df9437e852"},
]
+jinja2-ansible-filters = [
+ {file = "jinja2-ansible-filters-1.3.2.tar.gz", hash = "sha256:07c10cf44d7073f4f01102ca12d9a2dc31b41d47e4c61ed92ef6a6d2669b356b"},
+ {file = "jinja2_ansible_filters-1.3.2-py3-none-any.whl", hash = "sha256:e1082f5564917649c76fed239117820610516ec10f87735d0338688800a55b34"},
+]
jinja2-base64-filters = [
{file = "jinja2_base64_filters-0.1.4-py2-none-any.whl", hash = "sha256:d007d543a9ce1e66a7a65645eef9100bc21a5d060a60b193fa4d4c4239bb3a86"},
{file = "jinja2_base64_filters-0.1.4.tar.gz", hash = "sha256:f5f5d3e0476c4918ab3266093e8757918aed7cc47dab12338f9bda048cdbacd9"},
diff --git a/pyproject.toml b/pyproject.toml
index 3b22c3f..4c52d94 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -59,6 +59,7 @@
pytest-mock = "^3.8.2"
python-on-whales = "^0.52.0"
tomli-w = "^1.0.0"
+jinja2-ansible-filters = "^1.3.2"
[tool.poetry.group.docs.dependencies]
mkdocs-material = "^8.5.7"