summaryrefslogtreecommitdiffstats
path: root/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.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/TestSymlink.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/TestSymlink.py')
-rw-r--r--testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py70
1 files changed, 9 insertions, 61 deletions
diff --git a/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py b/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py
index 4c8ddfa3f..78bfd716f 100644
--- a/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py
+++ b/testsuite/Testsrc/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py
@@ -1,6 +1,5 @@
import os
import sys
-import copy
import lxml.etree
from mock import Mock, MagicMock, patch
from Bcfg2.Client.Tools.POSIX.Symlink import *
@@ -14,84 +13,33 @@ 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 Testbase import TestPOSIXLinkTool
from common import *
-class TestPOSIXSymlink(TestPOSIXTool):
+
+class TestPOSIXSymlink(TestPOSIXLinkTool):
test_obj = POSIXSymlink
@patch("os.readlink")
- @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.verify")
- def test_verify(self, mock_verify, mock_readlink):
+ def test__verify(self, mock_readlink):
entry = lxml.etree.Element("Path", name="/test", type="symlink",
to="/dest")
ptool = self.get_obj()
mock_readlink.return_value = entry.get("to")
- mock_verify.return_value = False
- self.assertFalse(ptool.verify(entry, []))
+ self.assertTrue(ptool._verify(entry))
mock_readlink.assert_called_with(entry.get("name"))
- mock_verify.assert_called_with(ptool, entry, [])
mock_readlink.reset_mock()
- mock_verify.reset_mock()
- mock_verify.return_value = True
- self.assertTrue(ptool.verify(entry, []))
- mock_readlink.assert_called_with(entry.get("name"))
- mock_verify.assert_called_with(ptool, entry, [])
-
- mock_readlink.reset_mock()
- mock_verify.reset_mock()
mock_readlink.return_value = "/bogus"
- self.assertFalse(ptool.verify(entry, []))
- mock_readlink.assert_called_with(entry.get("name"))
- mock_verify.assert_called_with(ptool, entry, [])
-
- # relative symlink
- mock_readlink.reset_mock()
- mock_verify.reset_mock()
- entry = lxml.etree.Element("Path", name="/test", type="symlink",
- to="dest")
- mock_readlink.return_value = entry.get("to")
- self.assertTrue(ptool.verify(entry, []))
- mock_readlink.assert_called_with(entry.get("name"))
- mock_verify.assert_called_with(ptool, entry, [])
-
- mock_readlink.reset_mock()
- mock_verify.reset_mock()
- mock_readlink.side_effect = OSError
- self.assertFalse(ptool.verify(entry, []))
+ self.assertFalse(ptool._verify(entry))
mock_readlink.assert_called_with(entry.get("name"))
@patch("os.symlink")
- @patch("Bcfg2.Client.Tools.POSIX.base.POSIXTool.install")
- @patch("Bcfg2.Client.Tools.POSIX.Symlink.%s._exists" % test_obj.__name__)
- def test_install(self, mock_exists, mock_install, mock_symlink):
+ def test__link(self, mock_symlink):
entry = lxml.etree.Element("Path", name="/test", type="symlink",
to="/dest")
ptool = self.get_obj()
-
- mock_exists.return_value = False
- mock_install.return_value = True
- self.assertTrue(ptool.install(entry))
- mock_exists.assert_called_with(entry, remove=True)
- mock_symlink.assert_called_with(entry.get("to"), entry.get("name"))
- mock_install.assert_called_with(ptool, entry)
-
- # relative symlink
- entry = lxml.etree.Element("Path", name="/test", type="symlink",
- to="dest")
- self.assertTrue(ptool.install(entry))
- mock_exists.assert_called_with(entry, remove=True)
- mock_symlink.assert_called_with(entry.get("to"), entry.get("name"))
- mock_install.assert_called_with(ptool, entry)
-
- mock_symlink.reset_mock()
- mock_exists.reset_mock()
- mock_install.reset_mock()
- mock_symlink.side_effect = OSError
- self.assertFalse(ptool.install(entry))
- mock_exists.assert_called_with(entry, remove=True)
+ self.assertEqual(ptool._link(entry),
+ mock_symlink.return_value)
mock_symlink.assert_called_with(entry.get("to"), entry.get("name"))
- mock_install.assert_called_with(ptool, entry)