Replace uuid.uuid4().hex with uuidutils.generate_uuid()
Openstack common has a wrapper for generating uuids. We should use that function to generate uuids for consistency. Change-Id: If31cc81bbf2f386db660a760eb866c7c1abd786a
This commit is contained in:
parent
9b966b4912
commit
609045ebb2
@ -11,9 +11,9 @@
|
||||
# the License.
|
||||
import json
|
||||
import logging
|
||||
from oslo_utils import uuidutils
|
||||
import requests
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
try:
|
||||
import SimpleHTTPServer
|
||||
@ -72,7 +72,7 @@ class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-Project-ID': self.headers['x-project-id'],
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'URL-Methods': self.headers['url-methods'],
|
||||
'URL-Signature': self.headers['url-signature'],
|
||||
'URL-Paths': self.headers['url-paths'],
|
||||
|
@ -11,9 +11,9 @@
|
||||
# the License.
|
||||
import json
|
||||
import logging
|
||||
from oslo_utils import uuidutils
|
||||
import requests
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
try:
|
||||
import SimpleHTTPServer
|
||||
@ -65,7 +65,7 @@ class ServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
'X-Project-ID': self.data['X-Project-ID'],
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'URL-Methods': self.data['URL-Methods'],
|
||||
'URL-Signature': self.data['URL-Signature'],
|
||||
'URL-Paths': self.data['URL-Paths'],
|
||||
|
@ -19,11 +19,11 @@
|
||||
import abc
|
||||
import functools
|
||||
import time
|
||||
import uuid
|
||||
|
||||
import enum
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from zaqar.common import decorators
|
||||
@ -138,9 +138,9 @@ class DataDriverBase(DriverBase):
|
||||
status_template = lambda s, t, r: {'succeeded': s,
|
||||
'seconds': t,
|
||||
'ref': r}
|
||||
project = str(uuid.uuid4())
|
||||
queue = str(uuid.uuid4())
|
||||
client = str(uuid.uuid4())
|
||||
project = uuidutils.generate_uuid()
|
||||
queue = uuidutils.generate_uuid()
|
||||
client = uuidutils.generate_uuid()
|
||||
msg_template = lambda s: {'ttl': 600, 'body': {'event': 'p_%s' % s}}
|
||||
messages = [msg_template(i) for i in range(100)]
|
||||
claim_metadata = {'ttl': 60, 'grace': 300}
|
||||
@ -155,7 +155,7 @@ class DataDriverBase(DriverBase):
|
||||
start = time.time()
|
||||
result = callable_operation()
|
||||
except Exception as e:
|
||||
ref = str(uuid.uuid4())
|
||||
ref = uuidutils.generate_uuid()
|
||||
LOG.exception(e, extra={'instance_uuid': ref})
|
||||
succeeded = False
|
||||
status = status_template(succeeded, time.time() - start, ref)
|
||||
|
@ -20,6 +20,7 @@ import uuid
|
||||
import msgpack
|
||||
from oslo_utils import encodeutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
MSGENV_FIELD_KEYS = (b'id', b't', b'cr', b'e', b'u', b'c', b'c.e')
|
||||
SUBENV_FIELD_KEYS = (b'id', b's', b'u', b't', b'e', b'o', b'p', b'c')
|
||||
@ -50,7 +51,7 @@ class MessageEnvelope(object):
|
||||
]
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.id = _validate_uuid4(kwargs.get('id', str(uuid.uuid4())))
|
||||
self.id = _validate_uuid4(kwargs.get('id', uuidutils.generate_uuid()))
|
||||
self.ttl = kwargs['ttl']
|
||||
self.created = kwargs['created']
|
||||
self.expires = kwargs.get('expires', self.created + self.ttl)
|
||||
@ -119,7 +120,7 @@ class SubscriptionEnvelope(object):
|
||||
]
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.id = kwargs.get('id', str(uuid.uuid4()))
|
||||
self.id = kwargs.get('id', uuidutils.generate_uuid())
|
||||
self.source = kwargs['source']
|
||||
self.subscriber = kwargs['subscriber']
|
||||
self.ttl = kwargs['ttl']
|
||||
|
@ -13,10 +13,10 @@
|
||||
# the License.
|
||||
|
||||
import functools
|
||||
import uuid
|
||||
|
||||
import msgpack
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import redis
|
||||
|
||||
from zaqar.common import utils as common_utils
|
||||
@ -106,7 +106,7 @@ class SubscriptionController(base.Subscription):
|
||||
@utils.raises_conn_error
|
||||
@utils.retries_on_connection_error
|
||||
def create(self, queue, subscriber, ttl, options, project=None):
|
||||
subscription_id = str(uuid.uuid4())
|
||||
subscription_id = uuidutils.generate_uuid()
|
||||
subset_key = utils.scope_subscription_ids_set(queue,
|
||||
project,
|
||||
SUBSCRIPTION_IDS_SUFFIX)
|
||||
|
@ -14,7 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from testtools import testcase
|
||||
import websocket
|
||||
@ -31,8 +31,8 @@ class TestQueues(base.V1_1FunctionalTestBase):
|
||||
if not base._TEST_INTEGRATION:
|
||||
raise testcase.TestSkipped('Only run in integration mode')
|
||||
super(TestQueues, self).setUp()
|
||||
self.project_id = str(uuid.uuid4())
|
||||
self.headers = {'Client-ID': str(uuid.uuid4()),
|
||||
self.project_id = uuidutils.generate_uuid()
|
||||
self.headers = {'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id}
|
||||
self.client = websocket.create_connection('ws://localhost:9000/')
|
||||
self.addCleanup(self.client.close)
|
||||
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import uuid
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from oslo_serialization import jsonutils as json
|
||||
from six.moves.urllib import parse as urllib
|
||||
@ -36,7 +36,7 @@ class MessagingClient(rest_client.RestClient):
|
||||
self.version = '1'
|
||||
self.uri_prefix = 'v{0}'.format(self.version)
|
||||
|
||||
client_id = uuid.uuid4().hex
|
||||
client_id = uuidutils.generate_uuid(dashed=False)
|
||||
self.headers = {'Client-ID': client_id}
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import uuid
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from tempest import config
|
||||
from tempest.lib.common.utils import data_utils
|
||||
@ -281,7 +281,7 @@ class TestClaimsNegative(base.BaseV2MessagingTest):
|
||||
def test_query_from_a_nonexistent_queue(self):
|
||||
# Query claim a non existent queue
|
||||
non_existent_queue = data_utils.rand_name('rand_queuename')
|
||||
non_existent_id = str(uuid.uuid4())
|
||||
non_existent_id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/claims/{1}".format(non_existent_queue,
|
||||
non_existent_id)
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
@ -291,7 +291,7 @@ class TestClaimsNegative(base.BaseV2MessagingTest):
|
||||
@decorators.idempotent_id('a2af8e9b-08fb-4079-a77a-28c0390a614a')
|
||||
def test_query_claim_with_non_existing_claim_id(self):
|
||||
# Query claim using a non existing claim id
|
||||
non_existent_id = str(uuid.uuid4())
|
||||
non_existent_id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/claims/{1}".format(self.queue_name,
|
||||
non_existent_id)
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
@ -332,7 +332,7 @@ class TestClaimsNegative(base.BaseV2MessagingTest):
|
||||
claim_ttl = data_utils.rand_int_id(start=60,
|
||||
end=CONF.messaging.max_claim_ttl)
|
||||
update_rbody = {"ttl": claim_ttl}
|
||||
claim_id = str(uuid.uuid4())
|
||||
claim_id = uuidutils.generate_uuid()
|
||||
claim_uri = "/v2/queues/{0}/claims/{1}".format(self.queue_name,
|
||||
claim_id)
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
@ -381,7 +381,7 @@ class TestClaimsNegative(base.BaseV2MessagingTest):
|
||||
def test_release_claim_from_a_non_existing_queue(self):
|
||||
# Release claim from a non existing queue
|
||||
non_existent_queue = data_utils.rand_name('rand_queuename')
|
||||
non_existent_id = str(uuid.uuid4())
|
||||
non_existent_id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/claims/{1}".format(non_existent_queue,
|
||||
non_existent_id)
|
||||
resp, body = self.client.delete_claim(uri)
|
||||
@ -391,7 +391,7 @@ class TestClaimsNegative(base.BaseV2MessagingTest):
|
||||
@decorators.idempotent_id('20a6e6ed-0f53-484d-aa78-717cdaa25e50')
|
||||
def test_release_a_nonexisting_claim_id(self):
|
||||
# Release a non existing claim
|
||||
non_existent_id = str(uuid.uuid4())
|
||||
non_existent_id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/claims/{1}".format(self.queue_name,
|
||||
non_existent_id)
|
||||
resp, body = self.client.delete_claim(uri)
|
||||
|
@ -14,8 +14,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
import random
|
||||
import uuid
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from six import moves
|
||||
from tempest import config
|
||||
from tempest.lib.common.utils import data_utils
|
||||
@ -45,7 +45,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
@decorators.idempotent_id('8246ee51-651c-4e2a-9a07-91848ca5e1e4')
|
||||
def test_request_single_message_from_a_nonexistent_queue(self):
|
||||
# List a message from a nonexistent queue
|
||||
id = str(uuid.uuid4())
|
||||
id = uuidutils.generate_uuid()
|
||||
non_existent_queue = data_utils.rand_name('rand_queuename')
|
||||
uri = "/v2/queues/{0}/messages/{1}".format(non_existent_queue, id)
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
@ -55,7 +55,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
@decorators.idempotent_id('767fdad1-37df-485a-8063-5036e8d16a12')
|
||||
def test_request_a_non_existing_message(self):
|
||||
# List a message with an invalid id
|
||||
invalid_id = str(uuid.uuid4())
|
||||
invalid_id = uuidutils.generate_uuid()
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
uri = "/v2/queues/{0}/messages/{1}".format(queue_name, invalid_id)
|
||||
@ -80,7 +80,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
# List a message without a valid token
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
id = str(uuid.uuid4())
|
||||
id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/messages/{1}".format(queue_name, id)
|
||||
self.client.auth_provider.set_alt_auth_data(
|
||||
request_part='headers',
|
||||
@ -95,8 +95,8 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
@decorators.idempotent_id('f544e745-f3da-451d-8621-c3711cd37453')
|
||||
def test_request_multiple_messages_from_a_nonexistent_queue(self):
|
||||
# List multiple messages from a non existent queue
|
||||
id1 = str(uuid.uuid4())
|
||||
id2 = str(uuid.uuid4())
|
||||
id1 = uuidutils.generate_uuid()
|
||||
id2 = uuidutils.generate_uuid()
|
||||
queue = data_utils.rand_name('nonexistent_queue')
|
||||
uri = "/v2/queues/{0}/messages?ids={1},{2}".format(queue,
|
||||
id1, id2)
|
||||
@ -107,7 +107,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
@decorators.idempotent_id('654e64f8-01df-40a0-a09e-d5ec17a3e187')
|
||||
def test_request_multiple_messages_with_invalid_message_id(self):
|
||||
# List multiple messages by passing invalid id
|
||||
invalid_id = str(uuid.uuid4())
|
||||
invalid_id = uuidutils.generate_uuid()
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
uri = "/v2/queues/{0}/messages?ids={1},{2}".format(queue_name,
|
||||
@ -122,7 +122,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
# Default limit value is 20 , configurable
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
ids = str.join(',', (str(uuid.uuid4())) * 21)
|
||||
ids = str.join(',', (uuidutils.generate_uuid()) * 21)
|
||||
uri = "/v2/queues/{0}/messages?ids={1}".format(queue_name, ids)
|
||||
self.assertRaises(lib_exc.BadRequest,
|
||||
self.client.show_multiple_messages, uri)
|
||||
@ -180,8 +180,8 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
# List messages without a valid token
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
id1 = str(uuid.uuid4())
|
||||
id2 = str(uuid.uuid4())
|
||||
id1 = uuidutils.generate_uuid()
|
||||
id2 = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/messages/{1},{2}".format(queue_name, id1, id2)
|
||||
self.client.auth_provider.set_alt_auth_data(
|
||||
request_part='headers',
|
||||
@ -440,7 +440,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
def test_delete_message_from_a_nonexistent_queue(self):
|
||||
# Delete is an idempotent operation
|
||||
non_existent_queue = data_utils.rand_name('rand_queuename')
|
||||
message_id = str(uuid.uuid4())
|
||||
message_id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/messages?ids={1}".format(non_existent_queue,
|
||||
message_id)
|
||||
resp, _ = self.client.delete_messages(uri)
|
||||
@ -452,7 +452,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
# Delete is an idempotent operation
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
message_id = str(uuid.uuid4())
|
||||
message_id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/messages?ids={1}".format(queue_name,
|
||||
message_id)
|
||||
resp, _ = self.client.delete_messages(uri)
|
||||
@ -464,7 +464,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
# Delete is an idempotent operation
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
message_id = str(uuid.uuid4())
|
||||
message_id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/messages/{1}".format(queue_name,
|
||||
message_id)
|
||||
resp, _ = self.client.delete_messages(uri)
|
||||
@ -476,9 +476,9 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
# Delete is an idempotent operation
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
id1 = str(uuid.uuid4())
|
||||
id2 = str(uuid.uuid4())
|
||||
id3 = str(uuid.uuid4())
|
||||
id1 = uuidutils.generate_uuid()
|
||||
id2 = uuidutils.generate_uuid()
|
||||
id3 = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/messages?ids={1}{2}{3}".format(queue_name,
|
||||
id1, id2, id3)
|
||||
resp, _ = self.client.delete_messages(uri)
|
||||
@ -504,7 +504,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
# Delete a message with negative id
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
message_id = str(uuid.uuid4())
|
||||
message_id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/messages?ids=-{1}".format(queue_name,
|
||||
message_id)
|
||||
resp, _ = self.client.delete_messages(uri)
|
||||
@ -516,7 +516,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
# Delete is an idempotent operation
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
message_id = str(uuid.uuid4())
|
||||
message_id = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/messages?ids={1}".format(queue_name,
|
||||
message_id)
|
||||
resp, _ = self.client.delete_messages(uri)
|
||||
@ -530,7 +530,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
# Default limit value is 20
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
ids = str.join(',', (str(uuid.uuid4())) * 21)
|
||||
ids = str.join(',', (uuidutils.generate_uuid()) * 21)
|
||||
uri = "/v2/queues/{0}/messages?ids={1}".format(queue_name, ids)
|
||||
self.assertRaises(lib_exc.BadRequest,
|
||||
self.client.delete_messages, uri)
|
||||
@ -616,7 +616,7 @@ class TestMessagesNegative(base.BaseV2MessagingTest):
|
||||
queue_name = self.queues[data_utils.rand_int_id(0,
|
||||
len(self.queues) - 1)]
|
||||
pop_value = 5
|
||||
ids_value = str(uuid.uuid4())
|
||||
ids_value = uuidutils.generate_uuid()
|
||||
uri = "/v2/queues/{0}/messages?pop={1}&ids={2}".format(queue_name,
|
||||
pop_value,
|
||||
ids_value)
|
||||
|
@ -14,8 +14,8 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from tempest.lib.common.utils import data_utils
|
||||
from tempest.lib.common.utils import test_utils
|
||||
from tempest.lib import decorators
|
||||
@ -125,7 +125,7 @@ class TestSubscriptions(base.BaseV2MessagingTest):
|
||||
post_body = json.dumps(
|
||||
{'messages': [{'body': '$zaqar_message$', 'ttl': 60}]})
|
||||
post_headers = {'X-Project-ID': self.client.tenant_id,
|
||||
'Client-ID': str(uuid.uuid4())}
|
||||
'Client-ID': uuidutils.generate_uuid()}
|
||||
sub_body = {'ttl': 1200, 'subscriber': subscriber,
|
||||
'options': {'post_data': post_body,
|
||||
'post_headers': post_headers}}
|
||||
|
@ -13,7 +13,7 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import uuid
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from tempest import config
|
||||
from tempest.lib.common.utils import data_utils
|
||||
@ -251,7 +251,7 @@ class TestSubscriptionsNegative(base.BaseV2MessagingTest):
|
||||
def test_update_subscription_with_invalid_id(self):
|
||||
# Update subscription using invalid id
|
||||
results = self._create_subscriptions()
|
||||
subscription_id = str(uuid.uuid4())
|
||||
subscription_id = uuidutils.generate_uuid()
|
||||
update_rbody = {'ttl': 100}
|
||||
self.assertRaises(lib_exc.NotFound,
|
||||
self.client.update_subscription, self.queue_name,
|
||||
@ -341,7 +341,7 @@ class TestSubscriptionsNegative(base.BaseV2MessagingTest):
|
||||
def test_delete_subscription_using_a_nonexisting_id(self):
|
||||
# Delete subscription with non existent id
|
||||
results = self._create_subscriptions()
|
||||
subscription_id = str(uuid.uuid4())
|
||||
subscription_id = uuidutils.generate_uuid()
|
||||
resp, _ = self.client.delete_subscription(self.queue_name,
|
||||
subscription_id)
|
||||
self.assertEqual('204', resp['status'])
|
||||
|
@ -343,7 +343,7 @@ class RedisMessagesTest(base.MessageControllerTest):
|
||||
self.queue_controller.create(self.queue_name)
|
||||
self.controller.post(self.queue_name,
|
||||
[{'ttl': 0, 'body': {}}],
|
||||
client_uuid=str(uuid.uuid4()))
|
||||
client_uuid=uuidutils.generate_uuid())
|
||||
|
||||
num_removed = self.controller.gc()
|
||||
self.assertEqual(1, num_removed)
|
||||
@ -351,7 +351,7 @@ class RedisMessagesTest(base.MessageControllerTest):
|
||||
for _ in range(100):
|
||||
self.controller.post(self.queue_name,
|
||||
[{'ttl': 0, 'body': {}}],
|
||||
client_uuid=str(uuid.uuid4()))
|
||||
client_uuid=uuidutils.generate_uuid())
|
||||
|
||||
num_removed = self.controller.gc()
|
||||
self.assertEqual(100, num_removed)
|
||||
@ -421,7 +421,7 @@ class RedisClaimsTest(base.ClaimControllerTest):
|
||||
{'ttl': 60, 'body': {}},
|
||||
{'ttl': 60, 'body': {}}]
|
||||
self.message_controller.post(queue_name, new_messages,
|
||||
client_uuid=str(uuid.uuid1()),
|
||||
client_uuid=str(uuid.uuid4()),
|
||||
project='fake_project')
|
||||
claim_id, messages = self.controller.create(queue_name, {'ttl': 1,
|
||||
'grace': 0},
|
||||
@ -438,7 +438,7 @@ class RedisClaimsTest(base.ClaimControllerTest):
|
||||
for _ in range(100):
|
||||
self.message_controller.post(self.queue_name,
|
||||
[{'ttl': 300, 'body': 'yo gabba'}],
|
||||
client_uuid=str(uuid.uuid4()))
|
||||
client_uuid=uuidutils.generate_uuid())
|
||||
|
||||
now = timeutils.utcnow_ts()
|
||||
timeutils_utcnow = 'oslo_utils.timeutils.utcnow_ts'
|
||||
|
@ -14,11 +14,11 @@
|
||||
# under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from zaqar.tests.unit.transport.websocket import base
|
||||
from zaqar.tests.unit.transport.websocket import utils as test_utils
|
||||
|
||||
@ -32,7 +32,7 @@ class TestMessagingProtocol(base.TestBase):
|
||||
self.protocol = self.transport.factory()
|
||||
self.project_id = 'protocol-test'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
from keystonemiddleware import auth_token
|
||||
import mock
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from zaqar.common import consts
|
||||
from zaqar.common import urls
|
||||
from zaqar.tests.unit.transport.websocket import base
|
||||
@ -39,7 +39,7 @@ class AuthTest(base.V2Base):
|
||||
|
||||
self.project_id = '7e55e1a7e'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
auth_mock = mock.patch.object(auth_token.AuthProtocol, '__call__')
|
||||
|
@ -13,11 +13,11 @@
|
||||
# the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar.common import consts
|
||||
from zaqar.tests.unit.transport.websocket import base
|
||||
@ -36,7 +36,7 @@ class ClaimsBaseTest(base.V1_1Base):
|
||||
|
||||
self.project_id = '7e55e1a7e'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
|
||||
@ -247,7 +247,7 @@ class ClaimsBaseTest(base.V1_1Base):
|
||||
"echo": False}
|
||||
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ class ClaimsBaseTest(base.V1_1Base):
|
||||
|
||||
# Try to get it from the wrong project
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'someproject'
|
||||
}
|
||||
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from testtools import matchers
|
||||
|
||||
@ -42,7 +42,7 @@ class MessagesBaseTest(base.V2Base):
|
||||
|
||||
self.project_id = '7e55e1a7e'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,11 @@
|
||||
# the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import mock
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from zaqar.common import consts
|
||||
from zaqar.storage import errors as storage_errors
|
||||
from zaqar import tests as testing
|
||||
@ -43,7 +43,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
"key3": [1, 2, 3, 4, 5]}
|
||||
}
|
||||
}
|
||||
headers = {'Client-ID': str(uuid.uuid4())}
|
||||
headers = {'Client-ID': uuidutils.generate_uuid()}
|
||||
req = test_utils.create_request(action, body, headers)
|
||||
|
||||
def validator(resp, isBinary):
|
||||
@ -60,7 +60,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
action = consts.QUEUE_GET_STATS
|
||||
body = {"queue_name": "gummybears"}
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': project_id
|
||||
}
|
||||
|
||||
@ -152,7 +152,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
|
||||
def test_name_restrictions(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'test-project'
|
||||
}
|
||||
action = consts.QUEUE_CREATE
|
||||
@ -194,7 +194,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
|
||||
def test_project_id_restriction(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'test-project' * 30
|
||||
}
|
||||
action = consts.QUEUE_CREATE
|
||||
@ -228,7 +228,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
(u'/queues/non-ascii-n\xc4me', 'iso8859-1'))
|
||||
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'test-project' * 30
|
||||
}
|
||||
action = consts.QUEUE_CREATE
|
||||
@ -254,7 +254,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
|
||||
def test_no_metadata(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'test-project'
|
||||
}
|
||||
action = consts.QUEUE_CREATE
|
||||
@ -283,7 +283,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
@ddt.data('{', '[]', '.', ' ')
|
||||
def test_bad_metadata(self, meta):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'test-project' * 30
|
||||
}
|
||||
action = consts.QUEUE_CREATE
|
||||
@ -305,7 +305,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
|
||||
def test_too_much_metadata(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'test-project'
|
||||
}
|
||||
action = consts.QUEUE_CREATE
|
||||
@ -332,7 +332,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
|
||||
def test_way_too_much_metadata(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'test-project'
|
||||
}
|
||||
action = consts.QUEUE_CREATE
|
||||
@ -360,7 +360,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
def test_update_metadata(self):
|
||||
self.skip("Implement patch method")
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'test-project'
|
||||
}
|
||||
action = consts.QUEUE_CREATE
|
||||
@ -438,7 +438,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
def test_list(self):
|
||||
arbitrary_number = 644079696574693
|
||||
project_id = str(arbitrary_number)
|
||||
client_id = str(uuid.uuid4())
|
||||
client_id = uuidutils.generate_uuid()
|
||||
headers = {
|
||||
'X-Project-ID': project_id,
|
||||
'Client-ID': client_id
|
||||
@ -569,7 +569,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
|
||||
def test_list_returns_503_on_nopoolfound_exception(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'test-project'
|
||||
}
|
||||
action = consts.QUEUE_LIST
|
||||
@ -621,7 +621,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
def test_purge(self):
|
||||
arbitrary_number = 644079696574693
|
||||
project_id = str(arbitrary_number)
|
||||
client_id = str(uuid.uuid4())
|
||||
client_id = uuidutils.generate_uuid()
|
||||
headers = {
|
||||
'X-Project-ID': project_id,
|
||||
'Client-ID': client_id
|
||||
|
@ -15,11 +15,11 @@
|
||||
|
||||
import json
|
||||
import time
|
||||
import uuid
|
||||
|
||||
import mock
|
||||
import msgpack
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from zaqar.common import auth
|
||||
from zaqar.common import consts
|
||||
from zaqar.storage import errors as storage_errors
|
||||
@ -38,7 +38,7 @@ class SubscriptionTest(base.V1_1Base):
|
||||
|
||||
self.project_id = '7e55e1a7e'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,11 @@
|
||||
# the License.
|
||||
|
||||
import six
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from falcon import testing as ftest
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar import bootstrap
|
||||
from zaqar.common import configs
|
||||
@ -56,7 +56,7 @@ class TestBase(testing.TestBase):
|
||||
self.srmock = ftest.StartResponseMock()
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-ROLES': 'admin',
|
||||
'X-USER-ID': 'a12d157c7d0d41999096639078fd11fc',
|
||||
'X-TENANT-ID': 'abb69142168841fcaa2785791b92467f',
|
||||
|
@ -14,11 +14,11 @@
|
||||
# limitations under the License.
|
||||
"""Test Auth."""
|
||||
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from falcon import testing
|
||||
from keystonemiddleware import auth_token
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
|
||||
@ -29,7 +29,7 @@ class TestAuth(base.V1Base):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAuth, self).setUp()
|
||||
self.headers = {'Client-ID': str(uuid.uuid4())}
|
||||
self.headers = {'Client-ID': uuidutils.generate_uuid()}
|
||||
|
||||
def test_auth_install(self):
|
||||
self.assertIsInstance(self.app._auth_app, auth_token.AuthProtocol)
|
||||
|
@ -14,13 +14,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from testtools import matchers
|
||||
|
||||
from zaqar import tests as testing
|
||||
@ -48,7 +48,8 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
|
||||
doc = jsonutils.dumps([{'body': 239, 'ttl': 300}] * 10)
|
||||
self.simulate_post(self.queue_path + '/messages', self.project_id,
|
||||
body=doc, headers={'Client-ID': str(uuid.uuid4())})
|
||||
body=doc, headers={'Client-ID':
|
||||
uuidutils.generate_uuid()})
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
def tearDown(self):
|
||||
@ -120,7 +121,7 @@ class TestClaimsMongoDB(base.V1Base):
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
}
|
||||
|
||||
# Listing messages, by default, won't include claimed
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import contextlib
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar import storage
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
@ -31,7 +31,7 @@ class TestDefaultLimits(base.V1Base):
|
||||
super(TestDefaultLimits, self).setUp()
|
||||
|
||||
self.queue_path = self.url_prefix + '/queues'
|
||||
self.q1_queue_path = self.queue_path + '/' + str(uuid.uuid4())
|
||||
self.q1_queue_path = self.queue_path + '/' + uuidutils.generate_uuid()
|
||||
self.messages_path = self.q1_queue_path + '/messages'
|
||||
self.claims_path = self.q1_queue_path + '/claims'
|
||||
|
||||
@ -58,7 +58,8 @@ class TestDefaultLimits(base.V1Base):
|
||||
self._prepare_messages(storage.DEFAULT_MESSAGES_PER_PAGE + 1)
|
||||
|
||||
result = self.simulate_get(self.messages_path,
|
||||
headers={'Client-ID': str(uuid.uuid4())})
|
||||
headers={'Client-ID':
|
||||
uuidutils.generate_uuid()})
|
||||
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
|
||||
@ -93,6 +94,6 @@ class TestDefaultLimits(base.V1Base):
|
||||
def _prepare_messages(self, count):
|
||||
doc = jsonutils.dumps([{'body': 239, 'ttl': 300}] * count)
|
||||
self.simulate_post(self.messages_path, body=doc,
|
||||
headers={'Client-ID': str(uuid.uuid4())})
|
||||
headers={'Client-ID': uuidutils.generate_uuid()})
|
||||
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
@ -13,11 +13,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from falcon import testing
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
@ -41,7 +41,7 @@ class TestMediaType(base.V1Base):
|
||||
|
||||
for method, endpoint in endpoints:
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'Accept': 'application/xml',
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ class TestMediaType(base.V1Base):
|
||||
eww_queue_messages_path = eww_queue_path + '/messages'
|
||||
sample_message = jsonutils.dumps([{'body': {'eww!'}, 'ttl': 200}])
|
||||
bad_headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
|
||||
|
@ -14,13 +14,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from testtools import matchers
|
||||
|
||||
@ -64,7 +64,7 @@ class TestMessagesMongoDB(base.V1Base):
|
||||
self.simulate_put(self.queue_path, body=doc)
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
}
|
||||
|
||||
def tearDown(self):
|
||||
@ -490,7 +490,7 @@ class TestMessagesFaultyDriver(base.V1BaseFaulty):
|
||||
path = self.url_prefix + '/queues/fizbit/messages'
|
||||
doc = '[{"body": 239, "ttl": 100}]'
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
}
|
||||
|
||||
self.simulate_post(path, project_id,
|
||||
|
@ -13,11 +13,11 @@
|
||||
# the License.
|
||||
|
||||
import contextlib
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar import tests as testing
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
@ -38,7 +38,7 @@ def pool(test, name, weight, uri, options={}):
|
||||
:returns: (name, weight, uri, options)
|
||||
:rtype: see above
|
||||
"""
|
||||
uri = "%s/%s" % (uri, str(uuid.uuid4()))
|
||||
uri = "%s/%s" % (uri, uuidutils.generate_uuid())
|
||||
doc = {'weight': weight, 'uri': uri, 'options': options}
|
||||
path = test.url_prefix + '/pools/' + name
|
||||
|
||||
@ -69,7 +69,7 @@ def pools(test, count, uri):
|
||||
{str(i): i})
|
||||
for i in range(count)]
|
||||
for path, weight, option in args:
|
||||
uri = "%s/%s" % (mongo_url, str(uuid.uuid4()))
|
||||
uri = "%s/%s" % (mongo_url, uuidutils.generate_uuid())
|
||||
doc = {'weight': weight, 'uri': uri, 'options': option}
|
||||
test.simulate_put(path, body=jsonutils.dumps(doc))
|
||||
|
||||
@ -89,7 +89,7 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
def setUp(self):
|
||||
super(TestPoolsMongoDB, self).setUp()
|
||||
self.doc = {'weight': 100, 'uri': self.mongodb_url}
|
||||
self.pool = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
self.pool = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(self.pool, body=jsonutils.dumps(self.doc))
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
@ -99,13 +99,13 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_put_pool_works(self):
|
||||
name = str(uuid.uuid1())
|
||||
name = uuidutils.generate_uuid()
|
||||
weight, uri = self.doc['weight'], self.doc['uri']
|
||||
with pool(self, name, weight, uri):
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
def test_put_raises_if_missing_fields(self):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(path, body=jsonutils.dumps({'weight': 100}))
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ -116,7 +116,7 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
|
||||
@ddt.data(-1, 2**32+1, 'big')
|
||||
def test_put_raises_if_invalid_weight(self, weight):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
doc = {'weight': weight, 'uri': 'a'}
|
||||
self.simulate_put(path,
|
||||
body=jsonutils.dumps(doc))
|
||||
@ -124,14 +124,14 @@ class TestPoolsMongoDB(base.V1Base):
|
||||
|
||||
@ddt.data(-1, 2**32+1, [], 'localhost:27017')
|
||||
def test_put_raises_if_invalid_uri(self, uri):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(path,
|
||||
body=jsonutils.dumps({'weight': 1, 'uri': uri}))
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 'wee', [])
|
||||
def test_put_raises_if_invalid_options(self, options):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
doc = {'weight': 1, 'uri': 'a', 'options': options}
|
||||
self.simulate_put(path, body=jsonutils.dumps(doc))
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
@ -14,7 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
import falcon
|
||||
|
||||
@ -34,7 +34,7 @@ class TestValidation(base.V1Base):
|
||||
self.simulate_put(self.queue_path, self.project_id)
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
}
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -14,11 +14,11 @@
|
||||
# limitations under the License.
|
||||
"""Test Auth."""
|
||||
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from falcon import testing
|
||||
from keystonemiddleware import auth_token
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
|
||||
@ -29,7 +29,7 @@ class TestAuth(base.V1_1Base):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAuth, self).setUp()
|
||||
self.headers = {'Client-ID': str(uuid.uuid4())}
|
||||
self.headers = {'Client-ID': uuidutils.generate_uuid()}
|
||||
|
||||
def test_auth_install(self):
|
||||
self.assertIsInstance(self.app._auth_app, auth_token.AuthProtocol)
|
||||
|
@ -15,13 +15,13 @@
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from testtools import matchers
|
||||
|
||||
from zaqar import tests as testing
|
||||
@ -40,7 +40,7 @@ class TestClaimsMongoDB(base.V1_1Base):
|
||||
self.default_claim_ttl = self.boot.transport._defaults.claim_ttl
|
||||
self.project_id = '737_abc8332832'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
self.queue_path = self.url_prefix + '/queues/fizbit'
|
||||
@ -166,7 +166,7 @@ class TestClaimsMongoDB(base.V1_1Base):
|
||||
# List messages with a different client-id and echo=false.
|
||||
# Should return some messages
|
||||
headers = self.headers.copy()
|
||||
headers["Client-ID"] = str(uuid.uuid4())
|
||||
headers["Client-ID"] = uuidutils.generate_uuid()
|
||||
body = self.simulate_get(self.messages_path,
|
||||
query_string='include_claimed=true'
|
||||
'&echo=false',
|
||||
@ -207,7 +207,7 @@ class TestClaimsMongoDB(base.V1_1Base):
|
||||
|
||||
# Try to get it from the wrong project
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'bogusproject'
|
||||
}
|
||||
self.simulate_get(message_href, query_string=params, headers=headers)
|
||||
@ -294,7 +294,7 @@ class TestClaimsFaultyDriver(base.V1_1BaseFaulty):
|
||||
def test_simple(self):
|
||||
self.project_id = '480924abc_'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import contextlib
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar import storage
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
@ -31,11 +31,11 @@ class TestDefaultLimits(base.V1_1Base):
|
||||
super(TestDefaultLimits, self).setUp()
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'X-Project-ID': '%s_' % str(uuid.uuid4())
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '%s_' % uuidutils.generate_uuid()
|
||||
}
|
||||
self.queue_path = self.url_prefix + '/queues'
|
||||
self.q1_queue_path = self.queue_path + '/' + str(uuid.uuid4())
|
||||
self.q1_queue_path = self.queue_path + '/' + uuidutils.generate_uuid()
|
||||
self.messages_path = self.q1_queue_path + '/messages'
|
||||
self.claims_path = self.q1_queue_path + '/claims'
|
||||
|
||||
@ -62,7 +62,7 @@ class TestDefaultLimits(base.V1_1Base):
|
||||
self._prepare_messages(storage.DEFAULT_MESSAGES_PER_PAGE + 1)
|
||||
|
||||
headers = self.headers.copy()
|
||||
headers['Client-ID'] = str(uuid.uuid4())
|
||||
headers['Client-ID'] = uuidutils.generate_uuid()
|
||||
result = self.simulate_get(self.messages_path,
|
||||
headers=headers,
|
||||
query_string='echo=false')
|
||||
|
@ -12,10 +12,10 @@
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
@ -27,7 +27,7 @@ class TestHomeDocument(base.V1_1Base):
|
||||
|
||||
def test_json_response(self):
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '8383830383abc_'
|
||||
}
|
||||
body = self.simulate_get(self.url_prefix, headers=self.headers)
|
||||
@ -43,7 +43,7 @@ class TestHomeDocument(base.V1_1Base):
|
||||
|
||||
def test_href_template(self):
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '8383830383'
|
||||
}
|
||||
body = self.simulate_get(self.url_prefix, headers=self.headers)
|
||||
|
@ -13,11 +13,11 @@
|
||||
# the License.
|
||||
|
||||
import contextlib
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar import tests as testing
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
@ -38,7 +38,7 @@ def pool(test, name, weight, uri, group=None, options={}):
|
||||
:returns: (name, weight, uri, options)
|
||||
:rtype: see above
|
||||
"""
|
||||
uri = "%s/%s" % (uri, str(uuid.uuid4()))
|
||||
uri = "%s/%s" % (uri, uuidutils.generate_uuid())
|
||||
doc = {'weight': weight, 'uri': uri,
|
||||
'group': group, 'options': options}
|
||||
path = test.url_prefix + '/pools/' + name
|
||||
@ -71,7 +71,7 @@ def pools(test, count, uri, group):
|
||||
{str(i): i})
|
||||
for i in range(count)]
|
||||
for path, weight, option in args:
|
||||
uri = "%s/%s" % (mongo_url, str(uuid.uuid4()))
|
||||
uri = "%s/%s" % (mongo_url, uuidutils.generate_uuid())
|
||||
doc = {'weight': weight, 'uri': uri,
|
||||
'group': group, 'options': option}
|
||||
test.simulate_put(path, body=jsonutils.dumps(doc))
|
||||
@ -94,7 +94,7 @@ class TestPoolsMongoDB(base.V1_1Base):
|
||||
self.doc = {'weight': 100,
|
||||
'group': 'mygroup',
|
||||
'uri': self.mongodb_url}
|
||||
self.pool = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
self.pool = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(self.pool, body=jsonutils.dumps(self.doc))
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
@ -104,13 +104,13 @@ class TestPoolsMongoDB(base.V1_1Base):
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_put_pool_works(self):
|
||||
name = str(uuid.uuid1())
|
||||
name = uuidutils.generate_uuid()
|
||||
weight, uri = self.doc['weight'], self.doc['uri']
|
||||
with pool(self, name, weight, uri, group='my-group'):
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
def test_put_raises_if_missing_fields(self):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(path, body=jsonutils.dumps({'weight': 100}))
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ -121,7 +121,7 @@ class TestPoolsMongoDB(base.V1_1Base):
|
||||
|
||||
@ddt.data(-1, 2**32+1, 'big')
|
||||
def test_put_raises_if_invalid_weight(self, weight):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
doc = {'weight': weight, 'uri': 'a'}
|
||||
self.simulate_put(path,
|
||||
body=jsonutils.dumps(doc))
|
||||
@ -129,14 +129,14 @@ class TestPoolsMongoDB(base.V1_1Base):
|
||||
|
||||
@ddt.data(-1, 2**32+1, [], 'localhost:27017')
|
||||
def test_put_raises_if_invalid_uri(self, uri):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(path,
|
||||
body=jsonutils.dumps({'weight': 1, 'uri': uri}))
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 'wee', [])
|
||||
def test_put_raises_if_invalid_options(self, options):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
doc = {'weight': 1, 'uri': 'a', 'options': options}
|
||||
self.simulate_put(path, body=jsonutils.dumps(doc))
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
@ -12,12 +12,12 @@
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from zaqar.storage import errors as storage_errors
|
||||
@ -39,7 +39,7 @@ class TestQueueLifecycleMongoDB(base.V1_1Base):
|
||||
self.fizbat_queue_path = self.queue_path + '/fizbat'
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '3387309841abc_'
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ class TestQueueLifecycleMongoDB(base.V1_1Base):
|
||||
|
||||
def test_empty_project_id(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': ''
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ class TestQueueLifecycleMongoDB(base.V1_1Base):
|
||||
@ddt.data('480924', 'foo')
|
||||
def test_basics_thoroughly(self, project_id):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': project_id
|
||||
}
|
||||
gumshoe_queue_path_stats = self.gumshoe_queue_path + '/stats'
|
||||
@ -123,13 +123,13 @@ class TestQueueLifecycleMongoDB(base.V1_1Base):
|
||||
muvluv_queue_path = self.queue_path + '/Muv-Luv'
|
||||
|
||||
self.simulate_put(muvluv_queue_path,
|
||||
headers={'Client-ID': str(uuid.uuid4()),
|
||||
headers={'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'JAM Project' * 24})
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
# no charset restrictions
|
||||
self.simulate_put(muvluv_queue_path,
|
||||
headers={'Client-ID': str(uuid.uuid4()),
|
||||
headers={'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'JAM Project'})
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
@ -247,7 +247,7 @@ class TestQueueLifecycleMongoDB(base.V1_1Base):
|
||||
def test_list(self):
|
||||
arbitrary_number = 644079696574693
|
||||
project_id = str(arbitrary_number)
|
||||
client_id = str(uuid.uuid4())
|
||||
client_id = uuidutils.generate_uuid()
|
||||
header = {
|
||||
'X-Project-ID': project_id,
|
||||
'Client-ID': client_id
|
||||
@ -330,7 +330,7 @@ class TestQueueLifecycleMongoDB(base.V1_1Base):
|
||||
def test_list_returns_503_on_nopoolfound_exception(self):
|
||||
arbitrary_number = 644079696574693
|
||||
project_id = str(arbitrary_number)
|
||||
client_id = str(uuid.uuid4())
|
||||
client_id = uuidutils.generate_uuid()
|
||||
header = {
|
||||
'X-Project-ID': project_id,
|
||||
'Client-ID': client_id
|
||||
@ -359,7 +359,7 @@ class TestQueueLifecycleFaultyDriver(base.V1_1BaseFaulty):
|
||||
|
||||
def test_simple(self):
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '338730984abc_1'
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ class TestValidation(base.V1_1Base):
|
||||
self.simulate_put(self.queue_path, self.project_id)
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
}
|
||||
|
||||
def tearDown(self):
|
||||
|
@ -14,11 +14,11 @@
|
||||
# limitations under the License.
|
||||
"""Test Auth."""
|
||||
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from falcon import testing
|
||||
from keystonemiddleware import auth_token
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
|
||||
@ -29,7 +29,7 @@ class TestAuth(base.V2Base):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAuth, self).setUp()
|
||||
self.headers = {'Client-ID': str(uuid.uuid4())}
|
||||
self.headers = {'Client-ID': uuidutils.generate_uuid()}
|
||||
|
||||
def test_auth_install(self):
|
||||
self.assertIsInstance(self.app._auth_app, auth_token.AuthProtocol)
|
||||
|
@ -15,13 +15,13 @@
|
||||
|
||||
import datetime
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
from testtools import matchers
|
||||
|
||||
from zaqar import tests as testing
|
||||
@ -40,7 +40,7 @@ class TestClaimsMongoDB(base.V2Base):
|
||||
self.default_claim_ttl = self.boot.transport._defaults.claim_ttl
|
||||
self.project_id = '737_abc8332832'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
self.queue_path = self.url_prefix + '/queues/fizbit'
|
||||
@ -167,7 +167,7 @@ class TestClaimsMongoDB(base.V2Base):
|
||||
# List messages with a different client-id and echo=false.
|
||||
# Should return some messages
|
||||
headers = self.headers.copy()
|
||||
headers["Client-ID"] = str(uuid.uuid4())
|
||||
headers["Client-ID"] = uuidutils.generate_uuid()
|
||||
body = self.simulate_get(self.messages_path,
|
||||
query_string='include_claimed=true'
|
||||
'&echo=false',
|
||||
@ -208,7 +208,7 @@ class TestClaimsMongoDB(base.V2Base):
|
||||
|
||||
# Try to get it from the wrong project
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'bogusproject'
|
||||
}
|
||||
self.simulate_get(message_href, query_string=params, headers=headers)
|
||||
@ -295,7 +295,7 @@ class TestClaimsFaultyDriver(base.V2BaseFaulty):
|
||||
def test_simple(self):
|
||||
self.project_id = '480924abc_'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import contextlib
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar import storage
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
@ -31,11 +31,11 @@ class TestDefaultLimits(base.V2Base):
|
||||
super(TestDefaultLimits, self).setUp()
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'X-Project-ID': '%s_' % str(uuid.uuid4())
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '%s_' % uuidutils.generate_uuid()
|
||||
}
|
||||
self.queue_path = self.url_prefix + '/queues'
|
||||
self.q1_queue_path = self.queue_path + '/' + str(uuid.uuid4())
|
||||
self.q1_queue_path = self.queue_path + '/' + uuidutils.generate_uuid()
|
||||
self.messages_path = self.q1_queue_path + '/messages'
|
||||
self.claims_path = self.q1_queue_path + '/claims'
|
||||
|
||||
@ -62,7 +62,7 @@ class TestDefaultLimits(base.V2Base):
|
||||
self._prepare_messages(storage.DEFAULT_MESSAGES_PER_PAGE + 1)
|
||||
|
||||
headers = self.headers.copy()
|
||||
headers['Client-ID'] = str(uuid.uuid4())
|
||||
headers['Client-ID'] = uuidutils.generate_uuid()
|
||||
result = self.simulate_get(self.messages_path,
|
||||
headers=headers,
|
||||
query_string='echo=false')
|
||||
|
@ -12,10 +12,10 @@
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
import six.moves.urllib.parse as urlparse
|
||||
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
@ -27,7 +27,7 @@ class TestHomeDocument(base.V2Base):
|
||||
|
||||
def test_json_response(self):
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '8383830383abc_'
|
||||
}
|
||||
body = self.simulate_get(self.url_prefix, headers=self.headers)
|
||||
@ -43,7 +43,7 @@ class TestHomeDocument(base.V2Base):
|
||||
|
||||
def test_href_template(self):
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '8383830383'
|
||||
}
|
||||
body = self.simulate_get(self.url_prefix, headers=self.headers)
|
||||
|
@ -13,11 +13,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
from falcon import testing
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
|
||||
@ -39,7 +39,7 @@ class TestMediaType(base.V2Base):
|
||||
|
||||
for method, endpoint in endpoints:
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'Accept': 'application/xml',
|
||||
}
|
||||
|
||||
@ -59,7 +59,7 @@ class TestMediaType(base.V2Base):
|
||||
sample_message = jsonutils.dumps({'messages': [{'body': {'eww!'},
|
||||
'ttl': 200}]})
|
||||
bad_headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
|
||||
|
@ -14,13 +14,13 @@
|
||||
# limitations under the License.
|
||||
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import timeutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
from testtools import matchers
|
||||
|
||||
@ -53,7 +53,7 @@ class TestMessagesMongoDB(base.V2Base):
|
||||
|
||||
self.project_id = '7e55e1a7e'
|
||||
self.headers.update({
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
})
|
||||
|
||||
@ -665,7 +665,7 @@ class TestMessagesFaultyDriver(base.V2BaseFaulty):
|
||||
path = self.url_prefix + '/queues/fizbit/messages'
|
||||
body = '{"messages": [{"body": 239, "ttl": 100}]}'
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': project_id
|
||||
}
|
||||
|
||||
|
@ -13,11 +13,11 @@
|
||||
# the License.
|
||||
|
||||
import contextlib
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar import tests as testing
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
@ -38,7 +38,7 @@ def pool(test, name, weight, uri, group=None, options={}):
|
||||
:returns: (name, weight, uri, options)
|
||||
:rtype: see above
|
||||
"""
|
||||
uri = "%s/%s" % (uri, str(uuid.uuid4()))
|
||||
uri = "%s/%s" % (uri, uuidutils.generate_uuid())
|
||||
doc = {'weight': weight, 'uri': uri,
|
||||
'group': group, 'options': options}
|
||||
path = test.url_prefix + '/pools/' + name
|
||||
@ -70,7 +70,7 @@ def pools(test, count, uri, group):
|
||||
{str(i): i})
|
||||
for i in range(count)]
|
||||
for path, weight, option in args:
|
||||
uri = "%s/%s" % (mongo_url, str(uuid.uuid4()))
|
||||
uri = "%s/%s" % (mongo_url, uuidutils.generate_uuid())
|
||||
doc = {'weight': weight, 'uri': uri,
|
||||
'group': group, 'options': option}
|
||||
test.simulate_put(path, body=jsonutils.dumps(doc))
|
||||
@ -93,7 +93,7 @@ class TestPoolsMongoDB(base.V2Base):
|
||||
self.doc = {'weight': 100,
|
||||
'group': 'mygroup',
|
||||
'uri': self.mongodb_url}
|
||||
self.pool = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
self.pool = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(self.pool, body=jsonutils.dumps(self.doc))
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
@ -103,13 +103,13 @@ class TestPoolsMongoDB(base.V2Base):
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
def test_put_pool_works(self):
|
||||
name = str(uuid.uuid1())
|
||||
name = uuidutils.generate_uuid()
|
||||
weight, uri = self.doc['weight'], self.doc['uri']
|
||||
with pool(self, name, weight, uri, group='my-group'):
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
def test_put_raises_if_missing_fields(self):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(path, body=jsonutils.dumps({'weight': 100}))
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ -120,7 +120,7 @@ class TestPoolsMongoDB(base.V2Base):
|
||||
|
||||
@ddt.data(-1, 2**32+1, 'big')
|
||||
def test_put_raises_if_invalid_weight(self, weight):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
doc = {'weight': weight, 'uri': 'a'}
|
||||
self.simulate_put(path,
|
||||
body=jsonutils.dumps(doc))
|
||||
@ -128,14 +128,14 @@ class TestPoolsMongoDB(base.V2Base):
|
||||
|
||||
@ddt.data(-1, 2**32+1, [], 'localhost:27017')
|
||||
def test_put_raises_if_invalid_uri(self, uri):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(path,
|
||||
body=jsonutils.dumps({'weight': 1, 'uri': uri}))
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
@ddt.data(-1, 'wee', [])
|
||||
def test_put_raises_if_invalid_options(self, options):
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
doc = {'weight': 1, 'uri': 'a', 'options': options}
|
||||
self.simulate_put(path, body=jsonutils.dumps(doc))
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
@ -143,7 +143,7 @@ class TestPoolsMongoDB(base.V2Base):
|
||||
def test_put_same_database_uri(self):
|
||||
# NOTE(cabrera): setUp creates default pool
|
||||
expect = self.doc
|
||||
path = self.url_prefix + '/pools/' + str(uuid.uuid1())
|
||||
path = self.url_prefix + '/pools/' + uuidutils.generate_uuid()
|
||||
self.simulate_put(path, body=jsonutils.dumps(expect))
|
||||
self.assertEqual(falcon.HTTP_409, self.srmock.status)
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
# limitations under the License.
|
||||
|
||||
import falcon
|
||||
import uuid
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
|
||||
@ -29,7 +29,7 @@ class TestPurge(base.V2Base):
|
||||
super(TestPurge, self).setUp()
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4())
|
||||
'Client-ID': uuidutils.generate_uuid()
|
||||
}
|
||||
self.queue_path = self.url_prefix + '/queues/myqueue'
|
||||
self.messages_path = self.queue_path + '/messages'
|
||||
|
@ -12,12 +12,12 @@
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
import six
|
||||
|
||||
from zaqar.storage import errors as storage_errors
|
||||
@ -39,7 +39,7 @@ class TestQueueLifecycleMongoDB(base.V2Base):
|
||||
self.fizbat_queue_path = self.queue_path + '/fizbat'
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '3387309841abc_'
|
||||
}
|
||||
|
||||
@ -57,7 +57,7 @@ class TestQueueLifecycleMongoDB(base.V2Base):
|
||||
|
||||
def test_without_project_id(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
}
|
||||
|
||||
self.simulate_put(self.gumshoe_queue_path, headers=headers,
|
||||
@ -70,7 +70,7 @@ class TestQueueLifecycleMongoDB(base.V2Base):
|
||||
|
||||
def test_empty_project_id(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': ''
|
||||
}
|
||||
|
||||
@ -83,7 +83,7 @@ class TestQueueLifecycleMongoDB(base.V2Base):
|
||||
@ddt.data('480924', 'foo')
|
||||
def test_basics_thoroughly(self, project_id):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': project_id
|
||||
}
|
||||
gumshoe_queue_path_stats = self.gumshoe_queue_path + '/stats'
|
||||
@ -144,13 +144,13 @@ class TestQueueLifecycleMongoDB(base.V2Base):
|
||||
muvluv_queue_path = self.queue_path + '/Muv-Luv'
|
||||
|
||||
self.simulate_put(muvluv_queue_path,
|
||||
headers={'Client-ID': str(uuid.uuid4()),
|
||||
headers={'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'JAM Project' * 24})
|
||||
self.assertEqual(falcon.HTTP_400, self.srmock.status)
|
||||
|
||||
# no charset restrictions
|
||||
self.simulate_put(muvluv_queue_path,
|
||||
headers={'Client-ID': str(uuid.uuid4()),
|
||||
headers={'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': 'JAM Project'})
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
@ -250,8 +250,8 @@ class TestQueueLifecycleMongoDB(base.V2Base):
|
||||
xyz_queue_path = self.url_prefix + '/queues/xyz'
|
||||
xyz_queue_path_metadata = xyz_queue_path
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'X-Project-ID': str(uuid.uuid4())
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': uuidutils.generate_uuid()
|
||||
}
|
||||
# Create
|
||||
self.simulate_put(xyz_queue_path, headers=headers)
|
||||
@ -360,7 +360,7 @@ class TestQueueLifecycleMongoDB(base.V2Base):
|
||||
def test_list(self):
|
||||
arbitrary_number = 644079696574693
|
||||
project_id = str(arbitrary_number)
|
||||
client_id = str(uuid.uuid4())
|
||||
client_id = uuidutils.generate_uuid()
|
||||
header = {
|
||||
'X-Project-ID': project_id,
|
||||
'Client-ID': client_id
|
||||
@ -444,7 +444,7 @@ class TestQueueLifecycleMongoDB(base.V2Base):
|
||||
def test_list_returns_503_on_nopoolfound_exception(self):
|
||||
arbitrary_number = 644079696574693
|
||||
project_id = str(arbitrary_number)
|
||||
client_id = str(uuid.uuid4())
|
||||
client_id = uuidutils.generate_uuid()
|
||||
header = {
|
||||
'X-Project-ID': project_id,
|
||||
'Client-ID': client_id
|
||||
@ -473,7 +473,7 @@ class TestQueueLifecycleFaultyDriver(base.V2BaseFaulty):
|
||||
|
||||
def test_simple(self):
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': '338730984abc_1'
|
||||
}
|
||||
|
||||
|
@ -12,12 +12,12 @@
|
||||
# License for the specific language governing permissions and limitations under
|
||||
# the License.
|
||||
|
||||
import uuid
|
||||
|
||||
import ddt
|
||||
import falcon
|
||||
import mock
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar.common import auth
|
||||
from zaqar.notification import notifier
|
||||
@ -48,7 +48,7 @@ class TestSubscriptionsMongoDB(base.V2Base):
|
||||
|
||||
self.project_id = '7e55e1a7exyz'
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id
|
||||
}
|
||||
self.queue = 'fake-topic'
|
||||
@ -226,7 +226,7 @@ class TestSubscriptionsMongoDB(base.V2Base):
|
||||
def test_list_returns_503_on_nopoolfound_exception(self):
|
||||
arbitrary_number = 644079696574693
|
||||
project_id = str(arbitrary_number)
|
||||
client_id = str(uuid.uuid4())
|
||||
client_id = uuidutils.generate_uuid()
|
||||
header = {
|
||||
'X-Project-ID': project_id,
|
||||
'Client-ID': client_id
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
import falcon
|
||||
|
||||
from oslo_utils import uuidutils
|
||||
from zaqar.tests.unit.transport.wsgi import base
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@ class TestValidation(base.V2Base):
|
||||
self.simulate_put(self.queue_path, self.project_id)
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
}
|
||||
|
||||
def tearDown(self):
|
||||
@ -155,7 +155,7 @@ class TestValidation(base.V2Base):
|
||||
|
||||
def test_queue_patching(self):
|
||||
headers = {
|
||||
'Client-ID': str(uuid.uuid4()),
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
'Content-Type': "application/openstack-messaging-v2.0-json-patch"
|
||||
}
|
||||
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
|
||||
import json
|
||||
import uuid
|
||||
|
||||
from autobahn.asyncio import websocket
|
||||
import msgpack
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from zaqar.transport.websocket import protocol
|
||||
|
||||
@ -37,7 +37,7 @@ class ProtocolFactory(websocket.WebSocketServerFactory):
|
||||
self._protos = {}
|
||||
|
||||
def __call__(self):
|
||||
proto_id = str(uuid.uuid4())
|
||||
proto_id = uuidutils.generate_uuid()
|
||||
proto = self.protocol(self._handler, proto_id, self._auth_strategy,
|
||||
self._loop)
|
||||
self._protos[proto_id] = proto
|
||||
|
Loading…
Reference in New Issue
Block a user