Replace uuid4() with uuidsentinel
As of now, in most of the test cases, uuidsentinel is used for generating a UUID except at some places where uuid4() is used. In order to maintain consistency, we propose to use uuidsentinel module for generating UUIDs throughout the test cases. There are some cases where unique UUIDs are required. For such cases, generate_uuid() from oslo_utils.uuidutils is used. Change-Id: I61914796aa94b453669add2e71b3d5d704633176
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
"""Tests for the aggregates admin api."""
|
||||
|
||||
import mock
|
||||
import uuid
|
||||
from webob import exc
|
||||
|
||||
from nova.api.openstack.compute import aggregates as aggregates_v21
|
||||
@@ -276,11 +275,12 @@ class AggregateTestCaseV21(test.NoDBTestCase):
|
||||
|
||||
@mock.patch('nova.compute.api.AggregateAPI.create_aggregate')
|
||||
def test_create_with_none_availability_zone(self, mock_create_agg):
|
||||
mock_create_agg.return_value = objects.Aggregate(self.context,
|
||||
name='test',
|
||||
uuid=uuid.uuid4(),
|
||||
hosts=[],
|
||||
metadata={})
|
||||
mock_create_agg.return_value = objects.Aggregate(
|
||||
self.context,
|
||||
name='test',
|
||||
uuid=uuidsentinel.aggregate,
|
||||
hosts=[],
|
||||
metadata={})
|
||||
body = {"aggregate": {"name": "test",
|
||||
"availability_zone": None}}
|
||||
result = self.controller.create(self.req, body=body)
|
||||
@@ -406,7 +406,7 @@ class AggregateTestCaseV21(test.NoDBTestCase):
|
||||
|
||||
@mock.patch('nova.compute.api.AggregateAPI.update_aggregate')
|
||||
def test_update_with_none_availability_zone(self, mock_update_agg):
|
||||
agg_id = uuid.uuid4()
|
||||
agg_id = uuidsentinel.aggregate
|
||||
mock_update_agg.return_value = objects.Aggregate(self.context,
|
||||
name='test',
|
||||
uuid=agg_id,
|
||||
|
||||
@@ -27,13 +27,14 @@ from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import fake_network
|
||||
from nova.tests.unit import matchers
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova import utils
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
|
||||
|
||||
project_id = str(uuid_lib.uuid4().hex)
|
||||
uuid = str(uuid_lib.uuid4())
|
||||
uuid = uuids.fake
|
||||
|
||||
|
||||
def fake_vpn_instance():
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
import uuid as stdlib_uuid
|
||||
|
||||
from oslo_policy import policy as oslo_policy
|
||||
from oslo_utils import timeutils
|
||||
@@ -28,6 +27,7 @@ from nova import policy
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import matchers
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
|
||||
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
@@ -54,7 +54,7 @@ class FakeInstanceDB(object):
|
||||
if id is None:
|
||||
id = self.max_id + 1
|
||||
if uuid is None:
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuids.fake
|
||||
instance = stub_instance(id, uuid=uuid)
|
||||
self.instances_by_id[id] = instance
|
||||
self.ids_by_uuid[uuid] = id
|
||||
@@ -129,7 +129,7 @@ class ConsolesControllerTestV21(test.NoDBTestCase):
|
||||
self.instance_db.return_server_by_id)
|
||||
self.stub_out('nova.db.instance_get_by_uuid',
|
||||
self.instance_db.return_server_by_uuid)
|
||||
self.uuid = str(stdlib_uuid.uuid4())
|
||||
self.uuid = uuids.fake
|
||||
self.url = '/v2/fake/servers/%s/consoles' % self.uuid
|
||||
self._set_up_controller()
|
||||
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
import testtools
|
||||
import webob
|
||||
@@ -26,6 +24,7 @@ from nova import exception
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
@@ -65,7 +64,7 @@ class EvacuateTestV21(test.NoDBTestCase):
|
||||
self.stub_out('nova.compute.api.API.get', fake_compute_api_get)
|
||||
self.stub_out('nova.compute.api.HostAPI.service_get_by_compute_host',
|
||||
fake_service_get_by_compute_host)
|
||||
self.UUID = uuid.uuid4()
|
||||
self.UUID = uuids.fake
|
||||
for _method in self._methods:
|
||||
self.stub_out('nova.compute.api.API.%s' % _method,
|
||||
fake_compute_api)
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
import six
|
||||
import webob
|
||||
@@ -33,6 +31,7 @@ from nova.objects import base as obj_base
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import fake_network
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
|
||||
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
@@ -92,7 +91,7 @@ def network_api_disassociate(self, context, instance, floating_address):
|
||||
def fake_instance_get(context, instance_id):
|
||||
return objects.Instance(**{
|
||||
"id": 1,
|
||||
"uuid": uuid.uuid4(),
|
||||
"uuid": uuids.fake,
|
||||
"name": 'fake',
|
||||
"user_id": 'fakeuser',
|
||||
"project_id": '123'})
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_policy import policy as oslo_policy
|
||||
@@ -31,6 +30,7 @@ from nova import policy
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import fake_server_actions
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
FAKE_UUID = fake_server_actions.FAKE_UUID
|
||||
FAKE_REQUEST_ID = fake_server_actions.FAKE_REQUEST_ID1
|
||||
@@ -95,7 +95,7 @@ class InstanceActionsPolicyTestV21(test.NoDBTestCase):
|
||||
req = self._get_http_req('os-instance-actions')
|
||||
mock_instance_get.return_value = self._get_instance_other_project(req)
|
||||
self.assertRaises(exception.Forbidden, self.controller.index, req,
|
||||
str(uuid.uuid4()))
|
||||
uuids.fake)
|
||||
|
||||
@mock.patch('nova.api.openstack.common.get_instance')
|
||||
def test_get_action_restricted_by_project(self, mock_instance_get):
|
||||
@@ -103,7 +103,7 @@ class InstanceActionsPolicyTestV21(test.NoDBTestCase):
|
||||
req = self._get_http_req('os-instance-actions/1')
|
||||
mock_instance_get.return_value = self._get_instance_other_project(req)
|
||||
self.assertRaises(exception.Forbidden, self.controller.show, req,
|
||||
str(uuid.uuid4()), '1')
|
||||
uuids.fake, '1')
|
||||
|
||||
|
||||
class InstanceActionsTestV21(test.NoDBTestCase):
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
import copy
|
||||
import datetime
|
||||
import math
|
||||
import uuid
|
||||
|
||||
import iso8601
|
||||
import mock
|
||||
@@ -211,7 +210,7 @@ class FakeNetworkAPI(object):
|
||||
new_id = max((net['id'] for net in self.networks))
|
||||
for index, subnet_v4 in enumerate(subnets_v4):
|
||||
new_id += 1
|
||||
net = {'id': new_id, 'uuid': str(uuid.uuid4())}
|
||||
net = {'id': new_id, 'uuid': uuids.fake}
|
||||
|
||||
net['cidr'] = str(subnet_v4)
|
||||
net['netmask'] = str(subnet_v4.netmask)
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import six
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from neutronclient.common import exceptions as n_exc
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import uuidutils
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import security_groups
|
||||
@@ -631,7 +631,7 @@ class MockClient(object):
|
||||
if not len(self._fake_security_groups):
|
||||
ret = {'name': 'default', 'description': 'default',
|
||||
'tenant_id': 'fake_tenant', 'security_group_rules': [],
|
||||
'id': str(uuid.uuid4())}
|
||||
'id': uuidutils.generate_uuid()}
|
||||
self._fake_security_groups[ret['id']] = ret
|
||||
|
||||
def _reset(self):
|
||||
@@ -656,7 +656,7 @@ class MockClient(object):
|
||||
raise n_exc.NeutronClientException(message=msg, status_code=401)
|
||||
ret = {'name': s.get('name'), 'description': s.get('description'),
|
||||
'tenant_id': 'fake', 'security_group_rules': [],
|
||||
'id': str(uuid.uuid4())}
|
||||
'id': uuidutils.generate_uuid()}
|
||||
|
||||
self._fake_security_groups[ret['id']] = ret
|
||||
return {'security_group': ret}
|
||||
@@ -666,7 +666,7 @@ class MockClient(object):
|
||||
ret = {'status': 'ACTIVE', 'subnets': [], 'name': n.get('name'),
|
||||
'admin_state_up': n.get('admin_state_up', True),
|
||||
'tenant_id': 'fake_tenant',
|
||||
'id': str(uuid.uuid4())}
|
||||
'id': uuidutils.generate_uuid()}
|
||||
if 'port_security_enabled' in n:
|
||||
ret['port_security_enabled'] = n['port_security_enabled']
|
||||
self._fake_networks[ret['id']] = ret
|
||||
@@ -681,7 +681,7 @@ class MockClient(object):
|
||||
raise n_exc.NeutronClientException(message=msg, status_code=404)
|
||||
ret = {'name': s.get('name'), 'network_id': s.get('network_id'),
|
||||
'tenant_id': 'fake_tenant', 'cidr': s.get('cidr'),
|
||||
'id': str(uuid.uuid4()), 'gateway_ip': '10.0.0.1'}
|
||||
'id': uuidutils.generate_uuid(), 'gateway_ip': '10.0.0.1'}
|
||||
net['subnets'].append(ret['id'])
|
||||
self._fake_networks[net['id']] = net
|
||||
self._fake_subnets[ret['id']] = ret
|
||||
@@ -689,9 +689,9 @@ class MockClient(object):
|
||||
|
||||
def create_port(self, body):
|
||||
p = body.get('port')
|
||||
ret = {'status': 'ACTIVE', 'id': str(uuid.uuid4()),
|
||||
ret = {'status': 'ACTIVE', 'id': uuidutils.generate_uuid(),
|
||||
'mac_address': p.get('mac_address', 'fa:16:3e:b8:f5:fb'),
|
||||
'device_id': p.get('device_id', str(uuid.uuid4())),
|
||||
'device_id': p.get('device_id', uuidutils.generate_uuid()),
|
||||
'admin_state_up': p.get('admin_state_up', True),
|
||||
'security_groups': p.get('security_groups', []),
|
||||
'network_id': p.get('network_id'),
|
||||
@@ -731,7 +731,7 @@ class MockClient(object):
|
||||
ret = {}
|
||||
for field in fields:
|
||||
ret[field] = r.get(field)
|
||||
ret['id'] = str(uuid.uuid4())
|
||||
ret['id'] = uuidutils.generate_uuid()
|
||||
self._fake_security_group_rules[ret['id']] = ret
|
||||
return {'security_group_rules': [ret]}
|
||||
|
||||
|
||||
@@ -13,11 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from mox3 import mox
|
||||
from oslo_utils import uuidutils
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import extension_info
|
||||
@@ -34,6 +31,7 @@ from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import fake_block_device
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests.unit.image import fake
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
CONF = nova.conf.CONF
|
||||
FAKE_UUID = fakes.FAKE_UUID
|
||||
@@ -115,7 +113,7 @@ class ServerActionsControllerTestV21(test.TestCase):
|
||||
def _stub_instance_get(self, context, uuid=None):
|
||||
self.mox.StubOutWithMock(compute_api.API, 'get')
|
||||
if uuid is None:
|
||||
uuid = uuidutils.generate_uuid()
|
||||
uuid = uuids.fake
|
||||
instance = fake_instance.fake_db_instance(
|
||||
id=1, uuid=uuid, vm_state=vm_states.ACTIVE, task_state=None,
|
||||
project_id=context.project_id,
|
||||
@@ -218,7 +216,7 @@ class ServerActionsControllerTestV21(test.TestCase):
|
||||
body = dict(reboot=dict(type="HARD"))
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller._action_reboot,
|
||||
self.req, str(uuid.uuid4()), body=body)
|
||||
self.req, uuids.fake, body=body)
|
||||
|
||||
def test_reboot_raises_conflict_on_invalid_state(self):
|
||||
body = dict(reboot=dict(type="HARD"))
|
||||
@@ -965,7 +963,7 @@ class ServerActionsControllerTestV21(test.TestCase):
|
||||
image_root_device_name='/dev/vda',
|
||||
image_block_device_mapping=str(bdm),
|
||||
image_container_format='ami')
|
||||
instance = fakes.fake_instance_get(image_ref=str(uuid.uuid4()),
|
||||
instance = fakes.fake_instance_get(image_ref=uuids.fake,
|
||||
vm_state=vm_states.ACTIVE,
|
||||
root_device_name='/dev/vda',
|
||||
system_metadata=system_metadata)
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from oslo_serialization import jsonutils
|
||||
@@ -32,6 +30,7 @@ from nova import objects
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
@@ -132,7 +131,7 @@ class ServerMetaDataTestV21(test.TestCase):
|
||||
|
||||
def _set_up_resources(self):
|
||||
self.controller = server_metadata_v21.ServerMetadataController()
|
||||
self.uuid = str(uuid.uuid4())
|
||||
self.uuid = uuids.fake
|
||||
self.url = '/fake/servers/%s/metadata' % self.uuid
|
||||
|
||||
def _get_request(self, param_url=''):
|
||||
@@ -685,7 +684,7 @@ class BadStateServerMetaDataTestV21(test.TestCase):
|
||||
|
||||
def _set_up_resources(self):
|
||||
self.controller = server_metadata_v21.ServerMetadataController()
|
||||
self.uuid = str(uuid.uuid4())
|
||||
self.uuid = uuids.fake
|
||||
self.url = '/fake/servers/%s/metadata' % self.uuid
|
||||
|
||||
def _get_request(self, param_url=''):
|
||||
|
||||
@@ -26,6 +26,7 @@ from mox3 import mox
|
||||
from oslo_policy import policy as oslo_policy
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from six.moves import range
|
||||
import six.moves.urllib.parse as urlparse
|
||||
@@ -287,7 +288,7 @@ class ServersControllerTest(ControllerTest):
|
||||
project_ids and check that the host_id's are unique.
|
||||
"""
|
||||
def return_instance_with_host(context, *args, **kwargs):
|
||||
project_id = str(uuid.uuid4())
|
||||
project_id = uuidutils.generate_uuid()
|
||||
return fakes.stub_instance_obj(context, id=1, uuid=FAKE_UUID,
|
||||
project_id=project_id,
|
||||
host='fake_host')
|
||||
@@ -488,7 +489,7 @@ class ServersControllerTest(ControllerTest):
|
||||
|
||||
self.stubs.Set(compute_api.API, 'get', fake_instance_get)
|
||||
|
||||
server_id = str(uuid.uuid4())
|
||||
server_id = uuids.fake
|
||||
req = self.req('/fake/servers/%s/ips' % server_id)
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.ips_controller.index, req, server_id)
|
||||
@@ -664,7 +665,7 @@ class ServersControllerTest(ControllerTest):
|
||||
self.controller.index, req)
|
||||
|
||||
def test_get_servers_with_bad_option(self):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -682,7 +683,7 @@ class ServersControllerTest(ControllerTest):
|
||||
self.assertEqual(servers[0]['id'], server_uuid)
|
||||
|
||||
def test_get_servers_allows_image(self):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -825,7 +826,7 @@ class ServersControllerTest(ControllerTest):
|
||||
self.controller.index, req)
|
||||
|
||||
def test_get_servers_allows_flavor(self):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -862,7 +863,7 @@ class ServersControllerTest(ControllerTest):
|
||||
self.assertThat(servers, testtools.matchers.HasLength(0))
|
||||
|
||||
def test_get_servers_allows_status(self):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -882,7 +883,7 @@ class ServersControllerTest(ControllerTest):
|
||||
self.assertEqual(servers[0]['id'], server_uuid)
|
||||
|
||||
def test_get_servers_allows_task_status(self):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
task_state = task_states.REBOOTING
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
@@ -908,7 +909,7 @@ class ServersControllerTest(ControllerTest):
|
||||
|
||||
def test_get_servers_resize_status(self):
|
||||
# Test when resize status, it maps list of vm states.
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -942,7 +943,7 @@ class ServersControllerTest(ControllerTest):
|
||||
self.controller.detail, req)
|
||||
|
||||
def test_get_servers_deleted_status_as_admin(self):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -964,7 +965,7 @@ class ServersControllerTest(ControllerTest):
|
||||
|
||||
@mock.patch.object(compute_api.API, 'get_all')
|
||||
def test_get_servers_deleted_filter_str_to_bool(self, mock_get_all):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
db_list = objects.InstanceList(
|
||||
objects=[fakes.stub_instance_obj(100, uuid=server_uuid,
|
||||
@@ -986,7 +987,7 @@ class ServersControllerTest(ControllerTest):
|
||||
|
||||
@mock.patch.object(compute_api.API, 'get_all')
|
||||
def test_get_servers_deleted_filter_invalid_str(self, mock_get_all):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
db_list = objects.InstanceList(
|
||||
objects=[fakes.stub_instance_obj(100, uuid=server_uuid)])
|
||||
@@ -1006,7 +1007,7 @@ class ServersControllerTest(ControllerTest):
|
||||
mock_get_all.call_args[1]['search_opts'])
|
||||
|
||||
def test_get_servers_allows_name(self):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -1036,7 +1037,7 @@ class ServersControllerTest(ControllerTest):
|
||||
self.assertEqual(0, len(servers))
|
||||
|
||||
def test_get_servers_allows_changes_since(self):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -1069,7 +1070,7 @@ class ServersControllerTest(ControllerTest):
|
||||
context is not admin. Make sure the admin and unknown options
|
||||
are stripped before they get to compute_api.get_all()
|
||||
"""
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -1099,7 +1100,7 @@ class ServersControllerTest(ControllerTest):
|
||||
"""Test getting servers by admin-only or unknown options when
|
||||
context is admin. All options should be passed
|
||||
"""
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -1128,7 +1129,7 @@ class ServersControllerTest(ControllerTest):
|
||||
def test_get_servers_allows_ip(self):
|
||||
"""Test getting servers by ip."""
|
||||
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -1151,7 +1152,7 @@ class ServersControllerTest(ControllerTest):
|
||||
"""Test getting servers by ip6 with admin_api enabled and
|
||||
admin context
|
||||
"""
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -1175,7 +1176,7 @@ class ServersControllerTest(ControllerTest):
|
||||
"""Test getting servers by ip6 with new version requested
|
||||
and no admin context
|
||||
"""
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
|
||||
def fake_get_all(compute_self, context, search_opts=None,
|
||||
limit=None, marker=None,
|
||||
@@ -1467,7 +1468,7 @@ class ServersControllerTestV226(ControllerTest):
|
||||
|
||||
@mock.patch.object(compute_api.API, 'get_all')
|
||||
def _test_get_servers_allows_tag_filters(self, filter_name, mock_get_all):
|
||||
server_uuid = str(uuid.uuid4())
|
||||
server_uuid = uuids.fake
|
||||
req = fakes.HTTPRequest.blank('/fake/servers?%s=t1,t2' % filter_name,
|
||||
version=self.wsgi_api_version)
|
||||
ctxt = req.environ['nova.context']
|
||||
|
||||
@@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_policy import policy as oslo_policy
|
||||
import webob
|
||||
@@ -25,6 +23,7 @@ from nova import policy
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import fake_instance
|
||||
from nova.tests import uuidsentinel
|
||||
|
||||
|
||||
class ShelvePolicyTestV21(test.NoDBTestCase):
|
||||
@@ -42,7 +41,7 @@ class ShelvePolicyTestV21(test.NoDBTestCase):
|
||||
self.stubs.Set(compute_api.API, 'shelve',
|
||||
fakes.fake_actions_to_locked_server)
|
||||
self.assertRaises(webob.exc.HTTPConflict, self.controller._shelve,
|
||||
self.req, str(uuid.uuid4()), {})
|
||||
self.req, uuidsentinel.fake, {})
|
||||
|
||||
@mock.patch('nova.api.openstack.common.get_instance')
|
||||
def test_unshelve_locked_server(self, get_instance_mock):
|
||||
@@ -51,7 +50,7 @@ class ShelvePolicyTestV21(test.NoDBTestCase):
|
||||
self.stubs.Set(compute_api.API, 'unshelve',
|
||||
fakes.fake_actions_to_locked_server)
|
||||
self.assertRaises(webob.exc.HTTPConflict, self.controller._unshelve,
|
||||
self.req, str(uuid.uuid4()), {})
|
||||
self.req, uuidsentinel.fake, {})
|
||||
|
||||
@mock.patch('nova.api.openstack.common.get_instance')
|
||||
def test_shelve_offload_locked_server(self, get_instance_mock):
|
||||
@@ -61,7 +60,7 @@ class ShelvePolicyTestV21(test.NoDBTestCase):
|
||||
fakes.fake_actions_to_locked_server)
|
||||
self.assertRaises(webob.exc.HTTPConflict,
|
||||
self.controller._shelve_offload,
|
||||
self.req, str(uuid.uuid4()), {})
|
||||
self.req, uuidsentinel.fake, {})
|
||||
|
||||
|
||||
class ShelvePolicyEnforcementV21(test.NoDBTestCase):
|
||||
@@ -79,7 +78,7 @@ class ShelvePolicyEnforcementV21(test.NoDBTestCase):
|
||||
policy.set_rules(oslo_policy.Rules.from_dict(rules))
|
||||
|
||||
self.assertRaises(exception.Forbidden, self.controller._shelve,
|
||||
self.req, str(uuid.uuid4()), {})
|
||||
self.req, uuidsentinel.fake, {})
|
||||
|
||||
@mock.patch('nova.api.openstack.common.get_instance')
|
||||
def test_shelve_policy_failed_with_other_project(self, get_instance_mock):
|
||||
@@ -149,7 +148,7 @@ class ShelvePolicyEnforcementV21(test.NoDBTestCase):
|
||||
|
||||
self.assertRaises(exception.Forbidden,
|
||||
self.controller._shelve_offload, self.req,
|
||||
str(uuid.uuid4()), {})
|
||||
uuidsentinel.fake, {})
|
||||
|
||||
def test_shelve_offload_policy_failed(self):
|
||||
rule_name = "os_compute_api:os-shelve:shelve_offload"
|
||||
@@ -167,7 +166,7 @@ class ShelvePolicyEnforcementV21(test.NoDBTestCase):
|
||||
policy.set_rules(oslo_policy.Rules.from_dict(rules))
|
||||
|
||||
self.assertRaises(exception.Forbidden, self.controller._unshelve,
|
||||
self.req, str(uuid.uuid4()), {})
|
||||
self.req, uuidsentinel.fake, {})
|
||||
|
||||
def test_unshelve_policy_failed(self):
|
||||
rule_name = "os_compute_api:os-shelve:unshelve"
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
# under the License.
|
||||
|
||||
import copy
|
||||
import uuid as stdlib_uuid
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
|
||||
@@ -23,6 +22,7 @@ from nova.api.openstack.compute import views
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import matchers
|
||||
from nova.tests import uuidsentinel as uuids
|
||||
from nova import wsgi
|
||||
|
||||
|
||||
@@ -259,7 +259,7 @@ class VersionsTestV21WithV2CompatibleWrapper(test.NoDBTestCase):
|
||||
self.assertEqual("application/json", res.content_type)
|
||||
|
||||
def test_multi_choice_server(self):
|
||||
uuid = str(stdlib_uuid.uuid4())
|
||||
uuid = uuids.fake
|
||||
req = fakes.HTTPRequest.blank('/servers/' + uuid, base_url='')
|
||||
req.accept = "application/json"
|
||||
res = req.get_response(self.wsgi_app)
|
||||
|
||||
Reference in New Issue
Block a user