Fix imports in openstack compute tests

This makes imports in a number of tests consistent. There were also
various places where files were being stubbed out that werent explicitly
imported. This patch fixes those as well. It also moves compute api
stubbing to stub the actual compute.api.API class instead of
compute.API. Includes a rewrite of test_createserverext to stub the
create method instead of doing a bunch of odd setup with a mock
compute api.

Change-Id: Id8ebb2f65228fafeac69c7ab635ff8909b79c449
This commit is contained in:
Vishvananda Ishaya
2012-10-11 11:56:04 -07:00
parent 0df84e9bba
commit 3337da9dfd
9 changed files with 169 additions and 186 deletions

View File

@@ -15,7 +15,7 @@
import webob
from nova import compute
from nova.compute import api as compute_api
from nova import exception
from nova.openstack.common import jsonutils
from nova import test
@@ -47,9 +47,9 @@ class ConsoleOutputExtensionTest(test.TestCase):
def setUp(self):
super(ConsoleOutputExtensionTest, self).setUp()
self.stubs.Set(compute.API, 'get_console_output',
self.stubs.Set(compute_api.API, 'get_console_output',
fake_get_console_output)
self.stubs.Set(compute.API, 'get', fake_get)
self.stubs.Set(compute_api.API, 'get', fake_get)
def test_get_text_console_instance_action(self):
body = {'os-getConsoleOutput': {}}
@@ -96,7 +96,7 @@ class ConsoleOutputExtensionTest(test.TestCase):
self.assertEqual(res.status_int, 400)
def test_get_text_console_no_instance(self):
self.stubs.Set(compute.API, 'get', fake_get_not_found)
self.stubs.Set(compute_api.API, 'get', fake_get_not_found)
body = {'os-getConsoleOutput': {}}
req = webob.Request.blank('/v2/fake/servers/1/action')
req.method = "POST"
@@ -107,7 +107,9 @@ class ConsoleOutputExtensionTest(test.TestCase):
self.assertEqual(res.status_int, 404)
def test_get_text_console_no_instance_on_get_output(self):
self.stubs.Set(compute.API, 'get_console_output', fake_get_not_found)
self.stubs.Set(compute_api.API,
'get_console_output',
fake_get_not_found)
body = {'os-getConsoleOutput': {}}
req = webob.Request.blank('/v2/fake/servers/1/action')
req.method = "POST"