From 399d57a651d94b4ebbb985b5fa80fec5e22146c7 Mon Sep 17 00:00:00 2001 From: Michael Scherer Date: Sat, 21 Sep 2013 12:57:25 +0200 Subject: [PATCH] add more tests : - test part of ansible.runner.filter_plugins.core - test ansible.utils.unfrackpath --- test/TestFilters.py | 25 +++++++++++++++++++++++-- test/TestUtils.py | 6 ++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/test/TestFilters.py b/test/TestFilters.py index 4bd5b32fa8..024185bce5 100644 --- a/test/TestFilters.py +++ b/test/TestFilters.py @@ -4,6 +4,7 @@ Test bundled filters import unittest, tempfile, shutil from ansible import playbook, inventory, callbacks +import ansible.runner.filter_plugins.core INVENTORY = inventory.Inventory(['localhost']) @@ -62,6 +63,26 @@ class TestFilters(unittest.TestCase): f.write(data) return name + def test_bool_none(self): + a = ansible.runner.filter_plugins.core.bool(None) + assert a == None + + def test_bool_true(self): + a = ansible.runner.filter_plugins.core.bool(True) + assert a == True + + def test_bool_yes(self): + a = ansible.runner.filter_plugins.core.bool('Yes') + assert a == True + + def test_bool_no(self): + a = ansible.runner.filter_plugins.core.bool('Foo') + assert a == False + + def test_quotes(self): + a = ansible.runner.filter_plugins.core.quote('ls | wc -l') + assert a == "'ls | wc -l'" + #def test_filters(self): # this test is pretty low level using a playbook, hence I am disabling it for now -- MPD. @@ -80,6 +101,6 @@ class TestFilters(unittest.TestCase): # stats = callbacks.AggregateStats(), #).run() - out = open(dest).read() - self.assertEqual(DEST, out) + #out = open(dest).read() + #self.assertEqual(DEST, out) diff --git a/test/TestUtils.py b/test/TestUtils.py index 4f5c97bc88..9d6714dd81 100644 --- a/test/TestUtils.py +++ b/test/TestUtils.py @@ -15,6 +15,12 @@ class TestUtils(unittest.TestCase): ##################################### ### varReplace function tests + def test_unfrackpath(self): + os.symlink("/etc", "/tmp/etc") + a = ansible.utils.unfrackpath('$HOME/../../tmp/etc/') + assert a == '/etc' + os.unlink('/tmp/etc') + def test_varReplace_simple(self): template = 'hello $who' vars = {