From 6de50a235ed21de987488a2890b13f029d1962b4 Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Thu, 16 Aug 2012 09:55:53 -0400 Subject: made POSIX subtool tests inherit from base POSIX tool tests --- .../TestClient/TestTools/TestPOSIX/TestDevice.py | 16 +++--- .../TestTools/TestPOSIX/TestDirectory.py | 19 ++++---- .../TestClient/TestTools/TestPOSIX/TestFile.py | 48 +++++++++--------- .../TestClient/TestTools/TestPOSIX/TestHardlink.py | 14 +++--- .../TestTools/TestPOSIX/TestNonexistent.py | 16 +++--- .../TestTools/TestPOSIX/TestPermissions.py | 11 ++--- .../TestClient/TestTools/TestPOSIX/TestSymlink.py | 14 +++--- .../TestClient/TestTools/TestPOSIX/Testbase.py | 57 ++++++++++++---------- 8 files changed, 96 insertions(+), 99 deletions(-) (limited to 'testsuite/Testlib') diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py index ba25c9bea..f32da9c37 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDevice.py @@ -5,16 +5,14 @@ import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Device import * from Test__init import get_posix_object +from Testbase import TestPOSIXTool from .....common import * -def get_device_object(posix=None): - if posix is None: - posix = get_posix_object() - return POSIXDevice(posix.logger, posix.setup, posix.config) +class TestPOSIXDevice(TestPOSIXTool): + test_obj = POSIXDevice -class TestPOSIXDevice(Bcfg2TestCase): def test_fully_specified(self): - ptool = get_device_object() + ptool = self.get_obj() orig_entry = lxml.etree.Element("Path", name="/test", type="device", dev_type="fifo") self.assertTrue(ptool.fully_specified(orig_entry)) @@ -38,7 +36,7 @@ class TestPOSIXDevice(Bcfg2TestCase): entry = lxml.etree.Element("Path", name="/test", type="device", perms='0644', owner='root', group='root', dev_type="block", major="0", minor="10") - ptool = get_device_object() + ptool = self.get_obj() def reset(): mock_exists.reset_mock() @@ -85,13 +83,13 @@ class TestPOSIXDevice(Bcfg2TestCase): @patch("os.makedev") @patch("os.mknod") - @patch("Bcfg2.Client.Tools.POSIX.Device.POSIXDevice._exists") + @patch("Bcfg2.Client.Tools.POSIX.Device.%s._exists" % test_obj.__name__) @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.install") def test_install(self, mock_install, mock_exists, mock_mknod, mock_makedev): entry = lxml.etree.Element("Path", name="/test", type="device", perms='0644', owner='root', group='root', dev_type="block", major="0", minor="10") - ptool = get_device_object() + ptool = self.get_obj() mock_exists.return_value = False mock_makedev.return_value = Mock() diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py index 41e1a3f00..34c98fa9c 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestDirectory.py @@ -6,20 +6,18 @@ import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Directory import * from Test__init import get_posix_object +from Testbase import TestPOSIXTool from .....common import * -def get_directory_object(posix=None): - if posix is None: - posix = get_posix_object() - return POSIXDirectory(posix.logger, posix.setup, posix.config) +class TestPOSIXDirectory(TestPOSIXTool): + test_obj = POSIXDirectory -class TestPOSIXDirectory(Bcfg2TestCase): @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.verify") - @patch("Bcfg2.Client.Tools.POSIX.Directory.POSIXDirectory._exists") + @patch("Bcfg2.Client.Tools.POSIX.Directory.%s._exists" % test_obj.__name__) def test_verify(self, mock_exists, mock_verify): entry = lxml.etree.Element("Path", name="/test", type="directory", perms='0644', owner='root', group='root') - ptool = get_directory_object() + ptool = self.get_obj() mock_exists.return_value = False self.assertFalse(ptool.verify(entry, [])) @@ -80,14 +78,15 @@ class TestPOSIXDirectory(Bcfg2TestCase): @patch("os.unlink") @patch("shutil.rmtree") @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.install") - @patch("Bcfg2.Client.Tools.POSIX.Directory.POSIXDirectory._exists") - @patch("Bcfg2.Client.Tools.POSIX.Directory.POSIXDirectory._makedirs") + @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_rmtree, mock_unlink): entry = lxml.etree.Element("Path", name="/test/foo/bar", type="directory", perms='0644', owner='root', group='root') - ptool = get_directory_object() + ptool = self.get_obj() def reset(): mock_exists.reset_mock() diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py index 0d267dcd4..d1f3ed14d 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestFile.py @@ -7,6 +7,7 @@ import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.File import * from Test__init import get_posix_object +from Testbase import TestPOSIXTool from .....common import * def get_file_object(posix=None): @@ -14,10 +15,12 @@ def get_file_object(posix=None): posix = get_posix_object() return POSIXFile(posix.logger, posix.setup, posix.config) -class TestPOSIXFile(Bcfg2TestCase): +class TestPOSIXFile(TestPOSIXTool): + test_obj = POSIXFile + def test_fully_specified(self): entry = lxml.etree.Element("Path", name="/test", type="file") - ptool = get_file_object() + ptool = self.get_obj() self.assertFalse(ptool.fully_specified(entry)) entry.set("empty", "true") @@ -28,7 +31,7 @@ class TestPOSIXFile(Bcfg2TestCase): self.assertTrue(ptool.fully_specified(entry)) def test_is_string(self): - ptool = get_file_object() + ptool = self.get_obj() for char in range(8) + range(14, 32): self.assertFalse(ptool._is_string("foo" + chr(char) + "bar", 'utf_8')) @@ -44,7 +47,7 @@ class TestPOSIXFile(Bcfg2TestCase): def test_get_data(self): orig_entry = lxml.etree.Element("Path", name="/test", type="file") setup = dict(encoding="ascii", ppath='/', max_copies=5) - ptool = get_file_object(posix=get_posix_object(setup=setup)) + ptool = self.get_obj(posix=get_posix_object(setup=setup)) entry = copy.deepcopy(orig_entry) entry.text = binascii.b2a_base64("test") @@ -65,7 +68,7 @@ class TestPOSIXFile(Bcfg2TestCase): self.assertEqual(ptool._get_data(entry), (ustr, False)) setup['encoding'] = "utf_8" - ptool = get_file_object(posix=get_posix_object(setup=setup)) + ptool = self.get_obj(posix=get_posix_object(setup=setup)) entry = copy.deepcopy(orig_entry) entry.text = ustr self.assertEqual(ptool._get_data(entry), @@ -73,14 +76,14 @@ class TestPOSIXFile(Bcfg2TestCase): @patch("__builtin__.open") @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.verify") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._exists") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._get_data") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._get_diffs") + @patch("Bcfg2.Client.Tools.POSIX.File.%s._exists" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.File.%s._get_data" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.File.%s._get_diffs" % test_obj.__name__) def test_verify(self, mock_get_diffs, mock_get_data, mock_exists, mock_verify, mock_open): entry = lxml.etree.Element("Path", name="/test", type="file") setup = dict(interactive=False, ppath='/', max_copies=5) - ptool = get_file_object(posix=get_posix_object(setup=setup)) + ptool = self.get_obj(posix=get_posix_object(setup=setup)) def reset(): mock_get_diffs.reset_mock() @@ -148,11 +151,11 @@ class TestPOSIXFile(Bcfg2TestCase): @patch("os.fdopen") @patch("tempfile.mkstemp") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._get_data") + @patch("Bcfg2.Client.Tools.POSIX.File.%s._get_data" % test_obj.__name__) def test_write_tmpfile(self, mock_get_data, mock_mkstemp, mock_fdopen): entry = lxml.etree.Element("Path", name="/test", type="file", perms='0644', owner='root', group='root') - ptool = get_file_object() + ptool = self.get_obj() newfile = "/foo/bar" def reset(): @@ -186,7 +189,7 @@ class TestPOSIXFile(Bcfg2TestCase): def test_rename_tmpfile(self, mock_unlink, mock_rename): entry = lxml.etree.Element("Path", name="/test", type="file", perms='0644', owner='root', group='root') - ptool = get_file_object() + ptool = self.get_obj() newfile = "/foo/bar" self.assertTrue(ptool._rename_tmpfile(newfile, entry)) @@ -208,8 +211,8 @@ class TestPOSIXFile(Bcfg2TestCase): mock_unlink.assert_called_with(newfile) @patch("__builtin__.open") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._diff") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._is_string") + @patch("Bcfg2.Client.Tools.POSIX.File.%s._diff" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.File.%s._is_string" % test_obj.__name__) def test__get_diffs(self, mock_is_string, mock_diff, mock_open): orig_entry = lxml.etree.Element("Path", name="/test", type="file", perms='0644', owner='root', @@ -217,7 +220,7 @@ class TestPOSIXFile(Bcfg2TestCase): orig_entry.text = "test" ondisk = "test2" setup = dict(encoding="ascii", ppath='/', max_copies=5) - ptool = get_file_object(posix=get_posix_object(setup=setup)) + ptool = self.get_obj(posix=get_posix_object(setup=setup)) def reset(): mock_is_string.reset_mock() @@ -300,15 +303,17 @@ class TestPOSIXFile(Bcfg2TestCase): @patch("os.path.exists") @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.install") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._makedirs") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._set_perms") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._write_tmpfile") - @patch("Bcfg2.Client.Tools.POSIX.File.POSIXFile._rename_tmpfile") + @patch("Bcfg2.Client.Tools.POSIX.File.%s._makedirs" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.File.%s._set_perms" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.File.%s._write_tmpfile" % + test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.File.%s._rename_tmpfile" % + test_obj.__name__) def test_install(self, mock_rename, mock_write, mock_set_perms, mock_makedirs, mock_install, mock_exists): entry = lxml.etree.Element("Path", name="/test", type="file", perms='0644', owner='root', group='root') - ptool = get_file_object() + ptool = self.get_obj() def reset(): mock_rename.reset_mock() @@ -385,9 +390,8 @@ class TestPOSIXFile(Bcfg2TestCase): mock_rename.assert_called_with(newfile, entry) mock_install.assert_called_with(ptool, entry) - @unittest.skip def test_diff(self): - ptool = get_file_object() + ptool = self.get_obj() content1 = "line1\nline2" content2 = "line3" rv = ["line1", "line2", "line3"] diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestHardlink.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestHardlink.py index 2f1b0c920..663c98af2 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestHardlink.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestHardlink.py @@ -5,20 +5,18 @@ import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Hardlink import * from Test__init import get_posix_object +from Testbase import TestPOSIXTool from .....common import * -def get_hardlink_object(posix=None): - if posix is None: - posix = get_posix_object() - return POSIXHardlink(posix.logger, posix.setup, posix.config) +class TestPOSIXHardlink(TestPOSIXTool): + test_obj = POSIXHardlink -class TestPOSIXHardlink(Bcfg2TestCase): @patch("os.path.samefile") @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.verify") def test_verify(self, mock_verify, mock_samefile): entry = lxml.etree.Element("Path", name="/test", type="hardlink", to="/dest") - ptool = get_hardlink_object() + ptool = self.get_obj() mock_samefile.return_value = True mock_verify.return_value = False @@ -52,11 +50,11 @@ class TestPOSIXHardlink(Bcfg2TestCase): @patch("os.link") @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.install") - @patch("Bcfg2.Client.Tools.POSIX.Hardlink.POSIXHardlink._exists") + @patch("Bcfg2.Client.Tools.POSIX.Hardlink.%s._exists" % test_obj.__name__) def test_install(self, mock_exists, mock_install, mock_link): entry = lxml.etree.Element("Path", name="/test", type="hardlink", to="/dest") - ptool = get_hardlink_object() + ptool = self.get_obj() mock_exists.return_value = False mock_install.return_value = True diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestNonexistent.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestNonexistent.py index 9ac23921c..8d959a15f 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestNonexistent.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestNonexistent.py @@ -5,18 +5,16 @@ import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Nonexistent import * from Test__init import get_config, get_posix_object +from Testbase import TestPOSIXTool from .....common import * -def get_nonexistent_object(posix=None): - if posix is None: - posix = get_posix_object() - return POSIXNonexistent(posix.logger, posix.setup, posix.config) +class TestPOSIXNonexistent(TestPOSIXTool): + test_obj = POSIXNonexistent -class TestPOSIXNonexistent(Bcfg2TestCase): @patch("os.path.lexists") def test_verify(self, mock_lexists): entry = lxml.etree.Element("Path", name="/test", type="nonexistent") - ptool = get_nonexistent_object() + ptool = self.get_obj() for val in [True, False]: mock_lexists.reset_mock() @@ -29,7 +27,7 @@ class TestPOSIXNonexistent(Bcfg2TestCase): @patch("shutil.rmtree") def test_install(self, mock_rmtree, mock_remove, mock_rmdir): entry = lxml.etree.Element("Path", name="/test", type="nonexistent") - ptool = get_nonexistent_object() + ptool = self.get_obj() with patch("os.path.isdir") as mock_isdir: def reset(): @@ -70,7 +68,7 @@ class TestPOSIXNonexistent(Bcfg2TestCase): reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="nonexistent") - ptool = get_nonexistent_object(posix=get_posix_object(config=get_config([child_entry]))) + ptool = self.get_obj(posix=get_posix_object(config=get_config([child_entry]))) mock_rmtree.side_effect = None self.assertTrue(ptool.install(entry)) mock_rmtree.assert_called_with(entry.get("name")) @@ -78,6 +76,6 @@ class TestPOSIXNonexistent(Bcfg2TestCase): reset() child_entry = lxml.etree.Element("Path", name="/test/foo", type="file") - ptool = get_nonexistent_object(posix=get_posix_object(config=get_config([child_entry]))) + ptool = self.get_obj(posix=get_posix_object(config=get_config([child_entry]))) mock_rmtree.side_effect = None self.assertFalse(ptool.install(entry)) diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestPermissions.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestPermissions.py index f1746e34a..9d8130658 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestPermissions.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestPermissions.py @@ -4,13 +4,8 @@ import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Permissions import * from Test__init import get_posix_object +from Testbase import TestPOSIXTool from .....common import * -def get_permissions_object(posix=None): - if posix is None: - posix = get_posix_object() - return POSIXPermissions(posix.logger, posix.setup, posix.config) - -class TestPOSIXPermissions(Bcfg2TestCase): - # nothing to test! - pass +class TestPOSIXPermissions(TestPOSIXTool): + test_obj = POSIXPermissions diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py index d9a2717dd..03504ca61 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py @@ -5,20 +5,18 @@ import lxml.etree from mock import Mock, MagicMock, patch from Bcfg2.Client.Tools.POSIX.Symlink import * from Test__init import get_posix_object +from Testbase import TestPOSIXTool from .....common import * -def get_symlink_object(posix=None): - if posix is None: - posix = get_posix_object() - return POSIXSymlink(posix.logger, posix.setup, posix.config) +class TestPOSIXSymlink(TestPOSIXTool): + test_obj = POSIXSymlink -class TestPOSIXSymlink(Bcfg2TestCase): @patch("os.readlink") @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.verify") def test_verify(self, mock_verify, mock_readlink): entry = lxml.etree.Element("Path", name="/test", type="symlink", to="/dest") - ptool = get_symlink_object() + ptool = self.get_obj() mock_readlink.return_value = entry.get("to") mock_verify.return_value = False @@ -48,11 +46,11 @@ class TestPOSIXSymlink(Bcfg2TestCase): @patch("os.symlink") @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.install") - @patch("Bcfg2.Client.Tools.POSIX.Symlink.POSIXSymlink._exists") + @patch("Bcfg2.Client.Tools.POSIX.Symlink.%s._exists" % test_obj.__name__) def test_install(self, mock_exists, mock_install, mock_symlink): entry = lxml.etree.Element("Path", name="/test", type="symlink", to="/dest") - ptool = get_symlink_object() + ptool = self.get_obj() mock_exists.return_value = False mock_install.return_value = True diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py index 7bc26e03d..4fbc2485f 100644 --- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py +++ b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py @@ -21,16 +21,13 @@ try: except ImportError: has_acls = False -def get_posixtool_object(posix=None): - if posix is None: - posix = get_posix_object() - return POSIXTool(posix.logger, posix.setup, posix.config) - class TestPOSIXTool(Bcfg2TestCase): test_obj = POSIXTool def get_obj(self, posix=None): - return get_posixtool_object(posix) + if posix is None: + posix = get_posix_object() + return self.test_obj(posix.logger, posix.setup, posix.config) def test_fully_specified(self): # fully_specified should do no checking on the abstract @@ -38,7 +35,8 @@ class TestPOSIXTool(Bcfg2TestCase): ptool = self.get_obj() self.assertTrue(ptool.fully_specified(Mock())) - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._verify_metadata") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._verify_metadata" % + test_obj.__name__) def test_verify(self, mock_verify): entry = lxml.etree.Element("Path", name="/test", type="file") ptool = self.get_obj() @@ -68,7 +66,7 @@ class TestPOSIXTool(Bcfg2TestCase): for p in dirs + files]) self.assertItemsEqual(mock_verify.call_args_list, all_verifies) - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._set_perms") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._set_perms" % test_obj.__name__) def test_install(self, mock_set_perms): entry = lxml.etree.Element("Path", name="/test", type="file") ptool = self.get_obj() @@ -166,10 +164,13 @@ class TestPOSIXTool(Bcfg2TestCase): @patch("os.chown") @patch("os.chmod") @patch("os.utime") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._norm_entry_uid") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._norm_entry_gid") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._set_acls") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._set_secontext") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._norm_entry_uid" % + test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.base.%s._norm_entry_gid" % + test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.base.%s._set_acls" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.base.%s._set_secontext" % + test_obj.__name__) def test_set_perms(self, mock_set_secontext, mock_set_acls, mock_norm_gid, mock_norm_uid, mock_utime, mock_chmod, mock_chown): ptool = self.get_obj() @@ -285,9 +286,10 @@ class TestPOSIXTool(Bcfg2TestCase): mock_set_acls.assert_called_with(entry, path=entry.get("name")) @unittest.skipUnless(has_acls, "ACLS not found, skipping") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._norm_uid") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._norm_gid") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._list_entry_acls") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._norm_uid" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.base.%s._norm_gid" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.base.%s._list_entry_acls" % + test_obj.__name__) def test_set_acls(self, mock_list_entry_acls, mock_norm_gid, mock_norm_uid): entry = lxml.etree.Element("Path", name="/etc/foo", type="file") ptool = self.get_obj() @@ -477,7 +479,7 @@ class TestPOSIXTool(Bcfg2TestCase): self.assertEqual(5, ptool._norm_gid("group")) mock_getgrnam.assert_called_with("group") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._norm_gid") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._norm_gid" % test_obj.__name__) def test_norm_entry_gid(self, mock_norm_gid): entry = lxml.etree.Element("Path", name="/test", type="file", group="group", owner="user") @@ -503,7 +505,7 @@ class TestPOSIXTool(Bcfg2TestCase): self.assertEqual(5, ptool._norm_uid("user")) mock_getpwnam.assert_called_with("user") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._norm_uid") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._norm_uid" % test_obj.__name__) def test_norm_entry_uid(self, mock_norm_uid): entry = lxml.etree.Element("Path", name="/test", type="file", group="group", owner="user") @@ -591,7 +593,8 @@ class TestPOSIXTool(Bcfg2TestCase): Bcfg2.Client.Tools.POSIX.base.has_acls = state mock_getfilecon.assert_called_with(path) - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._list_file_acls") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._list_file_acls" % + test_obj.__name__) @unittest.skipUnless(has_acls, "ACLS not found, skipping") def test__gather_data_acls(self, mock_list_file_acls): acls = {("default", posix1e.ACL_USER, "testuser"): "rwx", @@ -608,10 +611,12 @@ class TestPOSIXTool(Bcfg2TestCase): Bcfg2.Client.Tools.POSIX.base.has_selinux = state mock_list_file_acls.assert_called_with(path) - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._verify_acls") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._gather_data") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._norm_entry_uid") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._norm_entry_gid") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._verify_acls" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.base.%s._gather_data" % test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.base.%s._norm_entry_uid" % + test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.base.%s._norm_entry_gid" % + test_obj.__name__) def test_verify_metadata(self, mock_norm_gid, mock_norm_uid, mock_gather_data, mock_verify_acls): entry = lxml.etree.Element("Path", name="/test", type="file", @@ -872,8 +877,10 @@ class TestPOSIXTool(Bcfg2TestCase): [call(file=path), call(filedef=path)]) @unittest.skipUnless(has_acls, "ACLS not found, skipping") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._list_file_acls") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._list_entry_acls") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._list_file_acls" % + test_obj.__name__) + @patch("Bcfg2.Client.Tools.POSIX.base.%s._list_entry_acls" % + test_obj.__name__) def test_verify_acls(self, mock_list_entry_acls, mock_list_file_acls): entry = lxml.etree.Element("Path", name="/test", type="file") ptool = self.get_obj() @@ -924,7 +931,7 @@ class TestPOSIXTool(Bcfg2TestCase): @patch("os.makedirs") @patch("os.path.exists") - @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool._set_perms") + @patch("Bcfg2.Client.Tools.POSIX.base.%s._set_perms" % test_obj.__name__) def test_makedirs(self, mock_set_perms, mock_exists, mock_makedirs): entry = lxml.etree.Element("Path", name="/test/foo/bar", type="directory") -- cgit v1.2.3-1-g7c22