Replace uuid.uuid4() with uuidutils.generate_uuid()
oslo.utils has a generate_uuid function for generating UUIDs. We should use that function when generating UUIDs for consistency. Change-Id: Ibf36852e71d716a52a9e231ca2054dd6988771c1
This commit is contained in:
parent
4de8370c02
commit
3ac9197588
|
@ -13,10 +13,10 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
# FIXME: https://bugs.launchpad.net/climate/+bug/1300132
|
||||
# from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects.mysql import MEDIUMTEXT
|
||||
from sqlalchemy.orm import relationship
|
||||
|
@ -29,7 +29,7 @@ from blazar.db.sqlalchemy import model_base as mb
|
|||
|
||||
|
||||
def _generate_unicode_uuid():
|
||||
return unicode(str(uuid.uuid4()))
|
||||
return unicode(uuidutils.generate_uuid())
|
||||
|
||||
|
||||
def MediumText():
|
||||
|
|
|
@ -14,14 +14,12 @@
|
|||
# limitations under the License.
|
||||
|
||||
"""Base classes for API tests."""
|
||||
import uuid
|
||||
|
||||
from keystonemiddleware import fixture
|
||||
from oslo_utils import uuidutils
|
||||
import pecan
|
||||
import pecan.testing
|
||||
import six
|
||||
|
||||
|
||||
from blazar.api import context as api_context
|
||||
from blazar import context
|
||||
from blazar.manager.oshosts import rpcapi as hosts_rpcapi
|
||||
|
@ -34,8 +32,8 @@ PATH_PREFIX = '/v2'
|
|||
class APITest(tests.TestCase):
|
||||
"""Used for unittests tests of Pecan controllers."""
|
||||
|
||||
ADMIN_TOKEN = uuid.uuid4().hex
|
||||
MEMBER_TOKEN = uuid.uuid4().hex
|
||||
ADMIN_TOKEN = uuidutils.generate_uuid(dashed=False)
|
||||
MEMBER_TOKEN = uuidutils.generate_uuid(dashed=False)
|
||||
|
||||
# SOURCE_DATA = {'test_source': {'somekey': '666'}}
|
||||
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
"""
|
||||
Tests for API /os-hosts/ methods
|
||||
"""
|
||||
import uuid
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
|
||||
|
@ -206,7 +205,7 @@ class TestCreateHost(api.APITest):
|
|||
def setUp(self):
|
||||
super(TestCreateHost, self).setUp()
|
||||
|
||||
self.id1 = six.text_type(uuid.uuid4())
|
||||
self.id1 = six.text_type(uuidutils.generate_uuid())
|
||||
self.fake_computehost = fake_computehost(id=self.id1)
|
||||
self.fake_computehost_body = fake_computehost_request_body(id=self.id1)
|
||||
self.path = '/os-hosts'
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
"""
|
||||
Tests for API /leases/ methods
|
||||
"""
|
||||
import uuid
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
|
||||
|
@ -108,8 +107,8 @@ class TestListLeases(api.APITest):
|
|||
self.assertEqual([self.fake_lease], response)
|
||||
|
||||
def test_multiple(self):
|
||||
id1 = six.text_type(uuid.uuid4())
|
||||
id2 = six.text_type(uuid.uuid4())
|
||||
id1 = six.text_type(uuidutils.generate_uuid())
|
||||
id2 = six.text_type(uuidutils.generate_uuid())
|
||||
self.patch(
|
||||
self.rpcapi, 'list_leases').return_value = [
|
||||
fake_lease(id=id1),
|
||||
|
@ -139,7 +138,7 @@ class TestShowLease(api.APITest):
|
|||
def setUp(self):
|
||||
super(TestShowLease, self).setUp()
|
||||
|
||||
self.id1 = six.text_type(uuid.uuid4())
|
||||
self.id1 = six.text_type(uuidutils.generate_uuid())
|
||||
self.fake_lease = fake_lease(id=self.id1)
|
||||
self.path = '/leases/{0}'.format(self.id1)
|
||||
self.patch(self.rpcapi, 'get_lease').return_value = self.fake_lease
|
||||
|
@ -182,7 +181,7 @@ class TestCreateLease(api.APITest):
|
|||
def setUp(self):
|
||||
super(TestCreateLease, self).setUp()
|
||||
|
||||
self.id1 = six.text_type(uuid.uuid4())
|
||||
self.id1 = six.text_type(uuidutils.generate_uuid())
|
||||
self.fake_lease = fake_lease(id=self.id1)
|
||||
self.fake_lease_body = fake_lease_request_body(id=self.id1)
|
||||
self.path = '/leases'
|
||||
|
@ -259,7 +258,7 @@ class TestUpdateLease(api.APITest):
|
|||
def setUp(self):
|
||||
super(TestUpdateLease, self).setUp()
|
||||
|
||||
self.id1 = six.text_type(uuid.uuid4())
|
||||
self.id1 = six.text_type(uuidutils.generate_uuid())
|
||||
self.fake_lease = fake_lease(id=self.id1, name='updated')
|
||||
self.fake_lease_body = fake_lease_request_body(
|
||||
exclude=['reservations', 'events'],
|
||||
|
@ -337,7 +336,7 @@ class TestDeleteLease(api.APITest):
|
|||
def setUp(self):
|
||||
super(TestDeleteLease, self).setUp()
|
||||
|
||||
self.id1 = six.text_type(uuid.uuid4())
|
||||
self.id1 = six.text_type(uuidutils.generate_uuid())
|
||||
self.path = '/leases/{0}'.format(self.id1)
|
||||
self.patch(self.rpcapi, 'delete_lease')
|
||||
|
||||
|
|
|
@ -15,7 +15,8 @@
|
|||
|
||||
import datetime
|
||||
import operator
|
||||
import uuid
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from blazar.db import exceptions as db_exceptions
|
||||
from blazar.db.sqlalchemy import api as db_api
|
||||
|
@ -25,7 +26,7 @@ from blazar import tests
|
|||
|
||||
|
||||
def _get_fake_random_uuid():
|
||||
return str(uuid.uuid4())
|
||||
return uuidutils.generate_uuid()
|
||||
|
||||
|
||||
def _get_fake_lease_uuid():
|
||||
|
|
|
@ -15,9 +15,9 @@
|
|||
# under the License.
|
||||
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
from oslo_context import context
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from blazar.db.sqlalchemy import api as db_api
|
||||
from blazar.db.sqlalchemy import utils as db_utils
|
||||
|
@ -25,7 +25,7 @@ from blazar import tests
|
|||
|
||||
|
||||
def _get_fake_random_uuid():
|
||||
return unicode(str(uuid.uuid4()))
|
||||
return unicode(uuidutils.generate_uuid())
|
||||
|
||||
|
||||
def _get_fake_lease_uuid():
|
||||
|
|
Loading…
Reference in New Issue