Replace uuid.uuid4() with uuidutils.generate_uuid()
As of now, UUID is being generated using either uuid.uuid4() or uuidutils.generate_uuid(). In order to maintain consistency, we propose to use uuidutils.generate_uuid() from oslo_utils. Change-Id: I60ed3771d98a9c9893750d02d601c0dbaaec393b Closes-bug: #1082248
This commit is contained in:
parent
0de0c4f2c8
commit
7fa12bda72
@ -14,10 +14,10 @@
|
||||
#
|
||||
|
||||
import copy
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
from requests import Response
|
||||
|
||||
from moganclient.common import base
|
||||
@ -171,9 +171,9 @@ class FakeFlavor(object):
|
||||
"description": "fake_description",
|
||||
"extra_specs": {"key0": "value0"},
|
||||
"is_public": True,
|
||||
"name": "flavor-name-" + uuid.uuid4().hex,
|
||||
"name": "flavor-name-" + uuidutils.generate_uuid(dashed=False),
|
||||
"updated_at": None,
|
||||
"uuid": "flavor-id-" + uuid.uuid4().hex,
|
||||
"uuid": "flavor-id-" + uuidutils.generate_uuid(dashed=False),
|
||||
}
|
||||
|
||||
# Overwrite default attributes.
|
||||
@ -247,14 +247,19 @@ class FakeServer(object):
|
||||
server_info = {
|
||||
"created_at": "2016-11-14T08:03:18.926737+00:00",
|
||||
"description": "fake_description",
|
||||
"image_uuid": "image-id-" + uuid.uuid4().hex,
|
||||
"instance_type_uuid": "server-type-id-" + uuid.uuid4().hex,
|
||||
"image_uuid": "image-id-" + uuidutils.generate_uuid(dashed=False),
|
||||
"instance_type_uuid": "server-type-id-" + uuidutils.generate_uuid(
|
||||
dashed=False),
|
||||
"links": [],
|
||||
"name": "server-name-" + uuid.uuid4().hex,
|
||||
"network_info": {"net-id-" + uuid.uuid4().hex: {}},
|
||||
"name": "server-name-" + uuidutils.generate_uuid(
|
||||
dashed=False),
|
||||
"network_info": {"net-id-" + uuidutils.generate_uuid(
|
||||
dashed=False): {}},
|
||||
"updated_at": None,
|
||||
"uuid": "server-id-" + uuid.uuid4().hex,
|
||||
"availability_zone": "zone-name-" + uuid.uuid4().hex,
|
||||
"uuid": "server-id-" + uuidutils.generate_uuid(
|
||||
dashed=False),
|
||||
"availability_zone": "zone-name-" + uuidutils.generate_uuid(
|
||||
dashed=False),
|
||||
'extra': "fake_extra"
|
||||
}
|
||||
|
||||
|
@ -15,10 +15,10 @@
|
||||
|
||||
import copy
|
||||
import mock
|
||||
import uuid
|
||||
|
||||
from osc_lib import exceptions
|
||||
from osc_lib import utils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from moganclient.osc.v1 import server
|
||||
from moganclient.tests.unit import base as test_base
|
||||
@ -142,17 +142,23 @@ class TestServerCreate(TestServer):
|
||||
|
||||
def test_server_create(self, mock_create, mock_find):
|
||||
name = 'server1'
|
||||
flavor_id = 'flavor-id-' + uuid.uuid4().hex
|
||||
image_id = 'image-id-' + uuid.uuid4().hex
|
||||
networks = [{'net-id': 'net-id-' + uuid.uuid4().hex}]
|
||||
flavor_id = 'flavor-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)
|
||||
image_id = 'image-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)
|
||||
networks = [{'net-id': 'net-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)}]
|
||||
self._test_create_fake_server(mock_create, mock_find,
|
||||
name, flavor_id, image_id, networks)
|
||||
|
||||
def test_server_create_with_description(self, mock_create, mock_find):
|
||||
name = 'server1'
|
||||
flavor_id = 'flavor-id-' + uuid.uuid4().hex
|
||||
image_id = 'image-id-' + uuid.uuid4().hex
|
||||
networks = [{'net-id': 'net-id-' + uuid.uuid4().hex}]
|
||||
flavor_id = 'flavor-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)
|
||||
image_id = 'image-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)
|
||||
networks = [{'net-id': 'net-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)}]
|
||||
description = 'fake_description'
|
||||
self._test_create_fake_server(mock_create, mock_find,
|
||||
name, flavor_id, image_id,
|
||||
@ -160,9 +166,12 @@ class TestServerCreate(TestServer):
|
||||
|
||||
def test_server_create_with_az(self, mock_create, mock_find):
|
||||
name = 'server1'
|
||||
flavor_id = 'flavor-id-' + uuid.uuid4().hex
|
||||
image_id = 'image-id-' + uuid.uuid4().hex
|
||||
networks = [{'net-id': 'net-id-' + uuid.uuid4().hex}]
|
||||
flavor_id = 'flavor-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)
|
||||
image_id = 'image-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)
|
||||
networks = [{'net-id': 'net-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)}]
|
||||
fake_az = 'fake_availability_zone'
|
||||
self._test_create_fake_server(mock_create, mock_find,
|
||||
name, flavor_id, image_id,
|
||||
@ -170,9 +179,10 @@ class TestServerCreate(TestServer):
|
||||
|
||||
def test_server_create_with_port_type(self, mock_create, mock_find):
|
||||
name = 'server1'
|
||||
flavor_id = 'flavor-id-' + uuid.uuid4().hex
|
||||
image_id = 'image-id-' + uuid.uuid4().hex
|
||||
networks = [{'net-id': 'net-id-' + uuid.uuid4().hex,
|
||||
flavor_id = 'flavor-id-' + uuidutils.generate_uuid(dashed=False)
|
||||
image_id = 'image-id-' + uuidutils.generate_uuid(dashed=False)
|
||||
networks = [{'net-id': 'net-id-' + uuidutils.generate_uuid(
|
||||
dashed=False),
|
||||
'port-type': 'normal'}]
|
||||
self._test_create_fake_server(mock_create, mock_find,
|
||||
name, flavor_id, image_id,
|
||||
@ -180,9 +190,10 @@ class TestServerCreate(TestServer):
|
||||
|
||||
def test_server_create_with_extra(self, mock_create, mock_find):
|
||||
name = 'server1'
|
||||
flavor_id = 'flavor-id-' + uuid.uuid4().hex
|
||||
image_id = 'image-id-' + uuid.uuid4().hex
|
||||
networks = [{'net-id': 'net-id-' + uuid.uuid4().hex}]
|
||||
flavor_id = 'flavor-id-' + uuidutils.generate_uuid(dashed=False)
|
||||
image_id = 'image-id-' + uuidutils.generate_uuid(dashed=False)
|
||||
networks = [{'net-id': 'net-id-' + uuidutils.generate_uuid(
|
||||
dashed=False)}]
|
||||
extra_info = 'key1=test'
|
||||
self._test_create_fake_server(mock_create, mock_find,
|
||||
name, flavor_id, image_id,
|
||||
|
Loading…
x
Reference in New Issue
Block a user