From 84a549116709827180353782d11b1c9a257ddd8d Mon Sep 17 00:00:00 2001 From: Sharat Sharma Date: Fri, 18 Nov 2016 14:21:55 +0530 Subject: [PATCH] Replace uuid4() with generate_uuid() from oslo_utils UUID can be generated using uuid4() as well as uuidutils.generate_utils(). Since we are using the latter in the Mistral code, we shall maintain the same on the client as well. Change-Id: I65c27bb6253cecc80bd538ba6d59022141d22b6c Closes-Bug: #1082248 --- mistralclient/tests/unit/test_client.py | 8 ++++---- mistralclient/tests/unit/test_httpclient.py | 14 +++++++------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/mistralclient/tests/unit/test_client.py b/mistralclient/tests/unit/test_client.py index 6ee4b497..dee168d4 100644 --- a/mistralclient/tests/unit/test_client.py +++ b/mistralclient/tests/unit/test_client.py @@ -16,9 +16,9 @@ import json import os import tempfile -import uuid import mock +from oslo_utils import uuidutils from oslotest import base import osprofiler.profiler @@ -37,9 +37,9 @@ class BaseClientTests(base.BaseTestCase): @staticmethod def setup_keystone_mock(keystone_client_mock): keystone_client_instance = keystone_client_mock.return_value - keystone_client_instance.auth_token = str(uuid.uuid4()) - keystone_client_instance.project_id = str(uuid.uuid4()) - keystone_client_instance.user_id = str(uuid.uuid4()) + keystone_client_instance.auth_token = uuidutils.generate_uuid() + keystone_client_instance.project_id = uuidutils.generate_uuid() + keystone_client_instance.user_id = uuidutils.generate_uuid() keystone_client_instance.auth_ref = str(json.dumps({})) return keystone_client_instance diff --git a/mistralclient/tests/unit/test_httpclient.py b/mistralclient/tests/unit/test_httpclient.py index 5cc1f7bc..da34472c 100644 --- a/mistralclient/tests/unit/test_httpclient.py +++ b/mistralclient/tests/unit/test_httpclient.py @@ -14,12 +14,12 @@ import base64 import copy -import uuid import mock from oslotest import base import requests +from oslo_utils import uuidutils from osprofiler import _utils as osprofiler_utils import osprofiler.profiler @@ -30,11 +30,11 @@ API_URL = '/executions' EXPECTED_URL = API_BASE_URL + API_URL -AUTH_TOKEN = str(uuid.uuid4()) -PROJECT_ID = str(uuid.uuid4()) -USER_ID = str(uuid.uuid4()) +AUTH_TOKEN = uuidutils.generate_uuid() +PROJECT_ID = uuidutils.generate_uuid() +USER_ID = uuidutils.generate_uuid() PROFILER_HMAC_KEY = 'SECRET_HMAC_KEY' -PROFILER_TRACE_ID = str(uuid.uuid4()) +PROFILER_TRACE_ID = uuidutils.generate_uuid() EXPECTED_AUTH_HEADERS = { 'x-auth-token': AUTH_TOKEN, @@ -134,8 +134,8 @@ class HTTPClientTest(base.BaseTestCase): mock.MagicMock(return_value=FakeResponse('get', EXPECTED_URL, 200)) ) def test_get_request_options_with_headers_for_get(self): - target_auth_url = str(uuid.uuid4()) - target_auth_token = str(uuid.uuid4()) + target_auth_url = uuidutils.generate_uuid() + target_auth_token = uuidutils.generate_uuid() target_user_id = 'target_user' target_project_id = 'target_project' target_service_catalog = 'this should be there'