summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorSalvatore Orlando <salvatore.orlando@eu.citrix.com>2011-03-24 02:01:46 +0000
committerSalvatore Orlando <salvatore.orlando@eu.citrix.com>2011-03-24 02:01:46 +0000
commit52bd70d500e7e82acea55c8d23c3fd1d66555cc0 (patch)
tree89018a7985a12d364d7f537475ed10f314e1fa06 /nova/tests
parentb8c943bc5115e310f1263e275b707d142a372fdb (diff)
Addressing Rick Clark's comments.
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/db/fakes.py4
-rw-r--r--nova/tests/fake_utils.py16
-rw-r--r--nova/tests/test_xenapi.py4
-rw-r--r--nova/tests/xenapi/stubs.py4
4 files changed, 13 insertions, 15 deletions
diff --git a/nova/tests/db/fakes.py b/nova/tests/db/fakes.py
index 62c7cd794..c46b75aa2 100644
--- a/nova/tests/db/fakes.py
+++ b/nova/tests/db/fakes.py
@@ -99,9 +99,7 @@ def stub_out_db_instance_api(stubs, injected=True):
return FakeModel(network_fields)
def fake_network_get_all_by_instance(context, instance_id):
- l = []
- l.append(FakeModel(network_fields))
- return l
+ return [FakeModel(network_fields)]
def fake_instance_get_fixed_address(context, instance_id):
return FakeModel(fixed_ip_fields).address
diff --git a/nova/tests/fake_utils.py b/nova/tests/fake_utils.py
index 8982f50be..823c775cb 100644
--- a/nova/tests/fake_utils.py
+++ b/nova/tests/fake_utils.py
@@ -33,7 +33,6 @@ _fake_execute_log = []
def fake_execute_get_log():
- global _fake_execute_log
return _fake_execute_log
@@ -55,7 +54,7 @@ def fake_execute_default_reply_handler(*ignore_args, **ignore_kwargs):
return '', ''
-def fake_execute(*cmd, **kwargs):
+def fake_execute(*cmd_parts, **kwargs):
"""This function stubs out execute, optionally executing
a preconfigued function to return expected data
"""
@@ -64,8 +63,7 @@ def fake_execute(*cmd, **kwargs):
process_input = kwargs.get('process_input', None)
addl_env = kwargs.get('addl_env', None)
check_exit_code = kwargs.get('check_exit_code', 0)
- cmd_map = map(str, cmd)
- cmd_str = ' '.join(cmd_map)
+ cmd_str = ' '.join(str(part) for part in cmd_parts)
LOG.debug(_("Faking execution of cmd (subprocess): %s"), cmd_str)
_fake_execute_log.append(cmd_str)
@@ -78,13 +76,13 @@ def fake_execute(*cmd, **kwargs):
LOG.debug(_('Faked command matched %s') % fake_replier[0])
break
- if isinstance(reply_handler, types.StringTypes):
+ if isinstance(reply_handler, basestring):
# If the reply handler is a string, return it as stdout
reply = reply_handler, ''
else:
try:
# Alternative is a function, so call it
- reply = reply_handler(cmd,
+ reply = reply_handler(cmd_parts,
process_input=process_input,
addl_env=addl_env,
check_exit_code=check_exit_code)
@@ -92,8 +90,10 @@ def fake_execute(*cmd, **kwargs):
LOG.debug(_('Faked command raised an exception %s' % str(e)))
raise
- LOG.debug(_("Reply to faked command is stdout='%(0)s' stderr='%(1)s'") %
- {'0': reply[0], '1': reply[1]})
+ stdout = reply[0]
+ stderr = reply[1]
+ LOG.debug(_("Reply to faked command is stdout='%(stdout)s' "
+ "stderr='%(stderr)s'") % locals())
# Replicate the sleep call in the real function
greenthread.sleep(0)
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py
index b22163e9b..d31fa27ac 100644
--- a/nova/tests/test_xenapi.py
+++ b/nova/tests/test_xenapi.py
@@ -76,7 +76,6 @@ class XenAPIVolumeTestCase(test.TestCase):
FLAGS.xenapi_connection_url = 'test_url'
FLAGS.xenapi_connection_password = 'test_pass'
db_fakes.stub_out_db_instance_api(self.stubs)
- #db_fakes.stub_out_db_network_api(self.stubs)
stubs.stub_out_get_target(self.stubs)
xenapi_fake.reset()
self.values = {'id': 1,
@@ -333,7 +332,8 @@ class XenAPIVMTestCase(test.TestCase):
self.assertEquals(self.vm['HVM_boot_policy'], '')
def _test_spawn(self, image_id, kernel_id, ramdisk_id,
- instance_type="m1.large", os_type="linux", check_injection=False):
+ instance_type="m1.large", os_type="linux",
+ check_injection=False):
stubs.stubout_loopingcall_start(self.stubs)
values = {'id': 1,
'project_id': self.project.id,
diff --git a/nova/tests/xenapi/stubs.py b/nova/tests/xenapi/stubs.py
index d278934c6..0f559b7f9 100644
--- a/nova/tests/xenapi/stubs.py
+++ b/nova/tests/xenapi/stubs.py
@@ -139,9 +139,9 @@ def stubout_is_vdi_pv(stubs):
def stubout_loopingcall_start(stubs):
- def f_1(self, interval, now=True):
+ def fake_start(self, interval, now=True):
self.f(*self.args, **self.kw)
- stubs.Set(utils.LoopingCall, 'start', f_1)
+ stubs.Set(utils.LoopingCall, 'start', fake_start)
class FakeSessionForVMTests(fake.SessionBase):