|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
|
|
|
|
|
from units.compat import unittest
|
|
|
|
|
from units.mock.loader import DictDataLoader
|
|
|
|
|
from units.compat.mock import MagicMock
|
|
|
|
|
|
|
|
|
|
from ansible.plugins.strategy import SharedPluginLoaderObj
|
|
|
|
|
from ansible.template import Templar
|
|
|
|
@ -33,6 +34,20 @@ class TestConditional(unittest.TestCase):
|
|
|
|
|
ret = self._eval_con(when, {})
|
|
|
|
|
self.assertTrue(ret)
|
|
|
|
|
|
|
|
|
|
def test_true_boolean(self):
|
|
|
|
|
self.cond.when = [True]
|
|
|
|
|
m = MagicMock()
|
|
|
|
|
ret = self.cond.evaluate_conditional(m, {})
|
|
|
|
|
self.assertTrue(ret)
|
|
|
|
|
self.assertFalse(m.is_template.called)
|
|
|
|
|
|
|
|
|
|
def test_false_boolean(self):
|
|
|
|
|
self.cond.when = [False]
|
|
|
|
|
m = MagicMock()
|
|
|
|
|
ret = self.cond.evaluate_conditional(m, {})
|
|
|
|
|
self.assertFalse(ret)
|
|
|
|
|
self.assertFalse(m.is_template.called)
|
|
|
|
|
|
|
|
|
|
def test_undefined(self):
|
|
|
|
|
when = [u"{{ some_undefined_thing }}"]
|
|
|
|
|
self.assertRaisesRegexp(errors.AnsibleError, "The conditional check '{{ some_undefined_thing }}' failed",
|
|
|
|
|