summaryrefslogtreecommitdiffstats
path: root/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-02-20 10:38:38 -0500
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-02-20 10:38:38 -0500
commit69ebf49d54aac70a42142d0d04e562496bce58ea (patch)
treead0f346ff95a14ad49440128ff76d7e2b3f0816a /testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py
parent602ba6af6bd1c9b3910940dee766660ab8e81a19 (diff)
parente17e41dcff096ead7e129a0db063f75de44aaa2b (diff)
downloadbcfg2-69ebf49d54aac70a42142d0d04e562496bce58ea.tar.gz
bcfg2-69ebf49d54aac70a42142d0d04e562496bce58ea.tar.bz2
bcfg2-69ebf49d54aac70a42142d0d04e562496bce58ea.zip
Merge branch 'master' into 1.4.x
Conflicts: doc/appendix/contributors.txt schemas/bundle.xsd src/lib/Bcfg2/Client/Tools/__init__.py src/lib/Bcfg2/Server/Encryption.py src/lib/Bcfg2/Server/Lint/Genshi.py src/lib/Bcfg2/Server/Plugins/Bundler.py src/lib/Bcfg2/Server/Plugins/Decisions.py src/lib/Bcfg2/Server/Plugins/TemplateHelper.py src/sbin/bcfg2-test testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/Test__init.py testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIXUsers.py testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testhelpers.py testsuite/Testsrc/Testlib/TestServer/TestPlugins/TestProperties.py tools/bcfg2-profile-templates.py
Diffstat (limited to 'testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py')
-rw-r--r--testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py111
1 files changed, 55 insertions, 56 deletions
diff --git a/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py b/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py
index 16490808e..d9431dc63 100644
--- a/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py
+++ b/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py
@@ -15,46 +15,47 @@ while path != "/":
if os.path.basename(path) == "testsuite":
break
path = os.path.dirname(path)
-from Test__init import get_posix_object
from Testbase import TestPOSIXTool
from common import *
+
class TestPOSIXDirectory(TestPOSIXTool):
test_obj = POSIXDirectory
@patch("os.listdir")
@patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.verify")
- @patch("Bcfg2.Client.Tools.POSIX.Directory.%s._exists" % test_obj.__name__)
- def test_verify(self, mock_exists, mock_verify, mock_listdir):
+ def test_verify(self, mock_verify, mock_listdir):
+ ptool = self.get_obj()
+ ptool._exists = Mock()
entry = lxml.etree.Element("Path", name="/test", type="directory",
mode='0644', owner='root', group='root')
- mock_exists.return_value = False
- self.assertFalse(self.ptool.verify(entry, []))
- mock_exists.assert_called_with(entry)
+ ptool._exists.return_value = False
+ self.assertFalse(ptool.verify(entry, []))
+ ptool._exists.assert_called_with(entry)
- mock_exists.reset_mock()
+ ptool._exists.reset_mock()
exists_rv = MagicMock()
exists_rv.__getitem__.return_value = stat.S_IFREG | 420 # 0o644
- mock_exists.return_value = exists_rv
- self.assertFalse(self.ptool.verify(entry, []))
- mock_exists.assert_called_with(entry)
+ ptool._exists.return_value = exists_rv
+ self.assertFalse(ptool.verify(entry, []))
+ ptool._exists.assert_called_with(entry)
- mock_exists.reset_mock()
+ ptool._exists.reset_mock()
mock_verify.return_value = False
exists_rv.__getitem__.return_value = stat.S_IFDIR | 420 # 0o644
- self.assertFalse(self.ptool.verify(entry, []))
- mock_exists.assert_called_with(entry)
- mock_verify.assert_called_with(self.ptool, entry, [])
+ self.assertFalse(ptool.verify(entry, []))
+ ptool._exists.assert_called_with(entry)
+ mock_verify.assert_called_with(ptool, entry, [])
- mock_exists.reset_mock()
+ ptool._exists.reset_mock()
mock_verify.reset_mock()
mock_verify.return_value = True
- self.assertTrue(self.ptool.verify(entry, []))
- mock_exists.assert_called_with(entry)
- mock_verify.assert_called_with(self.ptool, entry, [])
+ self.assertTrue(ptool.verify(entry, []))
+ ptool._exists.assert_called_with(entry)
+ mock_verify.assert_called_with(ptool, entry, [])
- mock_exists.reset_mock()
+ ptool._exists.reset_mock()
mock_verify.reset_mock()
entry.set("prune", "true")
orig_entry = copy.deepcopy(entry)
@@ -62,9 +63,9 @@ class TestPOSIXDirectory(TestPOSIXTool):
entries = ["foo", "bar", "bar/baz"]
mock_listdir.return_value = entries
modlist = [os.path.join(entry.get("name"), entries[0])]
- self.assertFalse(self.ptool.verify(entry, modlist))
- mock_exists.assert_called_with(entry)
- mock_verify.assert_called_with(self.ptool, entry, modlist)
+ self.assertFalse(ptool.verify(entry, modlist))
+ ptool._exists.assert_called_with(entry)
+ mock_verify.assert_called_with(ptool, entry, modlist)
mock_listdir.assert_called_with(entry.get("name"))
expected = [os.path.join(entry.get("name"), e)
for e in entries
@@ -73,67 +74,65 @@ class TestPOSIXDirectory(TestPOSIXTool):
self.assertItemsEqual(expected, actual)
mock_verify.reset_mock()
- mock_exists.reset_mock()
+ ptool._exists.reset_mock()
mock_listdir.reset_mock()
entry = copy.deepcopy(orig_entry)
modlist = [os.path.join(entry.get("name"), e)
for e in entries]
- self.assertTrue(self.ptool.verify(entry, modlist))
- mock_exists.assert_called_with(entry)
- mock_verify.assert_called_with(self.ptool, entry, modlist)
+ self.assertTrue(ptool.verify(entry, modlist))
+ ptool._exists.assert_called_with(entry)
+ mock_verify.assert_called_with(ptool, entry, modlist)
mock_listdir.assert_called_with(entry.get("name"))
self.assertEqual(len(entry.findall("Prune")), 0)
@patch("os.unlink")
@patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.install")
- @patch("Bcfg2.Client.Tools.POSIX.Directory.%s._exists" % test_obj.__name__)
- @patch("Bcfg2.Client.Tools.POSIX.Directory.%s._makedirs" %
- test_obj.__name__)
- def test_install(self, mock_makedirs, mock_exists, mock_install,
- mock_unlink):
+ def test_install(self, mock_install, mock_unlink):
entry = lxml.etree.Element("Path", name="/test/foo/bar",
type="directory", mode='0644',
owner='root', group='root')
- self.ptool._makedirs = Mock()
- self.ptool._remove = Mock()
+ ptool = self.get_obj()
+ ptool._exists = Mock()
+ ptool._makedirs = Mock()
+ ptool._remove = Mock()
def reset():
- mock_exists.reset_mock()
+ ptool._exists.reset_mock()
mock_install.reset_mock()
mock_unlink.reset_mock()
- self.ptool._makedirs.reset_mock()
- self.ptool._remove.reset_mock()
+ ptool._makedirs.reset_mock()
+ ptool._remove.reset_mock()
- self.ptool._makedirs.return_value = True
- mock_exists.return_value = False
+ ptool._makedirs.return_value = True
+ ptool._exists.return_value = False
mock_install.return_value = True
- self.assertTrue(self.ptool.install(entry))
- mock_exists.assert_called_with(entry)
- mock_install.assert_called_with(self.ptool, entry)
- self.ptool._makedirs.assert_called_with(entry)
+ self.assertTrue(ptool.install(entry))
+ ptool._exists.assert_called_with(entry)
+ mock_install.assert_called_with(ptool, entry)
+ ptool._makedirs.assert_called_with(entry)
reset()
exists_rv = MagicMock()
exists_rv.__getitem__.return_value = stat.S_IFREG | 420 # 0o644
- mock_exists.return_value = exists_rv
- self.assertTrue(self.ptool.install(entry))
+ ptool._exists.return_value = exists_rv
+ self.assertTrue(ptool.install(entry))
mock_unlink.assert_called_with(entry.get("name"))
- mock_exists.assert_called_with(entry)
- self.ptool._makedirs.assert_called_with(entry)
- mock_install.assert_called_with(self.ptool, entry)
+ ptool._exists.assert_called_with(entry)
+ ptool._makedirs.assert_called_with(entry)
+ mock_install.assert_called_with(ptool, entry)
reset()
exists_rv.__getitem__.return_value = stat.S_IFDIR | 420 # 0o644
mock_install.return_value = True
- self.assertTrue(self.ptool.install(entry))
- mock_exists.assert_called_with(entry)
- mock_install.assert_called_with(self.ptool, entry)
+ self.assertTrue(ptool.install(entry))
+ ptool._exists.assert_called_with(entry)
+ mock_install.assert_called_with(ptool, entry)
reset()
mock_install.return_value = False
- self.assertFalse(self.ptool.install(entry))
- mock_install.assert_called_with(self.ptool, entry)
+ self.assertFalse(ptool.install(entry))
+ mock_install.assert_called_with(ptool, entry)
entry.set("prune", "true")
prune = ["/test/foo/bar/prune1", "/test/foo/bar/prune2"]
@@ -143,9 +142,9 @@ class TestPOSIXDirectory(TestPOSIXTool):
reset()
mock_install.return_value = True
- self.assertTrue(self.ptool.install(entry))
- mock_exists.assert_called_with(entry)
- mock_install.assert_called_with(self.ptool, entry)
+ self.assertTrue(ptool.install(entry))
+ ptool._exists.assert_called_with(entry)
+ mock_install.assert_called_with(ptool, entry)
self.assertItemsEqual([c[0][0].get("path")
- for c in self.ptool._remove.call_args_list],
+ for c in ptool._remove.call_args_list],
prune)