summaryrefslogtreecommitdiff
path: root/tests/unittests/test_datasource/test_opennebula.py
diff options
context:
space:
mode:
authorVlastimil Holer <vlastimil.holer@gmail.com>2013-09-11 01:14:11 +0200
committerVlastimil Holer <vlastimil.holer@gmail.com>2013-09-11 01:14:11 +0200
commit8020ff584b37e3786fb9575003cfc543a16344ce (patch)
tree30aa4778ae90e61f0b16d14747f2ba4a58befc96 /tests/unittests/test_datasource/test_opennebula.py
parent1d0c83bd64e3ff24d9b4e722f7aa1a9e108fb943 (diff)
downloadvyos-cloud-init-8020ff584b37e3786fb9575003cfc543a16344ce.tar.gz
vyos-cloud-init-8020ff584b37e3786fb9575003cfc543a16344ce.zip
All fake util.find_devs_with set before try-finally section
Diffstat (limited to 'tests/unittests/test_datasource/test_opennebula.py')
-rw-r--r--tests/unittests/test_datasource/test_opennebula.py15
1 files changed, 6 insertions, 9 deletions
diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py
index 9c7a644a..45256a86 100644
--- a/tests/unittests/test_datasource/test_opennebula.py
+++ b/tests/unittests/test_datasource/test_opennebula.py
@@ -62,11 +62,10 @@ class TestOpenNebulaDataSource(MockerTestCase):
super(TestOpenNebulaDataSource, self).tearDown()
def test_get_data_non_contextdisk(self):
+ orig_find_devs_with = util.find_devs_with
try:
# dont' try to lookup for CDs
- orig_find_devs_with = util.find_devs_with
util.find_devs_with = lambda n: []
-
dsrc = self.ds(sys_cfg=self.sys_cfg, distro=None, paths=self.paths)
ret = dsrc.get_data()
self.assertFalse(ret)
@@ -74,11 +73,10 @@ class TestOpenNebulaDataSource(MockerTestCase):
util.find_devs_with = orig_find_devs_with
def test_get_data_broken_contextdisk(self):
+ orig_find_devs_with = util.find_devs_with
try:
# dont' try to lookup for CDs
- orig_find_devs_with = util.find_devs_with
util.find_devs_with = lambda n: []
-
populate_dir(self.seed_dir, {'context.sh': INVALID_CONTEXT})
dsrc = self.ds(sys_cfg=self.sys_cfg, distro=None, paths=self.paths)
self.assertRaises(ds.BrokenContextDiskDir, dsrc.get_data)
@@ -86,11 +84,8 @@ class TestOpenNebulaDataSource(MockerTestCase):
util.find_devs_with = orig_find_devs_with
def test_get_data_invalid_identity(self):
+ orig_find_devs_with = util.find_devs_with
try:
- # dont' try to lookup for CDs
- orig_find_devs_with = util.find_devs_with
- util.find_devs_with = lambda n: []
-
# generate non-existing system user name
sys_cfg = self.sys_cfg
invalid_user = 'invalid'
@@ -102,6 +97,8 @@ class TestOpenNebulaDataSource(MockerTestCase):
sys_cfg['datasource']['OpenNebula']['parseuser'] = \
invalid_user
+ # dont' try to lookup for CDs
+ util.find_devs_with = lambda n: []
populate_context_dir(self.seed_dir, {'KEY1': 'val1'})
dsrc = self.ds(sys_cfg=sys_cfg, distro=None, paths=self.paths)
self.assertRaises(ds.BrokenContextDiskDir, dsrc.get_data)
@@ -200,8 +197,8 @@ class TestOpenNebulaDataSource(MockerTestCase):
"TYPE=iso9660": ["/dev/vdb"],
}.get(criteria, [])
+ orig_find_devs_with = util.find_devs_with
try:
- orig_find_devs_with = util.find_devs_with
util.find_devs_with = my_devs_with
self.assertEqual(["/dev/sdb", "/dev/sr0", "/dev/vdb"],
ds.find_candidate_devs())