network icon indicating copy to clipboard operation
network copied to clipboard

don't compare booleans, this was fixed only very recently: https://github.com/pallets/jinja/issues/813

Open tyll opened this issue 5 years ago • 4 comments

don't compare booleans, this was fixed only very recently: https://github.com/pallets/jinja/issues/813

Originally posted by @pcahyna in https://github.com/linux-system-roles/network/pull/232/files

tyll avatar Jun 15 '20 19:06 tyll

Possible patch:

diff --git a/tests/tasks/test_802.1x_capath.yml b/tests/tasks/test_802.1x_capath.yml
index f98b1b2..b8d7949 100644
--- a/tests/tasks/test_802.1x_capath.yml
+++ b/tests/tasks/test_802.1x_capath.yml
@@ -79,13 +79,15 @@
         - __NM_capath_ignored_NVRs
 
     - name: Assert role behavior
+      vars:
+        expected_failure: __network_NM_NVR.stdout in __NM_capath_ignored_NVRs
+        failure: __network_connections_result.failed
       assert:
-        that: __network_connections_result.failed ==
-          (__network_NM_NVR.stdout in __NM_capath_ignored_NVRs)
-        msg: "Role {{ __network_connections_result.failed and 'failed'
-            or 'did not fail' }} but was expected
-            {{ (__network_NM_NVR.stdout in __NM_capath_ignored_NVRs)
-            and '' or 'not' }} to fail. NM NVR: {{ __network_NM_NVR.stdout }}"
+        that: (failure and expected_failure) or
+          (not failure and not expected_failure)
+        msg: "Role {{ failure and 'failed' or 'did not fail' }} but was expected
+          {{ expected_failure and '' or 'not' }} to fail.
+          NM NVR: {{ __network_NM_NVR.stdout }}"
 
     - name: Assert ping succeeded
       assert:

tyll avatar Jun 15 '20 19:06 tyll

@pcahyna are the Jinja2 requirements for the system roles documented anywhere? Please provide a URL if they are.

tyll avatar Jun 16 '20 10:06 tyll

@tyll here: https://github.com/linux-system-roles/storage/issues/49

pcahyna avatar Jun 16 '20 10:06 pcahyna

@tyll more formally here: https://github.com/oasis-roles/meta_standards#ansible-best-practices

pcahyna avatar Jun 16 '20 10:06 pcahyna