From 4843e1fa14010c06cb5f072c9c7f7b12ce468b09 Mon Sep 17 00:00:00 2001 From: Tim Byrne Date: Thu, 23 Dec 2021 15:42:43 -0600 Subject: [PATCH] Add arch to template tests --- test/test_unit_template_default.py | 14 ++++++++++++++ test/test_unit_template_esh.py | 14 ++++++++++++++ test/test_unit_template_j2.py | 14 ++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/test/test_unit_template_default.py b/test/test_unit_template_default.py index ea2f904..f503a39 100644 --- a/test/test_unit_template_default.py +++ b/test/test_unit_template_default.py @@ -5,6 +5,7 @@ FILE_MODE = 0o754 # these values are also testing the handling of bizarre characters LOCAL_CLASS = "default_Test+@-!^Class" +LOCAL_ARCH = "default_Test+@-!^Arch" LOCAL_SYSTEM = "default_Test+@-!^System" LOCAL_HOST = "default_Test+@-!^Host" LOCAL_USER = "default_Test+@-!^User" @@ -12,6 +13,7 @@ LOCAL_DISTRO = "default_Test+@-!^Distro" TEMPLATE = f''' start of template default class = >{{{{yadm.class}}}}< +default arch = >{{{{yadm.arch}}}}< default os = >{{{{yadm.os}}}}< default host = >{{{{yadm.hostname}}}}< default user = >{{{{yadm.user}}}}< @@ -33,6 +35,15 @@ Should not be included... {{% if yadm.class == "wrongclass2" %}} wrong class 2 {{% endif %}} +{{% if yadm.arch == "wrongarch1" %}} +wrong arch 1 +{{% endif %}} +{{% if yadm.arch == "{LOCAL_ARCH}" %}} +Included section for arch = {{{{yadm.arch}}}} ({{{{yadm.arch}}}} repeated) +{{% endif %}} +{{% if yadm.arch == "wrongarch2" %}} +wrong arch 2 +{{% endif %}} {{% if yadm.os == "wrongos1" %}} wrong os 1 {{% endif %}} @@ -74,6 +85,7 @@ end of template EXPECTED = f''' start of template default class = >{LOCAL_CLASS}< +default arch = >{LOCAL_ARCH}< default os = >{LOCAL_SYSTEM}< default host = >{LOCAL_HOST}< default user = >{LOCAL_USER}< @@ -81,6 +93,7 @@ default distro = >{LOCAL_DISTRO}< Included section from else Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated) Multiple lines +Included section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated) Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated) Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again) Included section for user = {LOCAL_USER} ({LOCAL_USER} repeated) @@ -137,6 +150,7 @@ def test_template_default(runner, yadm, tmpdir): YADM_TEST=1 source {yadm} set_awk local_class="{LOCAL_CLASS}" + local_arch="{LOCAL_ARCH}" local_system="{LOCAL_SYSTEM}" local_host="{LOCAL_HOST}" local_user="{LOCAL_USER}" diff --git a/test/test_unit_template_esh.py b/test/test_unit_template_esh.py index 23766c4..ee3888a 100644 --- a/test/test_unit_template_esh.py +++ b/test/test_unit_template_esh.py @@ -4,6 +4,7 @@ import os FILE_MODE = 0o754 LOCAL_CLASS = "esh_Test+@-!^Class" +LOCAL_ARCH = "esh_Test+@-!^Arch" LOCAL_SYSTEM = "esh_Test+@-!^System" LOCAL_HOST = "esh_Test+@-!^Host" LOCAL_USER = "esh_Test+@-!^User" @@ -11,6 +12,7 @@ LOCAL_DISTRO = "esh_Test+@-!^Distro" TEMPLATE = f''' start of template esh class = ><%=$YADM_CLASS%>< +esh arch = ><%=$YADM_ARCH%>< esh os = ><%=$YADM_OS%>< esh host = ><%=$YADM_HOSTNAME%>< esh user = ><%=$YADM_USER%>< @@ -24,6 +26,15 @@ Included section for class = <%=$YADM_CLASS%> (<%=$YADM_CLASS%> repeated) <% if [ "$YADM_CLASS" = "wrongclass2" ]; then -%> wrong class 2 <% fi -%> +<% if [ "$YADM_ARCH" = "wrongarch1" ]; then -%> +wrong arch 1 +<% fi -%> +<% if [ "$YADM_ARCH" = "{LOCAL_ARCH}" ]; then -%> +Included section for arch = <%=$YADM_ARCH%> (<%=$YADM_ARCH%> repeated) +<% fi -%> +<% if [ "$YADM_ARCH" = "wrongarch2" ]; then -%> +wrong arch 2 +<% fi -%> <% if [ "$YADM_OS" = "wrongos1" ]; then -%> wrong os 1 <% fi -%> @@ -65,11 +76,13 @@ end of template EXPECTED = f''' start of template esh class = >{LOCAL_CLASS}< +esh arch = >{LOCAL_ARCH}< esh os = >{LOCAL_SYSTEM}< esh host = >{LOCAL_HOST}< esh user = >{LOCAL_USER}< esh distro = >{LOCAL_DISTRO}< Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated) +Included section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated) Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated) Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again) Included section for user = {LOCAL_USER} ({LOCAL_USER} repeated) @@ -95,6 +108,7 @@ def test_template_esh(runner, yadm, tmpdir): script = f""" YADM_TEST=1 source {yadm} local_class="{LOCAL_CLASS}" + local_arch="{LOCAL_ARCH}" local_system="{LOCAL_SYSTEM}" local_host="{LOCAL_HOST}" local_user="{LOCAL_USER}" diff --git a/test/test_unit_template_j2.py b/test/test_unit_template_j2.py index 981112b..6e4c5b0 100644 --- a/test/test_unit_template_j2.py +++ b/test/test_unit_template_j2.py @@ -5,6 +5,7 @@ import pytest FILE_MODE = 0o754 LOCAL_CLASS = "j2_Test+@-!^Class" +LOCAL_ARCH = "j2_Test+@-!^Arch" LOCAL_SYSTEM = "j2_Test+@-!^System" LOCAL_HOST = "j2_Test+@-!^Host" LOCAL_USER = "j2_Test+@-!^User" @@ -12,6 +13,7 @@ LOCAL_DISTRO = "j2_Test+@-!^Distro" TEMPLATE = f''' start of template j2 class = >{{{{YADM_CLASS}}}}< +j2 arch = >{{{{YADM_ARCH}}}}< j2 os = >{{{{YADM_OS}}}}< j2 host = >{{{{YADM_HOSTNAME}}}}< j2 user = >{{{{YADM_USER}}}}< @@ -25,6 +27,15 @@ Included section for class = {{{{YADM_CLASS}}}} ({{{{YADM_CLASS}}}} repeated) {{%- if YADM_CLASS == "wrongclass2" %}} wrong class 2 {{%- endif %}} +{{%- if YADM_ARCH == "wrongarch1" %}} +wrong arch 1 +{{%- endif %}} +{{%- if YADM_ARCH == "{LOCAL_ARCH}" %}} +Included section for arch = {{{{YADM_ARCH}}}} ({{{{YADM_ARCH}}}} repeated) +{{%- endif %}} +{{%- if YADM_ARCH == "wrongarch2" %}} +wrong arch 2 +{{%- endif %}} {{%- if YADM_OS == "wrongos1" %}} wrong os 1 {{%- endif %}} @@ -66,11 +77,13 @@ end of template EXPECTED = f''' start of template j2 class = >{LOCAL_CLASS}< +j2 arch = >{LOCAL_ARCH}< j2 os = >{LOCAL_SYSTEM}< j2 host = >{LOCAL_HOST}< j2 user = >{LOCAL_USER}< j2 distro = >{LOCAL_DISTRO}< Included section for class = {LOCAL_CLASS} ({LOCAL_CLASS} repeated) +Included section for arch = {LOCAL_ARCH} ({LOCAL_ARCH} repeated) Included section for os = {LOCAL_SYSTEM} ({LOCAL_SYSTEM} repeated) Included section for host = {LOCAL_HOST} ({LOCAL_HOST} again) Included section for user = {LOCAL_USER} ({LOCAL_USER} repeated) @@ -97,6 +110,7 @@ def test_template_j2(runner, yadm, tmpdir, processor): script = f""" YADM_TEST=1 source {yadm} local_class="{LOCAL_CLASS}" + local_arch="{LOCAL_ARCH}" local_system="{LOCAL_SYSTEM}" local_host="{LOCAL_HOST}" local_user="{LOCAL_USER}"