summaryrefslogtreecommitdiffstats
path: root/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-04 09:52:57 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2012-09-04 09:52:57 -0400
commitd9d4391b211c0a13cbfeadc9fa63e5bdeba9d2f6 (patch)
treecf59b7bcef389ca76f09c7f804db9d893b918e3b /testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py
parent6697481f7bed646b4c66c54c9a46d11aa075af4a (diff)
downloadbcfg2-d9d4391b211c0a13cbfeadc9fa63e5bdeba9d2f6.tar.gz
bcfg2-d9d4391b211c0a13cbfeadc9fa63e5bdeba9d2f6.tar.bz2
bcfg2-d9d4391b211c0a13cbfeadc9fa63e5bdeba9d2f6.zip
reorganized testsuite to allow tests on stuff outside of src
Diffstat (limited to 'testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py')
-rw-r--r--testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py99
1 files changed, 0 insertions, 99 deletions
diff --git a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py b/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py
deleted file mode 100644
index b02f7b3c3..000000000
--- a/testsuite/Testlib/TestClient/TestTools/TestPOSIX/TestSymlink.py
+++ /dev/null
@@ -1,99 +0,0 @@
-import os
-import sys
-import copy
-import lxml.etree
-from mock import Mock, MagicMock, patch
-from Bcfg2.Client.Tools.POSIX.Symlink import *
-
-# add all parent testsuite directories to sys.path to allow (most)
-# relative imports in python 2.4
-path = os.path.dirname(__file__)
-while path != "/":
- if os.path.basename(path).lower().startswith("test"):
- sys.path.append(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 XI_NAMESPACE, XI, inPy3k, call, builtins, u, can_skip, \
- skip, skipIf, skipUnless, Bcfg2TestCase, DBModelTestCase, syncdb, \
- patchIf, datastore
-
-class TestPOSIXSymlink(TestPOSIXTool):
- test_obj = POSIXSymlink
-
- @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 = self.get_obj()
-
- mock_readlink.return_value = entry.get("to")
- mock_verify.return_value = False
- self.assertFalse(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, []))
- 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):
- 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)
- mock_symlink.assert_called_with(entry.get("to"), entry.get("name"))
- mock_install.assert_called_with(ptool, entry)