summaryrefslogtreecommitdiff
path: root/tests/unittests/test_datasource/test_opennebula.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unittests/test_datasource/test_opennebula.py')
-rw-r--r--tests/unittests/test_datasource/test_opennebula.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/unittests/test_datasource/test_opennebula.py b/tests/unittests/test_datasource/test_opennebula.py
index f2457657..9c7a644a 100644
--- a/tests/unittests/test_datasource/test_opennebula.py
+++ b/tests/unittests/test_datasource/test_opennebula.py
@@ -37,6 +37,7 @@ CMD_IP_OUT = '''\
class TestOpenNebulaDataSource(MockerTestCase):
+ parsed_user = None
def setUp(self):
super(TestOpenNebulaDataSource, self).setUp()
@@ -48,6 +49,18 @@ class TestOpenNebulaDataSource(MockerTestCase):
self.seed_dir = os.path.join(self.paths.seed_dir, "opennebula")
self.sys_cfg = {'datasource': {'OpenNebula': {'dsmode': 'local'}}}
+ # we don't want 'sudo' called in tests. so we patch switch_user_cmd
+ def my_switch_user_cmd(user):
+ self.parsed_user = user
+ return []
+
+ self.switch_user_cmd_real = ds.switch_user_cmd
+ ds.switch_user_cmd = my_switch_user_cmd
+
+ def tearDown(self):
+ ds.switch_user_cmd = self.switch_user_cmd_real
+ super(TestOpenNebulaDataSource, self).tearDown()
+
def test_get_data_non_contextdisk(self):
try:
# dont' try to lookup for CDs
@@ -96,9 +109,9 @@ class TestOpenNebulaDataSource(MockerTestCase):
util.find_devs_with = orig_find_devs_with
def test_get_data(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_context_dir(self.seed_dir, {'KEY1': 'val1'})
dsrc = self.ds(sys_cfg=self.sys_cfg, distro=None, paths=self.paths)