Merge "Convert nova.tests.unit.image.fake.stub_out_image_service to use stub_out"
This commit is contained in:
commit
1906dbd3a4
@ -45,7 +45,7 @@ class ConfigDriveSampleJsonTest(test_servers.ServersSampleBase):
|
||||
super(ConfigDriveSampleJsonTest, self).setUp()
|
||||
fakes.stub_out_networking(self.stubs)
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
|
||||
def test_config_drive_show(self):
|
||||
uuid = self._post_server(use_common_server_api_samples=False)
|
||||
|
@ -71,7 +71,7 @@ class _IntegratedTestBase(test.TestCase):
|
||||
self.flags(**f)
|
||||
self.flags(verbose=True)
|
||||
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self)
|
||||
self._setup_services()
|
||||
|
||||
self.api_fixture = self.useFixture(
|
||||
|
@ -63,7 +63,7 @@ class ServerGroupTestBase(test.TestCase):
|
||||
self.admin_api = api_fixture.admin_api
|
||||
|
||||
# the image fake backend needed for image discovery
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self)
|
||||
|
||||
self.start_service('conductor', manager=CONF.conductor.manager)
|
||||
self.start_service('scheduler')
|
||||
|
@ -54,7 +54,7 @@ class SecgroupsFullstack(testscenarios.WithScenarios, test.TestCase):
|
||||
self.api = api_fixture.api
|
||||
|
||||
# the image fake backend needed for image discovery
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self)
|
||||
|
||||
# TODO(sdague): refactor this method into the API client, we're
|
||||
# going to use it a lot
|
||||
|
@ -117,7 +117,7 @@ class CinderCloudTestCase(test.TestCase):
|
||||
|
||||
self.stubs.Set(fake._FakeImageService, 'show', fake_show)
|
||||
self.stubs.Set(fake._FakeImageService, 'detail', fake_detail)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
|
||||
def dumb(*args, **kwargs):
|
||||
pass
|
||||
|
@ -166,7 +166,7 @@ class CloudTestCase(test.TestCase):
|
||||
|
||||
self.stubs.Set(fake._FakeImageService, 'show', fake_show)
|
||||
self.stubs.Set(fake._FakeImageService, 'detail', fake_detail)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
|
||||
def dumb(*args, **kwargs):
|
||||
pass
|
||||
|
@ -101,7 +101,7 @@ class EC2ValidateTestCase(test.TestCase):
|
||||
image['name'] = kwargs.get('name')
|
||||
return [image]
|
||||
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.stubs.Set(fake._FakeImageService, 'show', fake_show)
|
||||
self.stubs.Set(fake._FakeImageService, 'detail', fake_detail)
|
||||
|
||||
|
@ -167,7 +167,7 @@ class ControllerTest(test.TestCase):
|
||||
self.flags(verbose=True, use_ipv6=False)
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_key_pair_funcs(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
return_server = fakes.fake_compute_get()
|
||||
return_servers = fakes.fake_compute_get_all()
|
||||
# Server sort keys extension is not enabled in v2 test so no sort
|
||||
@ -1934,7 +1934,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_key_pair_funcs(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.stubs.Set(uuid, 'uuid4', fake_gen_uuid)
|
||||
self.stubs.Set(db, 'instance_add_security_group',
|
||||
return_security_group)
|
||||
|
@ -170,7 +170,7 @@ class AccessIPsExtAPIValidationTestV21(test.TestCase):
|
||||
pass
|
||||
|
||||
self._set_up_controller()
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.stubs.Set(db, 'instance_get_by_uuid', fakes.fake_instance_get())
|
||||
self.stubs.Set(instance_obj.Instance, 'save', fake_save)
|
||||
self.stubs.Set(compute_api.API, 'rebuild', fake_rebuild)
|
||||
|
@ -230,7 +230,7 @@ class ServersControllerCreateTestV21(test.TestCase):
|
||||
|
||||
return instance
|
||||
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.stubs.Set(db, 'instance_create', instance_create)
|
||||
|
||||
self.req = fakes.HTTPRequest.blank('')
|
||||
|
@ -53,7 +53,7 @@ class BlockDeviceMappingTestV21(test.TestCase):
|
||||
def setUp(self):
|
||||
super(BlockDeviceMappingTestV21, self).setUp()
|
||||
self._setup_controller()
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
|
||||
self.bdm = [{
|
||||
'no_device': None,
|
||||
|
@ -54,7 +54,7 @@ class BlockDeviceMappingTestV21(test.TestCase):
|
||||
def setUp(self):
|
||||
super(BlockDeviceMappingTestV21, self).setUp()
|
||||
self._setup_controller()
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.volume_id = fakes.FAKE_UUID
|
||||
self.bdm = [{
|
||||
'no_device': None,
|
||||
|
@ -48,7 +48,7 @@ class ConfigDriveTestV21(test.TestCase):
|
||||
super(ConfigDriveTestV21, self).setUp()
|
||||
fakes.stub_out_networking(self.stubs)
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self._setup_wsgi()
|
||||
|
||||
def test_show(self):
|
||||
@ -142,7 +142,7 @@ class ServersControllerCreateTestV21(test.TestCase):
|
||||
|
||||
return instance
|
||||
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.stubs.Set(db, 'instance_create', instance_create)
|
||||
|
||||
def _test_create_extra(self, params, override_controller):
|
||||
|
@ -140,7 +140,7 @@ class DiskConfigTestCaseV21(test.TestCase):
|
||||
|
||||
def _setup_fake_image_service(self):
|
||||
self.image_service = nova.tests.unit.image.fake.stub_out_image_service(
|
||||
self.stubs)
|
||||
self)
|
||||
timestamp = datetime.datetime(2011, 1, 1, 1, 2, 3)
|
||||
image = {'id': '88580842-f50a-11e2-8d3a-f23c91aec05e',
|
||||
'name': 'fakeimage7',
|
||||
|
@ -123,7 +123,7 @@ class MultiCreateExtensionTestV21(test.TestCase):
|
||||
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_key_pair_funcs(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
fakes.stub_out_nw_api(self.stubs)
|
||||
self.stubs.Set(uuid, 'uuid4', fake_gen_uuid)
|
||||
self.stubs.Set(db, 'instance_add_security_group',
|
||||
@ -576,7 +576,7 @@ class MultiCreateExtensionTestV2(MultiCreateExtensionTestV21):
|
||||
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_key_pair_funcs(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.stubs.Set(uuid, 'uuid4', fake_gen_uuid)
|
||||
self.stubs.Set(db, 'instance_create', instance_create)
|
||||
self.stubs.Set(db, 'instance_get', instance_get)
|
||||
|
@ -198,7 +198,7 @@ class ServersControllerCreateTestV21(test.TestCase):
|
||||
|
||||
return instance
|
||||
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.stubs.Set(db, 'instance_create', instance_create)
|
||||
|
||||
def _set_up_controller(self):
|
||||
|
@ -94,7 +94,7 @@ class ServerActionsControllerTestV21(test.TestCase):
|
||||
|
||||
fakes.stub_out_nw_api(self.stubs)
|
||||
fakes.stub_out_compute_api_snapshot(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.flags(allow_instance_snapshots=True,
|
||||
enable_instance_password=True)
|
||||
self._image_href = '155d900f-4e14-4e4c-a73d-069cbf4541e6'
|
||||
|
@ -190,7 +190,7 @@ class ControllerTest(test.TestCase):
|
||||
self.flags(verbose=True, use_ipv6=False)
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_key_pair_funcs(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
return_server = fakes.fake_compute_get()
|
||||
return_servers = fakes.fake_compute_get_all()
|
||||
# Server sort keys extension is enabled in v21 so sort data is passed
|
||||
@ -2110,7 +2110,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_key_pair_funcs(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.stubs.Set(uuid, 'uuid4', fake_gen_uuid)
|
||||
self.stubs.Set(db, 'project_get_networks',
|
||||
project_get_networks)
|
||||
|
@ -25,7 +25,7 @@ class UrlmapTest(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(UrlmapTest, self).setUp()
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self)
|
||||
|
||||
def tearDown(self):
|
||||
super(UrlmapTest, self).tearDown()
|
||||
|
@ -120,7 +120,7 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
|
||||
fakes.stub_out_rate_limiting(self.stubs)
|
||||
fakes.stub_out_key_pair_funcs(self.stubs)
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
fakes.stub_out_nw_api(self.stubs)
|
||||
self.stubs.Set(uuid, 'uuid4', fake_gen_uuid)
|
||||
self.stubs.Set(db, 'instance_add_security_group',
|
||||
|
@ -231,7 +231,7 @@ class BaseTestCase(test.TestCase):
|
||||
else:
|
||||
raise exception.ImageNotFound(image_id=id)
|
||||
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
self.stubs.Set(fake_image._FakeImageService, 'show', fake_show)
|
||||
|
||||
fake_taskapi = FakeComputeTaskAPI()
|
||||
@ -2042,7 +2042,7 @@ class ComputeTestCase(BaseTestCase):
|
||||
def fake_delete(self_, ctxt, image_id):
|
||||
self.deleted_image_id = image_id
|
||||
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
self.stubs.Set(fake_image._FakeImageService, 'delete', fake_delete)
|
||||
|
||||
instance = self._create_fake_instance_obj()
|
||||
@ -3107,7 +3107,7 @@ class ComputeTestCase(BaseTestCase):
|
||||
raise Exception()
|
||||
|
||||
self.stubs.Set(self.compute.driver, 'snapshot', fake_snapshot)
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
self.stubs.Set(fake_image._FakeImageService, 'delete', fake_delete)
|
||||
|
||||
inst_obj = self._get_snapshotting_instance()
|
||||
@ -3169,7 +3169,7 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
self.stubs.Set(self.compute.driver, 'snapshot', fake_snapshot)
|
||||
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
|
||||
inst_obj = self._get_snapshotting_instance()
|
||||
|
||||
@ -11234,7 +11234,7 @@ class ComputeInactiveImageTestCase(BaseTestCase):
|
||||
'ramdisk_id': 'fake_ramdisk_id',
|
||||
'something_else': 'meow'}}
|
||||
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
self.stubs.Set(fake_image._FakeImageService, 'show', fake_show)
|
||||
self.compute_api = compute.API()
|
||||
|
||||
|
@ -2383,7 +2383,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||
|
||||
def fake_show(obj, context, image_id, **kwargs):
|
||||
return self.fake_image
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
self.stubs.Set(fake_image._FakeImageService, 'show', fake_show)
|
||||
return self.fake_image['id']
|
||||
|
||||
|
@ -232,7 +232,7 @@ class ShelveComputeManagerTestCase(test_compute.BaseTestCase):
|
||||
else:
|
||||
self.fail('Unexpected save!')
|
||||
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
self.stubs.Set(fake_image._FakeImageService, 'delete', fake_delete)
|
||||
|
||||
self.compute._notify_about_instance_usage(self.context, instance,
|
||||
@ -464,7 +464,7 @@ class ShelveComputeAPITestCase(test_compute.BaseTestCase):
|
||||
metadata['id'] = '8b24ed3f-ee57-43bc-bc2e-fb2e9482bc42'
|
||||
return metadata
|
||||
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
self.stubs.Set(fake_image._FakeImageService, '__init__', fake_init)
|
||||
self.stubs.Set(fake_image._FakeImageService, 'create', fake_create)
|
||||
|
||||
|
@ -25,7 +25,6 @@ from oslo_log import log as logging
|
||||
|
||||
from nova.compute import arch
|
||||
from nova import exception
|
||||
import nova.image.glance
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.import_opt('null_kernel', 'nova.compute.api')
|
||||
@ -249,10 +248,15 @@ def get_valid_image_id():
|
||||
return AUTO_DISK_CONFIG_ENABLED_IMAGE_UUID
|
||||
|
||||
|
||||
def stub_out_image_service(stubs):
|
||||
def stub_out_image_service(test):
|
||||
"""Stubs out the image service for the test with the FakeImageService
|
||||
|
||||
:param test: instance of nova.test.TestCase
|
||||
:returns: The stubbed out FakeImageService object
|
||||
"""
|
||||
image_service = FakeImageService()
|
||||
stubs.Set(nova.image.glance, 'get_remote_image_service',
|
||||
lambda x, y: (image_service, y))
|
||||
stubs.Set(nova.image.glance, 'get_default_image_service',
|
||||
lambda: image_service)
|
||||
test.stub_out('nova.image.glance.get_remote_image_service',
|
||||
lambda x, y: (image_service, y))
|
||||
test.stub_out('nova.image.glance.get_default_image_service',
|
||||
lambda: image_service)
|
||||
return image_service
|
||||
|
@ -94,7 +94,7 @@ class TestS3ImageService(test.TestCase):
|
||||
db.s3_image_create(self.context,
|
||||
'76fa36fc-c930-4bf3-8c8a-ea2a2420deb6')
|
||||
|
||||
fake.stub_out_image_service(self.stubs)
|
||||
fake.stub_out_image_service(self)
|
||||
self.image_service = s3.S3ImageService()
|
||||
ec2utils.reset_cache()
|
||||
|
||||
|
@ -56,7 +56,7 @@ class QuotaIntegrationTestCase(test.TestCase):
|
||||
self.project_id,
|
||||
is_admin=True)
|
||||
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self)
|
||||
|
||||
self.compute_api = compute.API()
|
||||
|
||||
|
@ -38,7 +38,7 @@ class LibvirtBlockInfoTest(test.NoDBTestCase):
|
||||
self.user_id = 'fake'
|
||||
self.project_id = 'fake'
|
||||
self.context = context.get_admin_context()
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self)
|
||||
self.test_instance = {
|
||||
'uuid': '32dfcb37-5af1-552b-357c-be8c3aa38310',
|
||||
'memory_kb': '1024000',
|
||||
|
@ -629,7 +629,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
|
||||
"disk_format": "raw",
|
||||
}
|
||||
self.image_service = nova.tests.unit.image.fake.stub_out_image_service(
|
||||
self.stubs)
|
||||
self)
|
||||
self.device_xml_tmpl = """
|
||||
<domain type='kvm'>
|
||||
<devices>
|
||||
@ -15499,7 +15499,7 @@ class _BaseSnapshotTests(test.NoDBTestCase):
|
||||
fake_libvirt_utils))
|
||||
|
||||
self.image_service = nova.tests.unit.image.fake.stub_out_image_service(
|
||||
self.stubs)
|
||||
self)
|
||||
|
||||
self.mock_update_task_state = mock.Mock()
|
||||
|
||||
|
@ -190,7 +190,7 @@ class _FakeDriverBackendTestCase(object):
|
||||
# TODO(sdague): it would be nice to do this in a way that only
|
||||
# the relevant backends where replaced for tests, though this
|
||||
# should not harm anything by doing it for all backends
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
self._setup_fakelibvirt()
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -50,7 +50,7 @@ class ConfigDriveTestCase(test.NoDBTestCase):
|
||||
self.flags(enabled=False, group='vnc')
|
||||
vmwareapi_fake.reset()
|
||||
stubs.set_stubs(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self)
|
||||
self.conn = driver.VMwareVCDriver(fake.FakeVirtAPI)
|
||||
self.network_info = utils.get_test_network_info()
|
||||
self.node_name = self.conn._nodename
|
||||
|
@ -172,7 +172,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
||||
self.context = context.RequestContext(self.user_id, self.project_id)
|
||||
stubs.set_stubs(self.stubs)
|
||||
vmwareapi_fake.reset()
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self)
|
||||
self.conn = driver.VMwareVCDriver(None, False)
|
||||
self._set_exception_vars()
|
||||
self.node_name = self.conn._nodename
|
||||
@ -193,7 +193,7 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
||||
'size': int(metadata['size']),
|
||||
}
|
||||
self.fake_image_uuid = self.image['id']
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self.stubs)
|
||||
nova.tests.unit.image.fake.stub_out_image_service(self)
|
||||
self.vnc_host = 'ha-host'
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -309,7 +309,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
|
||||
self.conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
|
||||
self.conn._session.is_local_connection = False
|
||||
|
||||
fake_image.stub_out_image_service(self.stubs)
|
||||
fake_image.stub_out_image_service(self)
|
||||
set_image_fixtures()
|
||||
stubs.stubout_image_service_download(self.stubs)
|
||||
stubs.stubout_stream_disk(self.stubs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user