summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-01-26 16:59:43 +0000
committerGerrit Code Review <review@openstack.org>2013-01-26 16:59:43 +0000
commite1ce3878b951ea491548c129453bb84a77205649 (patch)
treee1cf871abdccf7a4771f782793be0605bf390db5 /nova/tests
parentc9af3eed35eb56e154235119fa130e8ba9e8d8fd (diff)
parentac8a9d80d035f19c251935491d4bf5672f5e3b6b (diff)
Merge "Baremetal/utils should not log certain exceptions"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/baremetal/test_utils.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/nova/tests/baremetal/test_utils.py b/nova/tests/baremetal/test_utils.py
index 827b1fcaf..2615a26cb 100644
--- a/nova/tests/baremetal/test_utils.py
+++ b/nova/tests/baremetal/test_utils.py
@@ -20,6 +20,9 @@
import mox
+import errno
+import os
+
from nova import exception
from nova import test
from nova.virt.baremetal import utils
@@ -32,3 +35,36 @@ class BareMetalUtilsTestCase(test.TestCase):
self.assertEqual(len(s), 10)
s = utils.random_alnum(100)
self.assertEqual(len(s), 100)
+
+ def test_unlink(self):
+ self.mox.StubOutWithMock(os, "unlink")
+ os.unlink("/fake/path")
+
+ self.mox.ReplayAll()
+ utils.unlink_without_raise("/fake/path")
+ self.mox.VerifyAll()
+
+ def test_unlink_ENOENT(self):
+ self.mox.StubOutWithMock(os, "unlink")
+ os.unlink("/fake/path").AndRaise(OSError(errno.ENOENT))
+
+ self.mox.ReplayAll()
+ utils.unlink_without_raise("/fake/path")
+ self.mox.VerifyAll()
+
+ def test_create_link(self):
+ self.mox.StubOutWithMock(os, "symlink")
+ os.symlink("/fake/source", "/fake/link")
+
+ self.mox.ReplayAll()
+ utils.create_link_without_raise("/fake/source", "/fake/link")
+ self.mox.VerifyAll()
+
+ def test_create_link_EEXIST(self):
+ self.mox.StubOutWithMock(os, "symlink")
+ os.symlink("/fake/source", "/fake/link").AndRaise(
+ OSError(errno.EEXIST))
+
+ self.mox.ReplayAll()
+ utils.create_link_without_raise("/fake/source", "/fake/link")
+ self.mox.VerifyAll()