summaryrefslogtreecommitdiff
path: root/nova/tests/unit/api/openstack/compute/test_servers.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-06-16 15:07:43 +0000
committerGerrit Code Review <review@openstack.org>2021-06-16 15:07:43 +0000
commiteec1958d82ad08b9727e8b360ef6e555c245291a (patch)
treedeec1e1b21bb48ac34b33c2f09c3bedb745af5f4 /nova/tests/unit/api/openstack/compute/test_servers.py
parentb32804758e2f52dd5f4b3f2ce7181afa3bff7d48 (diff)
parent1748bd25096d93e66473894999ae18d4a29d7137 (diff)
downloadnova-eec1958d82ad08b9727e8b360ef6e555c245291a.tar.gz
Merge "tests: Remove useless mocks"
Diffstat (limited to 'nova/tests/unit/api/openstack/compute/test_servers.py')
-rw-r--r--nova/tests/unit/api/openstack/compute/test_servers.py73
1 files changed, 9 insertions, 64 deletions
diff --git a/nova/tests/unit/api/openstack/compute/test_servers.py b/nova/tests/unit/api/openstack/compute/test_servers.py
index 397adec18a..7ee8659c33 100644
--- a/nova/tests/unit/api/openstack/compute/test_servers.py
+++ b/nova/tests/unit/api/openstack/compute/test_servers.py
@@ -4199,70 +4199,12 @@ class ServersControllerCreateTest(test.TestCase):
super(ServersControllerCreateTest, self).setUp()
self.flags(enable_instance_password=True, group='api')
- self.instance_cache_num = 0
- self.instance_cache_by_id = {}
- self.instance_cache_by_uuid = {}
-
fakes.stub_out_nw_api(self)
+ fakes.stub_out_key_pair_funcs(self)
self.controller = servers.ServersController()
- def instance_create(context, inst):
- flavor = flavors.get_flavor_by_flavor_id(3)
- image_uuid = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
- def_image_ref = 'http://localhost/%s/images/%s' % (self.project_id,
- image_uuid)
- self.instance_cache_num += 1
- instance = fake_instance.fake_db_instance(**{
- 'id': self.instance_cache_num,
- 'display_name': inst['display_name'] or 'test',
- 'display_description': inst['display_description'] or '',
- 'uuid': FAKE_UUID,
- 'flavor': flavor,
- 'image_ref': inst.get('image_ref', def_image_ref),
- 'user_id': 'fake',
- 'project_id': fakes.FAKE_PROJECT_ID,
- 'reservation_id': inst['reservation_id'],
- "created_at": datetime.datetime(2010, 10, 10, 12, 0, 0),
- "updated_at": datetime.datetime(2010, 11, 11, 11, 0, 0),
- "config_drive": None,
- "progress": 0,
- "fixed_ips": [],
- "task_state": "",
- "vm_state": "",
- "root_device_name": inst.get('root_device_name', 'vda'),
- })
-
- self.instance_cache_by_id[instance['id']] = instance
- self.instance_cache_by_uuid[instance['uuid']] = instance
- return instance
-
- def instance_get(context, instance_id):
- """Stub for compute/api create() pulling in instance after
- scheduling
- """
- return self.instance_cache_by_id[instance_id]
-
- def instance_update(context, uuid, values):
- instance = self.instance_cache_by_uuid[uuid]
- instance.update(values)
- return instance
-
- def server_update_and_get_original(
- context, instance_uuid, params, columns_to_join=None):
- inst = self.instance_cache_by_uuid[instance_uuid]
- inst.update(params)
- return (inst, inst)
-
- fakes.stub_out_key_pair_funcs(self)
self.useFixture(nova_fixtures.GlanceFixture(self))
- self.stub_out('nova.db.api.instance_create', instance_create)
- self.stub_out('nova.db.api.instance_system_metadata_update',
- lambda *a, **kw: None)
- self.stub_out('nova.db.api.instance_get', instance_get)
- self.stub_out('nova.db.api.instance_update', instance_update)
- self.stub_out('nova.db.api.instance_update_and_get_original',
- server_update_and_get_original)
self.body = {
'server': {
'name': 'server_test',
@@ -4303,8 +4245,7 @@ class ServersControllerCreateTest(test.TestCase):
def _check_admin_password_len(self, server_dict):
"""utility function - check server_dict for admin_password length."""
- self.assertEqual(CONF.password_length,
- len(server_dict["adminPass"]))
+ self.assertEqual(CONF.password_length, len(server_dict["adminPass"]))
def _check_admin_password_missing(self, server_dict):
"""utility function - check server_dict for admin_password absence."""
@@ -5856,6 +5797,8 @@ class ServersControllerCreateTest(test.TestCase):
"""Test creating multiple instances but not asking for
reservation_id
"""
+ self.instance_cache_by_uuid = {}
+
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
flavor_ref = 'http://localhost/123/flavors/3'
body = {
@@ -5887,6 +5830,8 @@ class ServersControllerCreateTest(test.TestCase):
reservation_id
"""
self.flags(enable_instance_password=False, group='api')
+ self.instance_cache_by_uuid = {}
+
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
flavor_ref = 'http://localhost/123/flavors/3'
body = {
@@ -5917,6 +5862,8 @@ class ServersControllerCreateTest(test.TestCase):
"""Test creating multiple instances with asking for
reservation_id
"""
+ self.instance_cache_by_uuid = {}
+
def _populate_instance_for_create(*args, **kwargs):
instance = args[2]
self.instance_cache_by_uuid[instance.uuid] = instance
@@ -6034,6 +5981,7 @@ class ServersControllerCreateTest(test.TestCase):
self.controller.create, self.req, body=body)
def test_create_multiple_instance_max_count_overquota_min_count_ok(self):
+ self.instance_cache_by_uuid = {}
self.flags(instances=3, group='quota')
image_href = '76fa36fc-c930-4bf3-8c8a-ea2a2420deb6'
flavor_ref = 'http://localhost/123/flavors/3'
@@ -7054,9 +7002,6 @@ class ServersControllerCreateTestWithMock(test.TestCase):
super(ServersControllerCreateTestWithMock, self).setUp()
self.flags(enable_instance_password=True, group='api')
- self.instance_cache_num = 0
- self.instance_cache_by_id = {}
- self.instance_cache_by_uuid = {}
self.controller = servers.ServersController()