summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorNaveed Massjouni <naveedm9@gmail.com>2011-05-20 04:14:02 -0400
committerNaveed Massjouni <naveedm9@gmail.com>2011-05-20 04:14:02 -0400
commite16b2d22dc4e6e24c3bf5150a0830661933aad29 (patch)
treef2ccb5b54289c237dc4a15ddb247782f26941b93 /nova/tests
parenta1869741689817168c75046f2f81ee9761956cbc (diff)
Fixed some tests.
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/api/openstack/test_servers.py14
-rw-r--r--nova/tests/integrated/integrated_helpers.py7
-rw-r--r--nova/tests/test_quota.py8
3 files changed, 19 insertions, 10 deletions
diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py
index bced2b910..22beef05f 100644
--- a/nova/tests/api/openstack/test_servers.py
+++ b/nova/tests/api/openstack/test_servers.py
@@ -29,6 +29,7 @@ from nova import db
from nova import exception
from nova import flags
from nova import test
+from nova import utils
import nova.api.openstack
from nova.api.openstack import servers
import nova.compute.api
@@ -37,6 +38,7 @@ from nova.compute import power_state
import nova.db.api
from nova.db.sqlalchemy.models import Instance
from nova.db.sqlalchemy.models import InstanceMetadata
+import nova.image.fake
import nova.rpc
from nova.tests.api.openstack import common
from nova.tests.api.openstack import fakes
@@ -464,7 +466,12 @@ class ServersTest(test.TestCase):
def image_id_from_hash(*args, **kwargs):
return 2
- FLAGS.glance_image_service = 'nova.image.fake.FakeImageService'
+ def fake_image_service(*args):
+ return nova.image.fake.FakeImageService()
+
+ FLAGS.image_service = 'nova.image.fake.FakeImageService'
+ self.stubs.Set(
+ nova.image.glance, 'GlanceImageService', fake_image_service)
self.stubs.Set(nova.db.api, 'project_get_network', project_get_network)
self.stubs.Set(nova.db.api, 'instance_create', instance_create)
self.stubs.Set(nova.rpc, 'cast', fake_method)
@@ -476,8 +483,6 @@ class ServersTest(test.TestCase):
fake_method)
self.stubs.Set(nova.api.openstack.servers.Controller,
"_get_kernel_ramdisk_from_image", kernel_ramdisk_mapping)
- self.stubs.Set(nova.api.openstack.common,
- "get_image_id_from_image_hash", image_id_from_hash)
self.stubs.Set(nova.compute.api.API, "_find_host", find_host)
def _test_create_instance_helper(self):
@@ -1707,11 +1712,10 @@ class TestServerInstanceCreation(test.TestCase):
return stub_method
compute_api = MockComputeAPI()
+ FLAGS.image_service = 'nova.image.fake.FakeImageService'
self.stubs.Set(nova.compute, 'API', make_stub_method(compute_api))
self.stubs.Set(nova.api.openstack.servers.Controller,
'_get_kernel_ramdisk_from_image', make_stub_method((1, 1)))
- self.stubs.Set(nova.api.openstack.common,
- 'get_image_id_from_image_hash', make_stub_method(2))
return compute_api
def _create_personality_request_dict(self, personality_files):
diff --git a/nova/tests/integrated/integrated_helpers.py b/nova/tests/integrated/integrated_helpers.py
index e6efc16c5..5871a498c 100644
--- a/nova/tests/integrated/integrated_helpers.py
+++ b/nova/tests/integrated/integrated_helpers.py
@@ -27,6 +27,7 @@ from nova import flags
from nova import service
from nova import test # For the flags
from nova.auth import manager
+import nova.image.glance
from nova.log import logging
from nova.tests.integrated.api import client
@@ -151,6 +152,11 @@ class _IntegratedTestBase(test.TestCase):
f = self._get_flags()
self.flags(**f)
+ def fake_image_service(*args):
+ return nova.image.fake.FakeImageService()
+ self.stubs.Set(
+ nova.image.glance, 'GlanceImageService', fake_image_service)
+
# set up services
self.start_service('compute')
self.start_service('volume')
@@ -185,7 +191,6 @@ class _IntegratedTestBase(test.TestCase):
"""An opportunity to setup flags, before the services are started."""
f = {}
f['image_service'] = 'nova.image.fake.FakeImageService'
- f['glance_image_service'] = 'nova.image.fake.FakeImageService'
f['fake_network'] = True
return f
diff --git a/nova/tests/test_quota.py b/nova/tests/test_quota.py
index 9ede0786f..02b641a47 100644
--- a/nova/tests/test_quota.py
+++ b/nova/tests/test_quota.py
@@ -280,18 +280,18 @@ class QuotaTestCase(test.TestCase):
FLAGS.quota_max_injected_files)
def _create_with_injected_files(self, files):
- FLAGS.glance_image_service = 'nova.image.fake.FakeImageService'
+ FLAGS.image_service = 'nova.image.fake.FakeImageService'
api = compute.API(image_service=self.StubImageService())
inst_type = instance_types.get_instance_type_by_name('m1.small')
api.create(self.context, min_count=1, max_count=1,
- instance_type=inst_type, image_id='fake',
+ instance_type=inst_type, image_id='3',
injected_files=files)
def test_no_injected_files(self):
- FLAGS.glance_image_service = 'nova.image.fake.FakeImageService'
+ FLAGS.image_service = 'nova.image.fake.FakeImageService'
api = compute.API(image_service=self.StubImageService())
inst_type = instance_types.get_instance_type_by_name('m1.small')
- api.create(self.context, instance_type=inst_type, image_id='fake')
+ api.create(self.context, instance_type=inst_type, image_id='3')
def test_max_injected_files(self):
files = []