From 20cf8f21bc7043de0070644cfb434ce77e24d28c Mon Sep 17 00:00:00 2001 From: "Chris St. Pierre" Date: Mon, 22 Oct 2012 08:23:49 -0400 Subject: fixed some POSIX unit tests --- .../Testlib/TestClient/TestTools/TestPOSIX/Testbase.py | 16 ++++++++++++---- .../Testlib/TestServer/TestPlugin/Testinterfaces.py | 10 ++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py b/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py index 332722074..0e0234719 100644 --- a/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py +++ b/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/Testbase.py @@ -587,11 +587,15 @@ class TestPOSIXTool(Bcfg2TestCase): def inner(mock_getfilecon, mock_stat): mock_getfilecon.return_value = [len(context) + 1, context] mock_stat.return_value = MagicMock() + mock_stat.return_value.__getitem__.return_value = MagicMock() # disable acls for this call and test them separately - state = Bcfg2.Client.Tools.POSIX.base.HAS_ACLS + state = (Bcfg2.Client.Tools.POSIX.base.HAS_ACLS, + Bcfg2.Client.Tools.POSIX.base.HAS_SELINUX) Bcfg2.Client.Tools.POSIX.base.HAS_ACLS = False + Bcfg2.Client.Tools.POSIX.base.HAS_SELINUX = True self.assertEqual(self.ptool._gather_data(path)[4], 'root_t') - Bcfg2.Client.Tools.POSIX.base.HAS_ACLS = state + Bcfg2.Client.Tools.POSIX.base.HAS_ACLS, \ + Bcfg2.Client.Tools.POSIX.base.HAS_SELINUX = state mock_getfilecon.assert_called_with(path) inner() @@ -606,11 +610,15 @@ class TestPOSIXTool(Bcfg2TestCase): mock_list_file_acls.return_value = acls path = '/test' mock_stat.return_value = MagicMock() + mock_stat.return_value.__getitem__.return_value = MagicMock() # disable selinux for this call and test it separately - state = Bcfg2.Client.Tools.POSIX.base.HAS_SELINUX + state = (Bcfg2.Client.Tools.POSIX.base.HAS_ACLS, + Bcfg2.Client.Tools.POSIX.base.HAS_SELINUX) + Bcfg2.Client.Tools.POSIX.base.HAS_ACLS = True Bcfg2.Client.Tools.POSIX.base.HAS_SELINUX = False self.assertItemsEqual(self.ptool._gather_data(path)[5], acls) - Bcfg2.Client.Tools.POSIX.base.HAS_SELINUX = state + Bcfg2.Client.Tools.POSIX.base.HAS_ACLS, \ + Bcfg2.Client.Tools.POSIX.base.HAS_SELINUX = state mock_list_file_acls.assert_called_with(path) @patchIf(HAS_SELINUX, "selinux.matchpathcon") diff --git a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py index ace509057..9a064663e 100644 --- a/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py +++ b/testsuite/Testsrc/Testlib/TestServer/TestPlugin/Testinterfaces.py @@ -326,11 +326,13 @@ class TestGoalValidator(Bcfg2TestCase): gv.validate_goals, None, None) -class TestVersion(Bcfg2TestCase): +class TestVersion(TestPlugin): test_obj = Version - - def get_obj(self): - return self.test_obj(datastore) + + def get_obj(self, core=None): + if core is None: + core = Mock() + return self.test_obj(core, datastore) def test_get_revision(self): d = self.get_obj() -- cgit v1.2.3-1-g7c22