Run pyupgrade to clean up Python 2 syntaxes
... because Python 2 is no longer supported. Change-Id: I2c2caf9f4c7e0f3260827c3b942993723a873245 Signed-off-by: Takashi Kajinami <kajinamit@oss.nttdata.com>
This commit is contained in:
@@ -18,6 +18,11 @@ repos:
|
||||
- id: hacking
|
||||
additional_dependencies: []
|
||||
exclude: '^(doc|releasenotes|tools)/.*$'
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.20.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py3-only]
|
||||
- repo: https://github.com/PyCQA/doc8
|
||||
rev: v2.0.0
|
||||
hooks:
|
||||
|
||||
@@ -40,7 +40,7 @@ source_suffix = '.rst'
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
copyright = u'2010-present, OpenStack Foundation'
|
||||
copyright = '2010-present, OpenStack Foundation'
|
||||
|
||||
# openstackdocstheme options
|
||||
openstackdocs_repo_name = 'openstack/zaqar'
|
||||
@@ -69,6 +69,6 @@ html_theme_options = {
|
||||
# (source start file, target name, title, author, documentclass
|
||||
# [howto/manual]).
|
||||
latex_documents = [
|
||||
('index', 'Nova.tex', u'OpenStack Messaging Service API Documentation',
|
||||
u'OpenStack Foundation', 'manual'),
|
||||
('index', 'Nova.tex', 'OpenStack Messaging Service API Documentation',
|
||||
'OpenStack Foundation', 'manual'),
|
||||
]
|
||||
|
||||
@@ -46,7 +46,7 @@ mail_info = {
|
||||
}
|
||||
|
||||
# It's a HTML mail template,and can be changed as needed
|
||||
mail_body = u"""
|
||||
mail_body = """
|
||||
<div style="font-family: 'Microsoft YaHei', Arial, Helvetica,sans-serif;
|
||||
position: relative;margin: 0 auto; width: 702px; font-size: 0;">
|
||||
<div style="display: inline-block; width: 0; height: 0;
|
||||
@@ -109,13 +109,13 @@ position: relative;margin: 0 auto; width: 702px; font-size: 0;">
|
||||
</div>
|
||||
"""
|
||||
|
||||
mail_confirm_link = u"""
|
||||
mail_confirm_link = """
|
||||
Your mailbox will be used for receiving system notifications.
|
||||
If you confirm, click the following link:
|
||||
<a href="{confirm_link}" target="_blank">Activation link</a>
|
||||
"""
|
||||
|
||||
mail_alarm_info = u"""
|
||||
mail_alarm_info = """
|
||||
Your alarm information is as follows:{reason}<br>
|
||||
Alarm level:{severity}<br>
|
||||
Alarm name:{alarm_name}<br>
|
||||
|
||||
@@ -22,7 +22,7 @@ from zaqar.common import errors
|
||||
from zaqar.common import urls
|
||||
|
||||
|
||||
class Handler(object):
|
||||
class Handler:
|
||||
"""Defines API handler
|
||||
|
||||
The handler validates and process the requests
|
||||
|
||||
@@ -27,7 +27,7 @@ from zaqar.transport import validation
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Endpoints(object):
|
||||
class Endpoints:
|
||||
"""v2 API Endpoints."""
|
||||
|
||||
def __init__(self, storage, control, validate, defaults):
|
||||
|
||||
@@ -57,7 +57,7 @@ def claim_delete(queues, stats, test_duration, ttl, grace, limit):
|
||||
claim_total_requests += 1
|
||||
|
||||
except errors.TransportError as ex:
|
||||
sys.stderr.write("Could not claim messages : {0}\n".format(ex))
|
||||
sys.stderr.write("Could not claim messages : {}\n".format(ex))
|
||||
total_failed_requests += 1
|
||||
|
||||
else:
|
||||
@@ -72,7 +72,7 @@ def claim_delete(queues, stats, test_duration, ttl, grace, limit):
|
||||
delete_total_requests += 1
|
||||
|
||||
except errors.TransportError as ex:
|
||||
msg = "Could not delete messages: {0}\n".format(ex)
|
||||
msg = "Could not delete messages: {}\n".format(ex)
|
||||
sys.stderr.write(msg)
|
||||
total_failed_requests += 1
|
||||
|
||||
@@ -150,7 +150,7 @@ def run(upstream_queue):
|
||||
for _ in range(num_procs)]
|
||||
|
||||
if CONF.debug:
|
||||
print('\nStarting consumers (cp={0}, cw={1})...'.format(
|
||||
print('\nStarting consumers (cp={}, cw={})...'.format(
|
||||
num_procs, num_workers))
|
||||
|
||||
start = time.time()
|
||||
|
||||
@@ -97,12 +97,12 @@ def _generate_client_conf():
|
||||
},
|
||||
},
|
||||
}
|
||||
print("Using '{0}' authentication method".format(conf['auth_opts']
|
||||
['backend']))
|
||||
print("Using '{}' authentication method".format(conf['auth_opts']
|
||||
['backend']))
|
||||
return conf
|
||||
|
||||
|
||||
class LazyAPIVersion(object):
|
||||
class LazyAPIVersion:
|
||||
def __init__(self):
|
||||
self.api_version = None
|
||||
|
||||
@@ -118,7 +118,7 @@ class LazyAPIVersion(object):
|
||||
print("Unknown Zaqar API version: '{}'. Exiting...".format(
|
||||
CONF.api_version))
|
||||
sys.exit()
|
||||
print("Benchmarking Zaqar API v{0}...".format(self.api_version))
|
||||
print("Benchmarking Zaqar API v{}...".format(self.api_version))
|
||||
return self.api_version
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ client_conf = _generate_client_conf()
|
||||
client_api = LazyAPIVersion()
|
||||
queue_names = []
|
||||
for i in range(CONF.num_queues):
|
||||
queue_names.append((CONF.queue_prefix + '-' + str(i)))
|
||||
queue_names.append(CONF.queue_prefix + '-' + str(i))
|
||||
|
||||
|
||||
def get_new_client():
|
||||
|
||||
@@ -81,7 +81,7 @@ def observer(queues, stats, test_duration, limit):
|
||||
queue['m'] = _extract_marker(cursor._links)
|
||||
|
||||
except errors.TransportError as ex:
|
||||
sys.stderr.write("Could not list messages : {0}\n".format(ex))
|
||||
sys.stderr.write("Could not list messages : {}\n".format(ex))
|
||||
total_failed += 1
|
||||
|
||||
total_requests = total_succeeded + total_failed
|
||||
@@ -146,7 +146,7 @@ def run(upstream_queue):
|
||||
for _ in range(num_procs)]
|
||||
|
||||
if CONF.debug:
|
||||
print('\nStarting observer (op={0}, ow={1})...'.format(
|
||||
print('\nStarting observer (op={}, ow={})...'.format(
|
||||
num_procs, num_workers))
|
||||
|
||||
start = time.time()
|
||||
|
||||
@@ -85,7 +85,7 @@ def producer(queues, message_pool, stats, test_duration):
|
||||
successful_requests += 1
|
||||
|
||||
except errors.TransportError as ex:
|
||||
sys.stderr.write("Could not post a message : {0}\n".format(ex))
|
||||
sys.stderr.write("Could not post a message : {}\n".format(ex))
|
||||
|
||||
total_requests += 1
|
||||
|
||||
@@ -156,7 +156,7 @@ def run(upstream_queue):
|
||||
]
|
||||
|
||||
if CONF.debug:
|
||||
print('\nStarting producer (pp={0}, pw={1})...'.format(
|
||||
print('\nStarting producer (pp={}, pw={})...'.format(
|
||||
num_procs, num_workers))
|
||||
|
||||
start = time.time()
|
||||
|
||||
@@ -37,7 +37,7 @@ from zaqar.transport import validation
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class Bootstrap(object):
|
||||
class Bootstrap:
|
||||
"""Defines the Zaqar bootstrapper.
|
||||
|
||||
The bootstrap loads up drivers per a given configuration, and
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
# TODO(cpp-cabrera): port to enum34 when that becomes available
|
||||
class Access(object):
|
||||
class Access:
|
||||
"""An enumeration to represent access levels for APIs."""
|
||||
public = 1
|
||||
admin = 2
|
||||
|
||||
@@ -23,7 +23,7 @@ from zaqar.i18n import _
|
||||
LOG = log.getLogger(__name__)
|
||||
|
||||
|
||||
class Api(object):
|
||||
class Api:
|
||||
|
||||
schema = {}
|
||||
validators = {}
|
||||
|
||||
@@ -20,7 +20,7 @@ class ExceptionBase(Exception):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
msg = self.msg_format.format(**kwargs)
|
||||
super(ExceptionBase, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class BadRequest(ExceptionBase):
|
||||
@@ -34,7 +34,7 @@ class BadRequest(ExceptionBase):
|
||||
:param description: Error description
|
||||
"""
|
||||
|
||||
super(BadRequest, self).__init__(description=description)
|
||||
super().__init__(description=description)
|
||||
|
||||
|
||||
class DocumentTypeNotSupported(ExceptionBase):
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
class Request(object):
|
||||
class Request:
|
||||
"""General data for a Zaqar request
|
||||
|
||||
Transport will generate a request object and send to this the API to be
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
|
||||
class Response(object):
|
||||
class Response:
|
||||
"""Common response class for Zaqar.
|
||||
|
||||
All `zaqar.transport.base.Transport` implementations
|
||||
|
||||
@@ -24,7 +24,7 @@ from oslo_serialization import jsonutils
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TransportLog(object):
|
||||
class TransportLog:
|
||||
"""Standard logging for transport driver responders
|
||||
|
||||
This class implements a logging decorator that the transport driver
|
||||
|
||||
@@ -39,7 +39,7 @@ from zaqar.i18n import _
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Pipeline(object):
|
||||
class Pipeline:
|
||||
|
||||
def __init__(self, pipeline=None):
|
||||
self._pipeline = pipeline and list(pipeline) or []
|
||||
@@ -88,7 +88,7 @@ class Pipeline(object):
|
||||
target = getattr(stage, method)
|
||||
except AttributeError:
|
||||
sstage = str(stage)
|
||||
msgtmpl = _(u"Stage %(stage)s does not "
|
||||
msgtmpl = _("Stage %(stage)s does not "
|
||||
"implement %(method)s")
|
||||
LOG.debug(msgtmpl, {'stage': sstage, 'method': method})
|
||||
continue
|
||||
|
||||
@@ -34,9 +34,9 @@ def fields(d, names, pred=lambda x: True,
|
||||
:rtype: dict
|
||||
"""
|
||||
|
||||
return dict((key_transform(k), value_transform(v))
|
||||
for k, v in d.items()
|
||||
if k in names and pred(v))
|
||||
return {key_transform(k): value_transform(v)
|
||||
for k, v in d.items()
|
||||
if k in names and pred(v)}
|
||||
|
||||
|
||||
_pytype_to_cfgtype = {
|
||||
|
||||
@@ -26,7 +26,7 @@ class RequestContext(context.RequestContext):
|
||||
auth_token=None, user_id=None, domain_id=None,
|
||||
user_domain_id=None, project_domain_id=None, is_admin=False,
|
||||
read_only=False, request_id=None, roles=None, **kwargs):
|
||||
super(RequestContext, self).__init__(
|
||||
super().__init__(
|
||||
auth_token=auth_token,
|
||||
user_id=user_id,
|
||||
project_id=project_id,
|
||||
@@ -46,7 +46,7 @@ class RequestContext(context.RequestContext):
|
||||
context._request_store.context = self
|
||||
|
||||
def to_dict(self):
|
||||
ctx = super(RequestContext, self).to_dict()
|
||||
ctx = super().to_dict()
|
||||
ctx.update({
|
||||
'project_id': self.project_id,
|
||||
'client_id': self.client_id
|
||||
|
||||
@@ -18,7 +18,7 @@ from oslo_log import log as logging
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MessageCodeAuthentication(object):
|
||||
class MessageCodeAuthentication:
|
||||
|
||||
def execute(self, extra_spec):
|
||||
# NOTE(wanghao): There need an implement by developers.
|
||||
|
||||
@@ -23,10 +23,10 @@ _all_log_levels = {'critical', 'error', 'exception', 'info',
|
||||
_all_hints = {'_'}
|
||||
|
||||
_log_translation_hint = re.compile(
|
||||
r".*LOG\.(%(levels)s)\(\s*(%(hints)s)\(" % {
|
||||
'levels': '|'.join(_all_log_levels),
|
||||
'hints': '|'.join(_all_hints),
|
||||
})
|
||||
r".*LOG\.({levels})\(\s*({hints})\(".format(
|
||||
levels='|'.join(_all_log_levels),
|
||||
hints='|'.join(_all_hints),
|
||||
))
|
||||
|
||||
|
||||
@core.flake8ext
|
||||
|
||||
@@ -35,7 +35,7 @@ class MessageType(enum.IntEnum):
|
||||
Notification = 3
|
||||
|
||||
|
||||
class NotifierDriver(object):
|
||||
class NotifierDriver:
|
||||
"""Notifier which is responsible for sending messages to subscribers.
|
||||
|
||||
"""
|
||||
@@ -99,10 +99,10 @@ class NotifierDriver(object):
|
||||
LOG.error("Can't send confirm notification due to the value of"
|
||||
" secret_key option is None")
|
||||
return
|
||||
url = "/%s/queues/%s/subscriptions/%s/confirm" % (api_version, queue,
|
||||
subscription['id'])
|
||||
pre_url = urls.create_signed_url(key, [url], project=project,
|
||||
expires=expires, methods=['PUT'])
|
||||
url = "/{}/queues/{}/subscriptions/{}/confirm".format(
|
||||
api_version, queue, subscription['id'])
|
||||
pre_url = urls.create_signed_url(
|
||||
key, [url], project=project, expires=expires, methods=['PUT'])
|
||||
message = None
|
||||
if is_unsubscribed:
|
||||
message_type = MessageType.UnsubscribeConfirmation.name
|
||||
|
||||
@@ -27,7 +27,7 @@ from zaqar.notification.notifier import MessageType
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class MailtoTask(object):
|
||||
class MailtoTask:
|
||||
|
||||
def _make_confirm_string(self, conf_n, message, queue_name):
|
||||
confirm_url = conf_n.external_confirmation_url
|
||||
@@ -64,7 +64,7 @@ class MailtoTask(object):
|
||||
def execute(self, subscription, messages, **kwargs):
|
||||
subscriber = urllib_parse.urlparse(subscription['subscriber'])
|
||||
params = urllib_parse.parse_qs(subscriber.query)
|
||||
params = dict((k.lower(), v) for k, v in params.items())
|
||||
params = {k.lower(): v for k, v in params.items()}
|
||||
conf_n = kwargs.get('conf').notification
|
||||
try:
|
||||
for message in messages:
|
||||
|
||||
@@ -38,8 +38,7 @@ class TrustTask(webhook.WebhookTask):
|
||||
subscription['subscriber'] = subscriber[6:]
|
||||
headers = {'X-Auth-Token': token,
|
||||
'Content-Type': 'application/json'}
|
||||
super(TrustTask, self).execute(subscription, messages, headers,
|
||||
**kwargs)
|
||||
super().execute(subscription, messages, headers, **kwargs)
|
||||
|
||||
def register(self, subscriber, options, ttl, project_id, request_data):
|
||||
if 'trust_id' not in options:
|
||||
@@ -58,6 +57,5 @@ class TrustTask(webhook.WebhookTask):
|
||||
seconds=ttl)
|
||||
|
||||
trust_id = auth.create_trust_id(
|
||||
auth_plugin, trustor_user_id, project_id, roles,
|
||||
expires_at)
|
||||
auth_plugin, trustor_user_id, project_id, roles, expires_at)
|
||||
options['trust_id'] = trust_id
|
||||
|
||||
@@ -57,7 +57,7 @@ RETRY_BACKOFF_FUNCTION_MAP = {'linear': _Linear_function,
|
||||
'exponential': _Exponential_function}
|
||||
|
||||
|
||||
class WebhookTask(object):
|
||||
class WebhookTask:
|
||||
|
||||
def _post_request_success(self, subscriber, data, headers):
|
||||
try:
|
||||
|
||||
@@ -51,7 +51,7 @@ class Capabilities(enum.IntEnum):
|
||||
HIGH_THROUGHPUT = 5
|
||||
|
||||
|
||||
class DriverBase(object, metaclass=abc.ABCMeta):
|
||||
class DriverBase(metaclass=abc.ABCMeta):
|
||||
"""Base class for both data and control plane drivers
|
||||
|
||||
:param conf: Configuration containing options for this driver.
|
||||
@@ -95,7 +95,7 @@ class DataDriverBase(DriverBase, metaclass=abc.ABCMeta):
|
||||
BASE_CAPABILITIES = []
|
||||
|
||||
def __init__(self, conf, cache, control_driver):
|
||||
super(DataDriverBase, self).__init__(conf, cache)
|
||||
super().__init__(conf, cache)
|
||||
# creating ControlDriver instance for accessing QueueController's
|
||||
# data from DataDriver
|
||||
self.control_driver = control_driver
|
||||
@@ -304,7 +304,7 @@ class ControlDriverBase(DriverBase, metaclass=abc.ABCMeta):
|
||||
raise NotImplementedError
|
||||
|
||||
|
||||
class ControllerBase(object):
|
||||
class ControllerBase:
|
||||
"""Top-level class for controllers.
|
||||
|
||||
:param driver: Instance of the driver
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
from oslo_config import cfg
|
||||
|
||||
|
||||
class Configuration(object):
|
||||
class Configuration:
|
||||
|
||||
def __init__(self, conf):
|
||||
"""Initialize configuration."""
|
||||
|
||||
@@ -20,7 +20,7 @@ class ExceptionBase(Exception):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
msg = self.msg_format.format(**kwargs)
|
||||
super(ExceptionBase, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
|
||||
|
||||
class ConnectionError(ExceptionBase):
|
||||
@@ -53,7 +53,7 @@ class MessageConflict(Conflict):
|
||||
:param project: name of the project to which the queue belongs
|
||||
"""
|
||||
|
||||
super(MessageConflict, self).__init__(queue=queue, project=project)
|
||||
super().__init__(queue=queue, project=project)
|
||||
|
||||
|
||||
class ClaimConflict(Conflict):
|
||||
@@ -69,7 +69,7 @@ class ClaimConflict(Conflict):
|
||||
:param project: name of the project to which the queue belongs
|
||||
"""
|
||||
|
||||
super(ClaimConflict, self).__init__(queue=queue, project=project)
|
||||
super().__init__(queue=queue, project=project)
|
||||
|
||||
|
||||
class QueueDoesNotExist(DoesNotExist):
|
||||
@@ -77,7 +77,7 @@ class QueueDoesNotExist(DoesNotExist):
|
||||
msg_format = 'Queue {name} does not exist for project {project}'
|
||||
|
||||
def __init__(self, name, project):
|
||||
super(QueueDoesNotExist, self).__init__(name=name, project=project)
|
||||
super().__init__(name=name, project=project)
|
||||
|
||||
|
||||
class QueueIsEmpty(ExceptionBase):
|
||||
@@ -85,7 +85,7 @@ class QueueIsEmpty(ExceptionBase):
|
||||
msg_format = 'Queue {name} in project {project} is empty'
|
||||
|
||||
def __init__(self, name, project):
|
||||
super(QueueIsEmpty, self).__init__(name=name, project=project)
|
||||
super().__init__(name=name, project=project)
|
||||
|
||||
|
||||
class MessageDoesNotExist(DoesNotExist):
|
||||
@@ -94,8 +94,7 @@ class MessageDoesNotExist(DoesNotExist):
|
||||
'queue {queue} for project {project}')
|
||||
|
||||
def __init__(self, mid, queue, project):
|
||||
super(MessageDoesNotExist, self).__init__(mid=mid, queue=queue,
|
||||
project=project)
|
||||
super().__init__(mid=mid, queue=queue, project=project)
|
||||
|
||||
|
||||
class ClaimDoesNotExist(DoesNotExist):
|
||||
@@ -104,8 +103,7 @@ class ClaimDoesNotExist(DoesNotExist):
|
||||
'queue {queue} for project {project}')
|
||||
|
||||
def __init__(self, cid, queue, project):
|
||||
super(ClaimDoesNotExist, self).__init__(cid=cid, queue=queue,
|
||||
project=project)
|
||||
super().__init__(cid=cid, queue=queue, project=project)
|
||||
|
||||
|
||||
class ClaimDoesNotMatch(ExceptionBase):
|
||||
@@ -114,8 +112,7 @@ class ClaimDoesNotMatch(ExceptionBase):
|
||||
'queue {queue} for project {project}')
|
||||
|
||||
def __init__(self, cid, queue, project):
|
||||
super(ClaimDoesNotMatch, self).__init__(cid=cid, queue=queue,
|
||||
project=project)
|
||||
super().__init__(cid=cid, queue=queue, project=project)
|
||||
|
||||
|
||||
class MessageIsClaimed(NotPermitted):
|
||||
@@ -123,7 +120,7 @@ class MessageIsClaimed(NotPermitted):
|
||||
msg_format = 'Message {mid} is claimed'
|
||||
|
||||
def __init__(self, mid):
|
||||
super(MessageIsClaimed, self).__init__(mid=mid)
|
||||
super().__init__(mid=mid)
|
||||
|
||||
|
||||
class MessageNotClaimed(NotPermitted):
|
||||
@@ -131,7 +128,7 @@ class MessageNotClaimed(NotPermitted):
|
||||
msg_format = 'Message {mid} is no longer claimed'
|
||||
|
||||
def __init__(self, mid):
|
||||
super(MessageNotClaimed, self).__init__(mid=mid)
|
||||
super().__init__(mid=mid)
|
||||
|
||||
|
||||
class MessageNotClaimedBy(NotPermitted):
|
||||
@@ -139,7 +136,7 @@ class MessageNotClaimedBy(NotPermitted):
|
||||
msg_format = 'Message {mid} is not claimed by {cid}'
|
||||
|
||||
def __init__(self, mid, cid):
|
||||
super(MessageNotClaimedBy, self).__init__(cid=cid, mid=mid)
|
||||
super().__init__(cid=cid, mid=mid)
|
||||
|
||||
|
||||
class QueueNotMapped(DoesNotExist):
|
||||
@@ -148,7 +145,7 @@ class QueueNotMapped(DoesNotExist):
|
||||
'queue {queue} for project {project}')
|
||||
|
||||
def __init__(self, queue, project):
|
||||
super(QueueNotMapped, self).__init__(queue=queue, project=project)
|
||||
super().__init__(queue=queue, project=project)
|
||||
|
||||
|
||||
class PoolDoesNotExist(DoesNotExist):
|
||||
@@ -156,7 +153,7 @@ class PoolDoesNotExist(DoesNotExist):
|
||||
msg_format = 'Pool {pool} does not exist'
|
||||
|
||||
def __init__(self, pool):
|
||||
super(PoolDoesNotExist, self).__init__(pool=pool)
|
||||
super().__init__(pool=pool)
|
||||
|
||||
|
||||
class PoolGroupDoesNotExist(DoesNotExist):
|
||||
@@ -164,7 +161,7 @@ class PoolGroupDoesNotExist(DoesNotExist):
|
||||
msg_format = 'Pool group {pool_group} does not exist'
|
||||
|
||||
def __init__(self, pool_group):
|
||||
super(PoolGroupDoesNotExist, self).__init__(pool_group=pool_group)
|
||||
super().__init__(pool_group=pool_group)
|
||||
|
||||
|
||||
class FlavorDoesNotExist(DoesNotExist):
|
||||
@@ -172,7 +169,7 @@ class FlavorDoesNotExist(DoesNotExist):
|
||||
msg_format = 'Flavor {flavor} does not exist'
|
||||
|
||||
def __init__(self, flavor):
|
||||
super(FlavorDoesNotExist, self).__init__(flavor=flavor)
|
||||
super().__init__(flavor=flavor)
|
||||
|
||||
|
||||
class NoPoolFound(ExceptionBase):
|
||||
@@ -180,7 +177,7 @@ class NoPoolFound(ExceptionBase):
|
||||
msg_format = 'No pools registered'
|
||||
|
||||
def __init__(self):
|
||||
super(NoPoolFound, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
|
||||
class PoolInUseByFlavor(NotPermitted):
|
||||
@@ -188,7 +185,7 @@ class PoolInUseByFlavor(NotPermitted):
|
||||
msg_format = 'Pool {pid} is in use by flavor {fid}'
|
||||
|
||||
def __init__(self, pid, fid):
|
||||
super(PoolInUseByFlavor, self).__init__(pid=pid, fid=fid)
|
||||
super().__init__(pid=pid, fid=fid)
|
||||
self._flavor = fid
|
||||
|
||||
@property
|
||||
@@ -201,8 +198,7 @@ class SubscriptionDoesNotExist(DoesNotExist):
|
||||
msg_format = 'Subscription {subscription_id} does not exist'
|
||||
|
||||
def __init__(self, subscription_id):
|
||||
super(SubscriptionDoesNotExist,
|
||||
self).__init__(subscription_id=subscription_id)
|
||||
super().__init__(subscription_id=subscription_id)
|
||||
|
||||
|
||||
class PoolCapabilitiesMismatch(ExceptionBase):
|
||||
@@ -232,7 +228,7 @@ class TopicDoesNotExist(DoesNotExist):
|
||||
msg_format = 'Topic {name} does not exist for project {project}'
|
||||
|
||||
def __init__(self, name, project):
|
||||
super(TopicDoesNotExist, self).__init__(name=name, project=project)
|
||||
super().__init__(name=name, project=project)
|
||||
|
||||
|
||||
class TopicIsEmpty(ExceptionBase):
|
||||
@@ -240,4 +236,4 @@ class TopicIsEmpty(ExceptionBase):
|
||||
msg_format = 'Topic {name} in project {project} is empty'
|
||||
|
||||
def __init__(self, name, project):
|
||||
super(TopicIsEmpty, self).__init__(name=name, project=project)
|
||||
super().__init__(name=name, project=project)
|
||||
|
||||
@@ -40,7 +40,7 @@ CATALOGUE_INDEX = [
|
||||
class CatalogueController(base.CatalogueBase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CatalogueController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self._col = self.driver.database.catalogue
|
||||
self._col.create_index(CATALOGUE_INDEX, unique=True)
|
||||
|
||||
@@ -207,7 +207,7 @@ class ClaimController(storage.Claim):
|
||||
msg_count_moved_to_DLQ = 0
|
||||
if ('_max_claim_count' in queue_meta and
|
||||
'_dead_letter_queue' in queue_meta):
|
||||
LOG.debug(u"The list of messages being claimed: %(be_claimed)s",
|
||||
LOG.debug("The list of messages being claimed: %(be_claimed)s",
|
||||
{"be_claimed": be_claimed})
|
||||
|
||||
for _id, claimed_count in be_claimed:
|
||||
@@ -222,9 +222,9 @@ class ClaimController(storage.Claim):
|
||||
'c.id': oid},
|
||||
{'$set': {'c.c': claimed_count + 1}},
|
||||
upsert=False)
|
||||
LOG.debug(u"Message %(id)s has been claimed %(count)d "
|
||||
u"times.", {"id": str(_id),
|
||||
"count": claimed_count + 1})
|
||||
LOG.debug("Message %(id)s has been claimed %(count)d "
|
||||
"times.", {"id": str(_id),
|
||||
"count": claimed_count + 1})
|
||||
else:
|
||||
# 2. Check if the message's claim count has exceeded the
|
||||
# max claim count defined in the queue, if so, move the
|
||||
@@ -250,9 +250,9 @@ class ClaimController(storage.Claim):
|
||||
**kwargs)
|
||||
dlq_collection = msg_ctrl._collection(dlq_name, project)
|
||||
if dlq_collection is None:
|
||||
LOG.warning(u"Failed to find the message collection "
|
||||
u"for queue %(dlq_name)s", {"dlq_name":
|
||||
dlq_name})
|
||||
LOG.warning("Failed to find the message collection "
|
||||
"for queue %(dlq_name)s", {"dlq_name":
|
||||
dlq_name})
|
||||
return None, iter([])
|
||||
# NOTE(flwang): If dead letter queue and queue are in the
|
||||
# same partition, the message has been already
|
||||
@@ -261,9 +261,9 @@ class ClaimController(storage.Claim):
|
||||
result = dlq_collection.insert_one(msg)
|
||||
if result.inserted_id:
|
||||
collection.delete_one({'_id': _id})
|
||||
LOG.debug(u"Message %(id)s has met the max claim count "
|
||||
u"%(count)d, now it has been moved to dead "
|
||||
u"letter queue %(dlq_name)s.",
|
||||
LOG.debug("Message %(id)s has met the max claim count "
|
||||
"%(count)d, now it has been moved to dead "
|
||||
"letter queue %(dlq_name)s.",
|
||||
{"id": str(_id), "count": claimed_count,
|
||||
"dlq_name": dlq_name})
|
||||
msg_count_moved_to_DLQ += 1
|
||||
|
||||
@@ -71,7 +71,7 @@ class DataDriver(storage.DataDriverBase):
|
||||
_COL_SUFIX = "_messages_p"
|
||||
|
||||
def __init__(self, conf, cache, control_driver):
|
||||
super(DataDriver, self).__init__(conf, cache, control_driver)
|
||||
super().__init__(conf, cache, control_driver)
|
||||
|
||||
self.mongodb_conf = self.conf[drivers_message_store_mongodb.GROUP_NAME]
|
||||
|
||||
@@ -231,7 +231,7 @@ class FIFODataDriver(DataDriver):
|
||||
class ControlDriver(storage.ControlDriverBase):
|
||||
|
||||
def __init__(self, conf, cache):
|
||||
super(ControlDriver, self).__init__(conf, cache)
|
||||
super().__init__(conf, cache)
|
||||
|
||||
self.conf.register_opts(
|
||||
drivers_management_store_mongodb.ALL_OPTS,
|
||||
|
||||
@@ -45,10 +45,10 @@ def _field_spec(detailed=False):
|
||||
class FlavorsController(base.FlavorsBase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(FlavorsController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
# To avoid creating unique index twice
|
||||
flavors_index_str = '_'.join(
|
||||
map(lambda x: '%s_%s' % (x[0], x[1]), FLAVORS_INDEX)
|
||||
map(lambda x: '{}_{}'.format(x[0], x[1]), FLAVORS_INDEX)
|
||||
)
|
||||
self._col = self.driver.database.flavors
|
||||
indexes = self._col.index_information().keys()
|
||||
|
||||
@@ -143,7 +143,7 @@ class MessageController(storage.Message):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MessageController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Cache for convenience and performance
|
||||
self._num_partitions = self.driver.mongodb_conf.partitions
|
||||
@@ -1069,7 +1069,7 @@ def _basic_message(msg, now):
|
||||
return res
|
||||
|
||||
|
||||
class MessageQueueHandler(object):
|
||||
class MessageQueueHandler:
|
||||
|
||||
def __init__(self, driver, control_driver):
|
||||
self.driver = driver
|
||||
|
||||
@@ -54,13 +54,13 @@ def _field_spec(detailed=False):
|
||||
class PoolsController(base.PoolsBase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PoolsController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
# To avoid creating unique index twice
|
||||
pools_index_str = '_'.join(
|
||||
map(lambda x: '%s_%s' % (x[0], x[1]), POOLS_INDEX)
|
||||
map(lambda x: '{}_{}'.format(x[0], x[1]), POOLS_INDEX)
|
||||
)
|
||||
uri_index_str = '_'.join(
|
||||
map(lambda x: '%s_%s' % (x[0], x[1]), URI_INDEX)
|
||||
map(lambda x: '{}_{}'.format(x[0], x[1]), URI_INDEX)
|
||||
)
|
||||
self._col = self.driver.database.pools
|
||||
indexes = self._col.index_information().keys()
|
||||
|
||||
@@ -85,7 +85,7 @@ class QueueController(storage.Queue):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(QueueController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self._cache = self.driver.cache
|
||||
self._collection = self.driver.queues_database.queues
|
||||
|
||||
@@ -52,7 +52,7 @@ class SubscriptionController(base.Subscription):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SubscriptionController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._collection = self.driver.subscriptions_database.subscriptions
|
||||
self._collection.create_index(SUBSCRIPTIONS_INDEX, unique=True)
|
||||
# NOTE(flwang): MongoDB will automatically delete the subscription
|
||||
|
||||
@@ -118,7 +118,7 @@ class MessageController(storage.Message):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MessageController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Cache for convenience and performance
|
||||
self._num_partitions = self.driver.mongodb_conf.partitions
|
||||
@@ -965,7 +965,7 @@ def _basic_message(msg, now):
|
||||
return res
|
||||
|
||||
|
||||
class MessageTopicHandler(object):
|
||||
class MessageTopicHandler:
|
||||
|
||||
def __init__(self, driver, control_driver):
|
||||
self.driver = driver
|
||||
|
||||
@@ -71,7 +71,7 @@ class TopicController(storage.Topic):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(TopicController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self._cache = self.driver.cache
|
||||
self._collection = self.driver.topics_database.topics
|
||||
|
||||
@@ -317,7 +317,7 @@ def retries_on_autoreconnect(func):
|
||||
return wrapper
|
||||
|
||||
|
||||
class HookedCursor(object):
|
||||
class HookedCursor:
|
||||
|
||||
def __init__(self, cursor, denormalizer, ntotal=None):
|
||||
self.cursor = cursor
|
||||
|
||||
@@ -76,7 +76,7 @@ def _get_builtin_entry_points(resource_name, storage, control_driver, conf):
|
||||
# `zaqar.storage.$STORAGE.driver.stages`. For now,
|
||||
# the builtin stages are bound to a single store and
|
||||
# are not applied to every store.
|
||||
namespace = '%s.%s.stages' % (storage.__module__, resource_name)
|
||||
namespace = '{}.{}.stages'.format(storage.__module__, resource_name)
|
||||
extensions = extension.ExtensionManager(namespace,
|
||||
invoke_on_load=True,
|
||||
invoke_args=[storage,
|
||||
@@ -104,7 +104,7 @@ class DataDriver(base.DataDriverBase):
|
||||
def __init__(self, conf, storage, control_driver):
|
||||
# NOTE(kgriffs): Pass None for cache since it won't ever
|
||||
# be referenced.
|
||||
super(DataDriver, self).__init__(conf, None, control_driver)
|
||||
super().__init__(conf, None, control_driver)
|
||||
self._storage = storage
|
||||
|
||||
@property
|
||||
|
||||
@@ -64,7 +64,7 @@ class DataDriver(storage.DataDriverBase):
|
||||
BASE_CAPABILITIES = tuple(storage.Capabilities)
|
||||
|
||||
def __init__(self, conf, cache, control, control_driver=None):
|
||||
super(DataDriver, self).__init__(conf, cache, control_driver)
|
||||
super().__init__(conf, cache, control_driver)
|
||||
catalog = Catalog(conf, cache, control)
|
||||
if self.conf.profiler.enabled:
|
||||
catalog = profiler.trace_cls("pooling_catalogue_"
|
||||
@@ -164,7 +164,7 @@ class QueueController(storage.Queue):
|
||||
"""
|
||||
|
||||
def __init__(self, pool_catalog):
|
||||
super(QueueController, self).__init__(None)
|
||||
super().__init__(None)
|
||||
self._pool_catalog = pool_catalog
|
||||
self._mgt_queue_ctrl = self._pool_catalog.control.queue_controller
|
||||
self._get_controller = self._pool_catalog.get_queue_controller
|
||||
@@ -276,7 +276,7 @@ class MessageController(storage.Message):
|
||||
"""
|
||||
|
||||
def __init__(self, pool_catalog):
|
||||
super(MessageController, self).__init__(None)
|
||||
super().__init__(None)
|
||||
self._pool_catalog = pool_catalog
|
||||
self._get_controller = self._pool_catalog.get_message_controller
|
||||
|
||||
@@ -351,7 +351,7 @@ class ClaimController(storage.Claim):
|
||||
"""
|
||||
|
||||
def __init__(self, pool_catalog):
|
||||
super(ClaimController, self).__init__(None)
|
||||
super().__init__(None)
|
||||
self._pool_catalog = pool_catalog
|
||||
self._get_controller = self._pool_catalog.get_claim_controller
|
||||
|
||||
@@ -391,7 +391,7 @@ class SubscriptionController(storage.Subscription):
|
||||
_resource_name = 'subscription'
|
||||
|
||||
def __init__(self, pool_catalog):
|
||||
super(SubscriptionController, self).__init__(pool_catalog)
|
||||
super().__init__(pool_catalog)
|
||||
self._pool_catalog = pool_catalog
|
||||
self._get_controller = self._pool_catalog.get_subscription_controller
|
||||
|
||||
@@ -444,7 +444,7 @@ class SubscriptionController(storage.Subscription):
|
||||
return control.get_with_subscriber(queue, subscriber, project)
|
||||
|
||||
|
||||
class Catalog(object):
|
||||
class Catalog:
|
||||
"""Represents the mapping between queues and pool drivers."""
|
||||
|
||||
def __init__(self, conf, cache, control):
|
||||
@@ -749,7 +749,7 @@ class TopicController(storage.Topic):
|
||||
"""
|
||||
|
||||
def __init__(self, pool_catalog):
|
||||
super(TopicController, self).__init__(None)
|
||||
super().__init__(None)
|
||||
self._pool_catalog = pool_catalog
|
||||
self._mgt_topic_ctrl = self._pool_catalog.control.topic_controller
|
||||
self._get_controller = self._pool_catalog.get_topic_controller
|
||||
|
||||
@@ -69,7 +69,7 @@ class CatalogueController(base.CatalogueBase):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CatalogueController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
|
||||
@utils.raises_conn_error
|
||||
|
||||
@@ -82,7 +82,7 @@ class ClaimController(storage.Claim, scripting.Mixin):
|
||||
script_names = ['claim_messages']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ClaimController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
|
||||
@@ -39,7 +39,7 @@ STRATEGY_SENTINEL = 3
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ConnectionURI(object):
|
||||
class ConnectionURI:
|
||||
def __init__(self, uri):
|
||||
# TODO(prashanthr_): Add SSL support
|
||||
try:
|
||||
@@ -161,7 +161,7 @@ class DataDriver(storage.DataDriverBase):
|
||||
drivers_message_store_redis.ALL_OPTS)]
|
||||
|
||||
def __init__(self, conf, cache, control_driver):
|
||||
super(DataDriver, self).__init__(conf, cache, control_driver)
|
||||
super().__init__(conf, cache, control_driver)
|
||||
self.redis_conf = self.conf[drivers_message_store_redis.GROUP_NAME]
|
||||
|
||||
server_version = self.connection.info()['redis_version']
|
||||
@@ -240,7 +240,7 @@ class DataDriver(storage.DataDriverBase):
|
||||
class ControlDriver(storage.ControlDriverBase):
|
||||
|
||||
def __init__(self, conf, cache):
|
||||
super(ControlDriver, self).__init__(conf, cache)
|
||||
super().__init__(conf, cache)
|
||||
|
||||
self.conf.register_opts(
|
||||
drivers_management_store_redis.ALL_OPTS,
|
||||
|
||||
@@ -67,7 +67,7 @@ class FlavorsController(base.FlavorsBase):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(FlavorsController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb)
|
||||
|
||||
@@ -110,7 +110,7 @@ class MessageController(storage.Message, scripting.Mixin):
|
||||
script_names = ['index_messages']
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MessageController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
|
||||
@decorators.lazy_property(write=False)
|
||||
@@ -582,7 +582,7 @@ def _filter_messages(messages, filters, to_basic, marker):
|
||||
QUEUES_SET_STORE_NAME = 'queues_set'
|
||||
|
||||
|
||||
class MessageQueueHandler(object):
|
||||
class MessageQueueHandler:
|
||||
def __init__(self, driver, control_driver):
|
||||
self.driver = driver
|
||||
self._client = self.driver.connection
|
||||
@@ -640,7 +640,7 @@ class MessageQueueHandler(object):
|
||||
return {'messages': message_stats}
|
||||
|
||||
|
||||
class MessageTopicHandler(object):
|
||||
class MessageTopicHandler:
|
||||
def __init__(self, driver, control_driver):
|
||||
self.driver = driver
|
||||
self._client = self.driver.connection
|
||||
|
||||
@@ -28,7 +28,7 @@ SUBENV_FIELD_KEYS = (b'id', b's', b'u', b't', b'e', b'o', b'p', b'c')
|
||||
|
||||
|
||||
# TODO(kgriffs): Make similar classes for claims and queues
|
||||
class MessageEnvelope(object):
|
||||
class MessageEnvelope:
|
||||
"""Encapsulates the message envelope (metadata only, no body).
|
||||
|
||||
:param id: Message ID in the form of a hexadecimal UUID. If not
|
||||
@@ -112,7 +112,7 @@ class MessageEnvelope(object):
|
||||
pipe.expire(self.id, self.ttl)
|
||||
|
||||
|
||||
class SubscriptionEnvelope(object):
|
||||
class SubscriptionEnvelope:
|
||||
"""Encapsulates the subscription envelope."""
|
||||
|
||||
__slots__ = [
|
||||
@@ -188,7 +188,7 @@ class Message(MessageEnvelope):
|
||||
__slots__ = MessageEnvelope.__slots__ + ['body']
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(Message, self).__init__(**kwargs)
|
||||
super().__init__(**kwargs)
|
||||
self.body = kwargs['body']
|
||||
|
||||
@staticmethod
|
||||
@@ -218,7 +218,7 @@ class Message(MessageEnvelope):
|
||||
|
||||
def to_redis(self, pipe, include_body=True):
|
||||
if not include_body:
|
||||
super(Message, self).to_redis(pipe)
|
||||
super().to_redis(pipe)
|
||||
|
||||
hmap = _msgenv_to_hmap(self)
|
||||
hmap['b'] = _pack(self.body)
|
||||
|
||||
@@ -84,7 +84,7 @@ class PoolsController(base.PoolsBase):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(PoolsController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
self.flavor_ctl = self.driver.flavors_controller
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
|
||||
@@ -61,7 +61,7 @@ class QueueController(storage.Queue):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(QueueController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb)
|
||||
|
||||
@@ -18,7 +18,7 @@ import os
|
||||
from zaqar.common import decorators
|
||||
|
||||
|
||||
class Mixin(object):
|
||||
class Mixin:
|
||||
script_names = []
|
||||
|
||||
@decorators.lazy_property(write=False)
|
||||
@@ -36,5 +36,5 @@ def _read_script(script_name):
|
||||
folder = os.path.abspath(os.path.dirname(__file__))
|
||||
filename = os.path.join(folder, 'scripts', script_name + '.lua')
|
||||
|
||||
with open(filename, 'r') as script_file:
|
||||
with open(filename) as script_file:
|
||||
return script_file.read()
|
||||
|
||||
@@ -47,7 +47,7 @@ class SubscriptionController(base.Subscription):
|
||||
'p': project :: str
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SubscriptionController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
self._packer = msgpack.Packer(use_bin_type=True).pack
|
||||
self._unpacker = functools.partial(msgpack.unpackb)
|
||||
|
||||
@@ -239,7 +239,7 @@ def msg_expired_filter(message, now):
|
||||
return message.expires <= now
|
||||
|
||||
|
||||
class QueueListCursor(object):
|
||||
class QueueListCursor:
|
||||
|
||||
def __init__(self, client, queues, denormalizer):
|
||||
self.queue_iter = queues
|
||||
@@ -259,7 +259,7 @@ class QueueListCursor(object):
|
||||
return self.next()
|
||||
|
||||
|
||||
class SubscriptionListCursor(object):
|
||||
class SubscriptionListCursor:
|
||||
|
||||
def __init__(self, client, subscriptions, denormalizer):
|
||||
self.subscription_iter = subscriptions
|
||||
@@ -331,7 +331,7 @@ def flavor_name_hash_key(name=None):
|
||||
FLAVORS_IDS_SUFFIX)
|
||||
|
||||
|
||||
class FlavorListCursor(object):
|
||||
class FlavorListCursor:
|
||||
|
||||
def __init__(self, client, flavors, denormalizer):
|
||||
self.flavor_iter = flavors
|
||||
@@ -401,7 +401,7 @@ def pools_name_hash_key(name=None):
|
||||
POOLS_IDS_SUFFIX)
|
||||
|
||||
|
||||
class PoolsListCursor(object):
|
||||
class PoolsListCursor:
|
||||
|
||||
def __init__(self, client, pools, denormalizer):
|
||||
self.pools_iter = pools
|
||||
|
||||
@@ -27,7 +27,7 @@ from zaqar.storage.sqlalchemy import controllers
|
||||
class ControlDriver(storage.ControlDriverBase):
|
||||
|
||||
def __init__(self, conf, cache):
|
||||
super(ControlDriver, self).__init__(conf, cache)
|
||||
super().__init__(conf, cache)
|
||||
self.conf.register_opts(
|
||||
drivers_management_store_sqlalchemy.ALL_OPTS,
|
||||
group=drivers_management_store_sqlalchemy.GROUP_NAME)
|
||||
|
||||
@@ -29,7 +29,7 @@ from zaqar.storage.sqlalchemy import utils
|
||||
class FlavorsController(base.FlavorsBase):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(FlavorsController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._pools_ctrl = self.driver.pools_controller
|
||||
|
||||
@utils.raises_conn_error
|
||||
|
||||
@@ -92,7 +92,7 @@ def msgid_decode(id):
|
||||
def marker_encode(id):
|
||||
# NOTE(AAzza): cannot use oct(id) here, because on Python 3 it returns
|
||||
# string with prefix '0o', whereas on Python 2 prefix is just '0'
|
||||
return '{0:o}'.format(id ^ 0x3c96a355)
|
||||
return '{:o}'.format(id ^ 0x3c96a355)
|
||||
|
||||
|
||||
def marker_decode(id):
|
||||
|
||||
@@ -31,7 +31,7 @@ class ClaimController(storage.Claim):
|
||||
Claims are scoped by project + queue.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(ClaimController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
|
||||
@decorators.lazy_property(write=False)
|
||||
|
||||
@@ -34,7 +34,7 @@ class DataDriver(storage.DataDriverBase):
|
||||
drivers_message_store_swift.ALL_OPTS)]
|
||||
|
||||
def __init__(self, conf, cache, control_driver):
|
||||
super(DataDriver, self).__init__(conf, cache, control_driver)
|
||||
super().__init__(conf, cache, control_driver)
|
||||
self.swift_conf = self.conf[drivers_message_store_swift.GROUP_NAME]
|
||||
if not self.conf.debug:
|
||||
# Reduce swiftclient logging, in particular to remove 404s
|
||||
@@ -94,7 +94,7 @@ class DataDriver(storage.DataDriverBase):
|
||||
pass
|
||||
|
||||
|
||||
class _ClientWrapper(object):
|
||||
class _ClientWrapper:
|
||||
"""Wrapper around swiftclient.Connection.
|
||||
|
||||
This wraps swiftclient.Connection to give the same API, but provide a
|
||||
|
||||
@@ -59,7 +59,7 @@ class MessageController(storage.Message):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(MessageController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
|
||||
@decorators.lazy_property(write=False)
|
||||
@@ -295,7 +295,7 @@ class MessageController(storage.Message):
|
||||
return messages
|
||||
|
||||
|
||||
class MessageQueueHandler(object):
|
||||
class MessageQueueHandler:
|
||||
def __init__(self, driver, control_driver):
|
||||
self.driver = driver
|
||||
self._client = self.driver.connection
|
||||
@@ -389,7 +389,7 @@ class MessageQueueHandler(object):
|
||||
return True
|
||||
|
||||
|
||||
class MessageTopicHandler(object):
|
||||
class MessageTopicHandler:
|
||||
def __init__(self, driver, control_driver):
|
||||
self.driver = driver
|
||||
self._client = self.driver.connection
|
||||
|
||||
@@ -44,7 +44,7 @@ class SubscriptionController(storage.Subscription):
|
||||
"""
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SubscriptionController, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
self._client = self.driver.connection
|
||||
|
||||
def list(self, queue, project=None, marker=None,
|
||||
|
||||
@@ -17,19 +17,19 @@ import swiftclient
|
||||
|
||||
|
||||
def _message_container(queue, project=None):
|
||||
return "zaqar_message:%s:%s" % (queue, project)
|
||||
return "zaqar_message:{}:{}".format(queue, project)
|
||||
|
||||
|
||||
def _claim_container(queue=None, project=None):
|
||||
return "zaqar_claim:%s:%s" % (queue, project)
|
||||
return "zaqar_claim:{}:{}".format(queue, project)
|
||||
|
||||
|
||||
def _subscription_container(queue, project=None):
|
||||
return "zaqar_subscription:%s:%s" % (queue, project)
|
||||
return "zaqar_subscription:{}:{}".format(queue, project)
|
||||
|
||||
|
||||
def _subscriber_container(queue, project=None):
|
||||
return "zaqar_subscriber:%s:%s" % (queue, project)
|
||||
return "zaqar_subscriber:{}:{}".format(queue, project)
|
||||
|
||||
|
||||
def _put_or_create_container(client, *args, **kwargs):
|
||||
@@ -134,7 +134,7 @@ def _filter_messages(messages, filters, marker, get_object, list_objects,
|
||||
yield msg
|
||||
|
||||
|
||||
class SubscriptionListCursor(object):
|
||||
class SubscriptionListCursor:
|
||||
|
||||
def __init__(self, objects, marker_next, get_object):
|
||||
self.objects = iter(objects)
|
||||
|
||||
@@ -63,7 +63,7 @@ def dynamic_conf(uri, options, conf=None):
|
||||
if 'drivers' not in conf:
|
||||
# NOTE(cpp-cabrera): parse general opts: 'drivers'
|
||||
driver_opts = utils.dict_to_conf({'message_store': storage_type})
|
||||
conf.register_opts(driver_opts, group=u'drivers')
|
||||
conf.register_opts(driver_opts, group='drivers')
|
||||
|
||||
conf.set_override('message_store', storage_type, 'drivers')
|
||||
|
||||
@@ -85,7 +85,7 @@ def load_storage_impl(uri, control_mode=False, default_store=None):
|
||||
"""
|
||||
|
||||
mode = 'control' if control_mode else 'data'
|
||||
driver_type = 'zaqar.{0}.storage'.format(mode)
|
||||
driver_type = 'zaqar.{}.storage'.format(mode)
|
||||
# Note(wanghao): In python3.9, urlparse will return 'localhost' as scheme
|
||||
# instead of '' in python3.8 when uri string is 'localhost:xxxxx'. So there
|
||||
# need to handle this change.
|
||||
@@ -132,7 +132,7 @@ def load_storage_driver(conf, cache, storage_type=None,
|
||||
mode = 'data'
|
||||
storage_type = storage_type or conf['drivers'].message_store
|
||||
|
||||
driver_type = 'zaqar.{0}.storage'.format(mode)
|
||||
driver_type = 'zaqar.{}.storage'.format(mode)
|
||||
|
||||
_invoke_args = (conf, cache)
|
||||
if control_driver is not None:
|
||||
@@ -147,7 +147,7 @@ def load_storage_driver(conf, cache, storage_type=None,
|
||||
if conf.profiler.enabled:
|
||||
if ((mode == "control" and conf.profiler.trace_management_store) or
|
||||
(mode == "data" and conf.profiler.trace_message_store)):
|
||||
trace_name = '{0}_{1}_driver'.format(storage_type, mode)
|
||||
trace_name = '{}_{}_driver'.format(storage_type, mode)
|
||||
return profiler.trace_cls(trace_name,
|
||||
trace_private=True)(mgr.driver)
|
||||
else:
|
||||
@@ -166,7 +166,7 @@ def keyify(key, iterable):
|
||||
:param iterable: The input iterable object
|
||||
"""
|
||||
|
||||
class Keyed(object):
|
||||
class Keyed:
|
||||
def __init__(self, obj):
|
||||
self.obj = obj
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ class TestBase(testtools.TestCase):
|
||||
config_file = None
|
||||
|
||||
def setUp(self):
|
||||
super(TestBase, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.useFixture(fixtures.FakeLogger('zaqar'))
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class DataDriver(storage.DataDriverBase):
|
||||
[cfg.StrOpt('uri', default='faulty://')])]
|
||||
|
||||
def __init__(self, conf, cache, control_driver):
|
||||
super(DataDriver, self).__init__(conf, cache, control_driver)
|
||||
super().__init__(conf, cache, control_driver)
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
@@ -69,7 +69,7 @@ class DataDriver(storage.DataDriverBase):
|
||||
class ControlDriver(storage.ControlDriverBase):
|
||||
|
||||
def __init__(self, conf, cache):
|
||||
super(ControlDriver, self).__init__(conf, cache)
|
||||
super().__init__(conf, cache)
|
||||
|
||||
def close(self):
|
||||
pass
|
||||
|
||||
@@ -54,10 +54,10 @@ class FunctionalTestBase(testing.TestBase):
|
||||
# NOTE(Eva-i): ttl_gc_interval is the known maximum time interval between
|
||||
# automatic resource TTL expirations. Depends on message store back end.
|
||||
class_ttl_gc_interval = None
|
||||
wipe_dbs_projects = set([])
|
||||
wipe_dbs_projects = set()
|
||||
|
||||
def setUp(self):
|
||||
super(FunctionalTestBase, self).setUp()
|
||||
super().setUp()
|
||||
# NOTE(flaper87): Config can't be a class
|
||||
# attribute because it may be necessary to
|
||||
# modify it at runtime which will affect
|
||||
@@ -116,7 +116,7 @@ class FunctionalTestBase(testing.TestBase):
|
||||
self.wipe_dbs_projects.add(self.headers["X-Project-ID"])
|
||||
|
||||
def tearDown(self):
|
||||
super(FunctionalTestBase, self).tearDown()
|
||||
super().tearDown()
|
||||
# Project might has changed during test case execution.
|
||||
# Lets add it again to the set.
|
||||
self.wipe_dbs_projects.add(self.headers["X-Project-ID"])
|
||||
@@ -215,7 +215,7 @@ class FunctionalTestBase(testing.TestBase):
|
||||
|
||||
form = 'Missing Header(s) - {0}'
|
||||
self.assertTrue(required_values.issubset(actual_values),
|
||||
msg=form.format((required_values - actual_values)))
|
||||
msg=form.format(required_values - actual_values))
|
||||
|
||||
def assertMessageCount(self, actualCount, expectedCount):
|
||||
"""Checks if number of messages returned <= limit
|
||||
@@ -223,8 +223,8 @@ class FunctionalTestBase(testing.TestBase):
|
||||
:param expectedCount: limit value passed in the url (OR) default(10).
|
||||
:param actualCount: number of messages returned in the API response.
|
||||
"""
|
||||
msg = ('More Messages returned than allowed: expected count = {0}'
|
||||
', actual count = {1}'.format(expectedCount, actualCount))
|
||||
msg = ('More Messages returned than allowed: expected count = {}'
|
||||
', actual count = {}'.format(expectedCount, actualCount))
|
||||
self.assertLessEqual(actualCount, expectedCount, msg)
|
||||
|
||||
def assertQueueStats(self, result_json, claimed):
|
||||
@@ -275,7 +275,7 @@ class FunctionalTestBase(testing.TestBase):
|
||||
|
||||
# Verify that age has valid values
|
||||
age = message['age']
|
||||
msg = 'Invalid Age {0}'.format(age)
|
||||
msg = 'Invalid Age {}'.format(age)
|
||||
self.assertLessEqual(0, age, msg)
|
||||
self.assertLessEqual(age, self.limits.max_message_ttl, msg)
|
||||
|
||||
@@ -297,13 +297,13 @@ class FunctionalTestBase(testing.TestBase):
|
||||
# (needed to pass this test on sqlite driver)
|
||||
delta = int(delta)
|
||||
|
||||
msg = ('Invalid Time Delta {0}, Created time {1}, Now {2}'
|
||||
msg = ('Invalid Time Delta {}, Created time {}, Now {}'
|
||||
.format(delta, created_time, now))
|
||||
self.assertLessEqual(0, delta, msg)
|
||||
self.assertLessEqual(delta, 6000, msg)
|
||||
|
||||
|
||||
class Server(object, metaclass=abc.ABCMeta):
|
||||
class Server(metaclass=abc.ABCMeta):
|
||||
|
||||
name = "zaqar-functional-test-server"
|
||||
|
||||
@@ -387,5 +387,5 @@ class ZaqarAdminServer(Server):
|
||||
|
||||
class V2FunctionalTestBase(FunctionalTestBase):
|
||||
def setUp(self):
|
||||
super(V2FunctionalTestBase, self).setUp()
|
||||
super().setUp()
|
||||
self.response = response_v2.ResponseSchema(self.limits)
|
||||
|
||||
@@ -37,7 +37,7 @@ def _build_url(method):
|
||||
return wrapper
|
||||
|
||||
|
||||
class Client(object):
|
||||
class Client:
|
||||
|
||||
def __init__(self):
|
||||
# NOTE(kgriffs): used by @_build_url
|
||||
@@ -91,7 +91,7 @@ class Client(object):
|
||||
return self.session.patch(url, **kwargs)
|
||||
|
||||
|
||||
class ResponseMock(object):
|
||||
class ResponseMock:
|
||||
"""Mocks part of the Requests library's Response object."""
|
||||
|
||||
def __init__(self, srmock, wsgi_result):
|
||||
@@ -103,7 +103,7 @@ class ResponseMock(object):
|
||||
return jsonutils.loads(self._body)
|
||||
|
||||
|
||||
class WSGIClient(object):
|
||||
class WSGIClient:
|
||||
"""Same interface as Client, but speaks directly to a WSGI callable."""
|
||||
|
||||
def __init__(self, app):
|
||||
@@ -116,8 +116,8 @@ class WSGIClient(object):
|
||||
@staticmethod
|
||||
def _sanitize_headers(headers):
|
||||
# NOTE(kgriffs): Workaround for a little create_environ bug
|
||||
return dict([(key, '' if value is None else value)
|
||||
for key, value in headers.items()])
|
||||
return {key: '' if value is None else value
|
||||
for key, value in headers.items()}
|
||||
|
||||
def _simulate_request(self, url, method='GET', data=None,
|
||||
headers=None, params=None):
|
||||
|
||||
@@ -30,7 +30,7 @@ class TestQueues(base.V2FunctionalTestBase):
|
||||
def setUp(self):
|
||||
if not base._TEST_INTEGRATION:
|
||||
raise testcase.TestSkipped('Only run in integration mode')
|
||||
super(TestQueues, self).setUp()
|
||||
super().setUp()
|
||||
self.project_id = uuidutils.generate_uuid()
|
||||
self.headers = {'Client-ID': uuidutils.generate_uuid(),
|
||||
'X-Project-ID': self.project_id}
|
||||
|
||||
@@ -23,7 +23,7 @@ class TestVersions(base.FunctionalTestBase):
|
||||
server_class = base.ZaqarServer
|
||||
|
||||
def setUp(self):
|
||||
super(TestVersions, self).setUp()
|
||||
super().setUp()
|
||||
self.base_url = "{url}/".format(url=self.cfg.zaqar.url)
|
||||
self.client.set_base_url(self.base_url)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class TestSubscriptions(base.V2FunctionalTestBase):
|
||||
server_class = base.ZaqarServer
|
||||
|
||||
def setUp(self):
|
||||
super(TestSubscriptions, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.queue_name = uuid.uuid1()
|
||||
self.queue_url = ("{url}/{version}/queues/{queue}".format(
|
||||
@@ -53,7 +53,7 @@ class TestSubscriptions(base.V2FunctionalTestBase):
|
||||
self.client.delete(sub_url)
|
||||
# Delete test queue.
|
||||
self.client.delete(self.queue_url)
|
||||
super(TestSubscriptions, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@helpers.is_slow(condition=lambda self: self.class_ttl_gc_interval > 1)
|
||||
def test_expired_subscription(self):
|
||||
|
||||
@@ -24,7 +24,7 @@ from zaqar import tests as testing
|
||||
class TestUtils(testing.TestBase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestUtils, self).setUp()
|
||||
super().setUp()
|
||||
self.conf.register_opts(default.ALL_OPTS)
|
||||
|
||||
@testing.requires_mongodb
|
||||
|
||||
@@ -37,7 +37,7 @@ class FakeApi(api.Api):
|
||||
class TestApi(base.TestBase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestApi, self).setUp()
|
||||
super().setUp()
|
||||
self.api = FakeApi()
|
||||
|
||||
def test_valid_params(self):
|
||||
|
||||
@@ -26,12 +26,12 @@ from zaqar.tests import base
|
||||
class TestDecorators(base.TestBase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestDecorators, self).setUp()
|
||||
super().setUp()
|
||||
self.conf.register_opts(default.ALL_OPTS)
|
||||
|
||||
def test_memoized_getattr(self):
|
||||
|
||||
class TestClass(object):
|
||||
class TestClass:
|
||||
|
||||
@decorators.memoized_getattr
|
||||
def __getattr__(self, name):
|
||||
@@ -58,7 +58,7 @@ class TestDecorators(base.TestBase):
|
||||
def create_key(user, project=None):
|
||||
return user + ':' + str(project)
|
||||
|
||||
class TestClass(object):
|
||||
class TestClass:
|
||||
|
||||
def __init__(self, cache):
|
||||
self._cache = cache
|
||||
@@ -107,7 +107,7 @@ class TestDecorators(base.TestBase):
|
||||
conf.cache.enabled = True
|
||||
cache = oslo_cache.get_cache(conf)
|
||||
|
||||
class TestClass(object):
|
||||
class TestClass:
|
||||
|
||||
def __init__(self, cache):
|
||||
self._cache = cache
|
||||
|
||||
@@ -17,7 +17,7 @@ from zaqar.common import pipeline
|
||||
from zaqar.tests import base
|
||||
|
||||
|
||||
class FirstClass(object):
|
||||
class FirstClass:
|
||||
|
||||
def with_args(self, name):
|
||||
return name
|
||||
@@ -26,7 +26,7 @@ class FirstClass(object):
|
||||
return lastname
|
||||
|
||||
def with_args_kwargs(self, name, lastname='yo'):
|
||||
return '{0} {1}'.format(name, lastname)
|
||||
return '{} {}'.format(name, lastname)
|
||||
|
||||
def no_args(self):
|
||||
return True
|
||||
@@ -38,7 +38,7 @@ class FirstClass(object):
|
||||
return None
|
||||
|
||||
|
||||
class SecondClass(object):
|
||||
class SecondClass:
|
||||
|
||||
def does_nothing(self):
|
||||
return None
|
||||
@@ -58,7 +58,7 @@ class SecondClass(object):
|
||||
class TestPipeLine(base.TestBase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestPipeLine, self).setUp()
|
||||
super().setUp()
|
||||
self.pipeline = pipeline.Pipeline([FirstClass(),
|
||||
SecondClass()])
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class TestURLs(base.TestBase):
|
||||
timeutils.set_time_override()
|
||||
self.addCleanup(timeutils.clear_time_override)
|
||||
|
||||
key = 'test'.encode('latin-1')
|
||||
key = b'test'
|
||||
methods = ['POST']
|
||||
project = 'my-project'
|
||||
paths = ['/v2/queues/shared/messages']
|
||||
@@ -52,7 +52,7 @@ class TestURLs(base.TestBase):
|
||||
timeutils.set_time_override()
|
||||
self.addCleanup(timeutils.clear_time_override)
|
||||
|
||||
key = 'test'.encode("latin-1")
|
||||
key = b'test'
|
||||
methods = ['POST']
|
||||
project = 'my-project'
|
||||
paths = ['/v2/queues/shared/messages',
|
||||
@@ -77,7 +77,7 @@ class TestURLs(base.TestBase):
|
||||
date_str = '2100-05-31T19:00:17+02'
|
||||
date_str_utc = '2100-05-31T17:00:17'
|
||||
|
||||
key = 'test'.encode("latin-1")
|
||||
key = b'test'
|
||||
project = None
|
||||
methods = ['GET']
|
||||
paths = ['/v2/queues/shared/messages']
|
||||
|
||||
@@ -20,8 +20,8 @@ class HackingTestCase(base.TestBase):
|
||||
def test_no_log_translations(self):
|
||||
for log in checks._all_log_levels:
|
||||
for hint in checks._all_hints:
|
||||
bad = 'LOG.%s(%s("Bad"))' % (log, hint)
|
||||
bad = 'LOG.{}({}("Bad"))'.format(log, hint)
|
||||
self.assertEqual(1, len(list(checks.no_translate_logs(bad))))
|
||||
# Catch abuses when used with a variable and not a literal
|
||||
bad = 'LOG.%s(%s(msg))' % (log, hint)
|
||||
bad = 'LOG.{}({}(msg))'.format(log, hint)
|
||||
self.assertEqual(1, len(list(checks.no_translate_logs(bad))))
|
||||
|
||||
@@ -31,7 +31,7 @@ from zaqar import tests as testing
|
||||
class NotifierTest(testing.TestBase):
|
||||
|
||||
def setUp(self):
|
||||
super(NotifierTest, self).setUp()
|
||||
super().setUp()
|
||||
self.client_id = uuid.uuid4()
|
||||
self.project = uuid.uuid4()
|
||||
self.messages = [{"ttl": 300,
|
||||
|
||||
@@ -45,13 +45,13 @@ class ControllerBaseTest(testing.TestBase):
|
||||
controller_base_class = None
|
||||
|
||||
def setUp(self):
|
||||
super(ControllerBaseTest, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
if not self.driver_class:
|
||||
self.skipTest('No driver class specified')
|
||||
|
||||
if not issubclass(self.controller_class, self.controller_base_class):
|
||||
self.skipTest('{0} is not an instance of {1}. '
|
||||
self.skipTest('{} is not an instance of {}. '
|
||||
'Tests not supported'.format(
|
||||
self.controller_class,
|
||||
self.controller_base_class))
|
||||
@@ -78,7 +78,7 @@ class ControllerBaseTest(testing.TestBase):
|
||||
db_name = "?dbid = " + str(i)
|
||||
|
||||
# NOTE(dynarro): we need to create a unique uri.
|
||||
new_uri = "%s/%s" % (uri, db_name)
|
||||
new_uri = "{}/{}".format(uri, db_name)
|
||||
self.control.pools_controller.create(str(i),
|
||||
100, new_uri)
|
||||
else:
|
||||
@@ -87,7 +87,7 @@ class ControllerBaseTest(testing.TestBase):
|
||||
db_name = "zaqar_test_pools_" + str(i)
|
||||
|
||||
# NOTE(dynarro): we need to create a unique uri.
|
||||
new_uri = "%s/%s" % (uri, db_name)
|
||||
new_uri = "{}/{}".format(uri, db_name)
|
||||
options = {'database': db_name}
|
||||
self.control.pools_controller.create(str(i),
|
||||
100, new_uri,
|
||||
@@ -126,7 +126,7 @@ class QueueControllerTest(ControllerBaseTest):
|
||||
controller_base_class = storage.Queue
|
||||
|
||||
def setUp(self):
|
||||
super(QueueControllerTest, self).setUp()
|
||||
super().setUp()
|
||||
self.queue_controller = self.pipeline.queue_controller
|
||||
|
||||
@ddt.data(None, ControllerBaseTest.project)
|
||||
@@ -212,7 +212,7 @@ class MessageControllerTest(ControllerBaseTest):
|
||||
gc_interval = 0
|
||||
|
||||
def setUp(self):
|
||||
super(MessageControllerTest, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
# Lets create a queue
|
||||
self.queue_controller = self.pipeline.queue_controller
|
||||
@@ -221,7 +221,7 @@ class MessageControllerTest(ControllerBaseTest):
|
||||
|
||||
def tearDown(self):
|
||||
self.queue_controller.delete(self.queue_name, project=self.project)
|
||||
super(MessageControllerTest, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_stats_for_empty_queue(self):
|
||||
self.addCleanup(self.queue_controller.delete, 'test',
|
||||
@@ -846,7 +846,7 @@ class ClaimControllerTest(ControllerBaseTest):
|
||||
controller_base_class = storage.Claim
|
||||
|
||||
def setUp(self):
|
||||
super(ClaimControllerTest, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
# Lets create a queue
|
||||
self.queue_controller = self.pipeline.queue_controller
|
||||
@@ -855,7 +855,7 @@ class ClaimControllerTest(ControllerBaseTest):
|
||||
|
||||
def tearDown(self):
|
||||
self.queue_controller.delete(self.queue_name, project=self.project)
|
||||
super(ClaimControllerTest, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_claim_lifecycle(self):
|
||||
_insert_fixtures(self.message_controller, self.queue_name,
|
||||
@@ -1194,7 +1194,7 @@ class SubscriptionControllerTest(ControllerBaseTest):
|
||||
controller_base_class = storage.Subscription
|
||||
|
||||
def setUp(self):
|
||||
super(SubscriptionControllerTest, self).setUp()
|
||||
super().setUp()
|
||||
self.subscription_controller = self.driver.subscription_controller
|
||||
self.queue_controller = self.driver.queue_controller
|
||||
|
||||
@@ -1205,7 +1205,7 @@ class SubscriptionControllerTest(ControllerBaseTest):
|
||||
|
||||
def tearDown(self):
|
||||
self.queue_controller.delete(self.queue_name, project=self.project)
|
||||
super(SubscriptionControllerTest, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
# NOTE(Eva-i): this method helps to test cases when the queue is
|
||||
# pre-created and when it's not.
|
||||
@@ -1218,7 +1218,7 @@ class SubscriptionControllerTest(ControllerBaseTest):
|
||||
def test_list(self, precreate_queue):
|
||||
self._precreate_queue(precreate_queue)
|
||||
for s in range(15):
|
||||
subscriber = 'http://fake_{0}'.format(s)
|
||||
subscriber = 'http://fake_{}'.format(s)
|
||||
s_id = self.subscription_controller.create(
|
||||
self.source,
|
||||
subscriber,
|
||||
@@ -1437,7 +1437,7 @@ class SubscriptionControllerTest(ControllerBaseTest):
|
||||
# create two subscriptions: fake_0 and fake_1
|
||||
ids = []
|
||||
for s in range(2):
|
||||
subscriber = 'http://fake_{0}'.format(s)
|
||||
subscriber = 'http://fake_{}'.format(s)
|
||||
s_id = self.subscription_controller.create(
|
||||
self.source,
|
||||
subscriber,
|
||||
@@ -1522,7 +1522,7 @@ class PoolsControllerTest(ControllerBaseTest):
|
||||
controller_base_class = storage.PoolsBase
|
||||
|
||||
def setUp(self):
|
||||
super(PoolsControllerTest, self).setUp()
|
||||
super().setUp()
|
||||
self.pools_controller = self.driver.pools_controller
|
||||
|
||||
# Let's create one pool
|
||||
@@ -1536,7 +1536,7 @@ class PoolsControllerTest(ControllerBaseTest):
|
||||
|
||||
def tearDown(self):
|
||||
self.pools_controller.drop_all()
|
||||
super(PoolsControllerTest, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_create_succeeds(self):
|
||||
self.pools_controller.create(str(uuid.uuid1()),
|
||||
@@ -1683,7 +1683,7 @@ class CatalogueControllerTest(ControllerBaseTest):
|
||||
controller_base_class = storage.CatalogueBase
|
||||
|
||||
def setUp(self):
|
||||
super(CatalogueControllerTest, self).setUp()
|
||||
super().setUp()
|
||||
self.controller = self.driver.catalogue_controller
|
||||
self.pool_ctrl = self.driver.pools_controller
|
||||
self.queue = str(uuid.uuid4())
|
||||
@@ -1706,7 +1706,7 @@ class CatalogueControllerTest(ControllerBaseTest):
|
||||
self.pool_ctrl.update(self.pool1, flavor="")
|
||||
self.pool_ctrl.drop_all()
|
||||
self.controller.drop_all()
|
||||
super(CatalogueControllerTest, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def _check_structure(self, entry):
|
||||
self.assertIn('queue', entry)
|
||||
@@ -1825,7 +1825,7 @@ class FlavorsControllerTest1(ControllerBaseTest):
|
||||
controller_base_class = storage.FlavorsBase
|
||||
|
||||
def setUp(self):
|
||||
super(FlavorsControllerTest1, self).setUp()
|
||||
super().setUp()
|
||||
self.pools_controller = self.driver.pools_controller
|
||||
self.flavors_controller = self.driver.flavors_controller
|
||||
|
||||
@@ -1841,7 +1841,7 @@ class FlavorsControllerTest1(ControllerBaseTest):
|
||||
self.pools_controller.update(self.pool, flavor="")
|
||||
self.pools_controller.drop_all()
|
||||
self.flavors_controller.drop_all()
|
||||
super(FlavorsControllerTest1, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_create_succeeds(self):
|
||||
self.flavors_controller.create(self.flavor,
|
||||
@@ -2003,7 +2003,7 @@ def _insert_fixtures(controller, queue_name, project=None,
|
||||
yield {
|
||||
'ttl': ttl,
|
||||
'body': {
|
||||
'event': 'Event number {0}'.format(n)
|
||||
'event': 'Event number {}'.format(n)
|
||||
}}
|
||||
|
||||
return controller.post(queue_name, messages(),
|
||||
|
||||
@@ -69,7 +69,7 @@ class TestCli(testtools.TestCase):
|
||||
]
|
||||
|
||||
def setUp(self):
|
||||
super(TestCli, self).setUp()
|
||||
super().setUp()
|
||||
do_alembic_cmd_p = mock.patch.object(cli, 'do_alembic_command')
|
||||
self.addCleanup(do_alembic_cmd_p.stop)
|
||||
self.do_alembic_cmd = do_alembic_cmd_p.start()
|
||||
|
||||
@@ -37,7 +37,7 @@ from zaqar.tests.unit.storage.sqlalchemy_migration import \
|
||||
test_migrations_base as base
|
||||
|
||||
|
||||
class ZaqarMigrationsCheckers(object):
|
||||
class ZaqarMigrationsCheckers:
|
||||
|
||||
def assertColumnExists(self, engine, table, column):
|
||||
t = db_utils.get_table(engine, table)
|
||||
|
||||
@@ -50,7 +50,7 @@ CONF.register_opts(sqlalchemy_opts,
|
||||
group='drivers:management_store:sqlalchemy')
|
||||
|
||||
|
||||
class BaseWalkMigrationTestCase(object):
|
||||
class BaseWalkMigrationTestCase:
|
||||
|
||||
ALEMBIC_CONFIG = alembic_config.Config(
|
||||
os.path.join(
|
||||
|
||||
@@ -38,7 +38,7 @@ from zaqar import tests as testing
|
||||
from zaqar.tests.unit.storage import base
|
||||
|
||||
|
||||
class MongodbSetupMixin(object):
|
||||
class MongodbSetupMixin:
|
||||
def _purge_databases(self):
|
||||
if isinstance(self.driver, mongodb.DataDriver):
|
||||
databases = (self.driver.message_databases +
|
||||
@@ -65,7 +65,7 @@ class MongodbUtilsTest(MongodbSetupMixin, testing.TestBase):
|
||||
config_file = 'wsgi_mongodb.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(MongodbUtilsTest, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.conf.register_opts(drivers_message_store_mongodb.ALL_OPTS,
|
||||
group=drivers_message_store_mongodb.GROUP_NAME)
|
||||
@@ -150,7 +150,7 @@ class MongodbDriverTest(MongodbSetupMixin, testing.TestBase):
|
||||
config_file = 'wsgi_mongodb.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(MongodbDriverTest, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.conf.register_opts(default.ALL_OPTS)
|
||||
self.config(unreliable=False)
|
||||
@@ -526,7 +526,7 @@ class MongodbPoolsTests(base.PoolsControllerTest):
|
||||
control_driver_class = mongodb.ControlDriver
|
||||
|
||||
def setUp(self):
|
||||
super(MongodbPoolsTests, self).setUp()
|
||||
super().setUp()
|
||||
self.uri2 = str(uuid.uuid1())
|
||||
self.flavor2 = str(uuid.uuid1())
|
||||
self.pools_controller.create(self.pool, 100, self.uri2,
|
||||
@@ -535,7 +535,7 @@ class MongodbPoolsTests(base.PoolsControllerTest):
|
||||
def tearDown(self):
|
||||
# self.pool_ctrl.update(self.pool, flavor="")
|
||||
self.pools_controller.drop_all()
|
||||
super(MongodbPoolsTests, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
# NOTE(gengchc2): Unittest for new flavor configure scenario.
|
||||
def test_delete_pool_used_by_flavor1(self):
|
||||
@@ -581,7 +581,7 @@ class MongodbCatalogueTests(base.CatalogueControllerTest):
|
||||
config_file = 'wsgi_mongodb.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(MongodbCatalogueTests, self).setUp()
|
||||
super().setUp()
|
||||
self.addCleanup(self.controller.drop_all)
|
||||
|
||||
|
||||
@@ -625,5 +625,5 @@ class MongodbFlavorsTest1(base.FlavorsControllerTest1):
|
||||
config_file = 'wsgi_mongodb.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(MongodbFlavorsTest1, self).setUp()
|
||||
super().setUp()
|
||||
self.addCleanup(self.controller.drop_all)
|
||||
|
||||
@@ -63,7 +63,7 @@ class RedisUtilsTest(testing.TestBase):
|
||||
config_file = 'wsgi_redis.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(RedisUtilsTest, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.conf.register_opts(drivers_message_store_redis.ALL_OPTS,
|
||||
group=drivers_message_store_redis.GROUP_NAME)
|
||||
@@ -441,12 +441,12 @@ class RedisQueuesTest(base.QueueControllerTest):
|
||||
control_driver_class = driver.ControlDriver
|
||||
|
||||
def setUp(self):
|
||||
super(RedisQueuesTest, self).setUp()
|
||||
super().setUp()
|
||||
self.connection = self.driver.connection
|
||||
self.msg_controller = self.driver.message_controller
|
||||
|
||||
def tearDown(self):
|
||||
super(RedisQueuesTest, self).tearDown()
|
||||
super().tearDown()
|
||||
self.connection.flushdb()
|
||||
|
||||
|
||||
@@ -459,11 +459,11 @@ class RedisMessagesTest(base.MessageControllerTest):
|
||||
gc_interval = 1
|
||||
|
||||
def setUp(self):
|
||||
super(RedisMessagesTest, self).setUp()
|
||||
super().setUp()
|
||||
self.connection = self.driver.connection
|
||||
|
||||
def tearDown(self):
|
||||
super(RedisMessagesTest, self).tearDown()
|
||||
super().tearDown()
|
||||
self.connection.flushdb()
|
||||
|
||||
def test_count(self):
|
||||
@@ -525,11 +525,11 @@ class RedisClaimsTest(base.ClaimControllerTest):
|
||||
control_driver_class = driver.ControlDriver
|
||||
|
||||
def setUp(self):
|
||||
super(RedisClaimsTest, self).setUp()
|
||||
super().setUp()
|
||||
self.connection = self.driver.connection
|
||||
|
||||
def tearDown(self):
|
||||
super(RedisClaimsTest, self).tearDown()
|
||||
super().tearDown()
|
||||
self.connection.flushdb()
|
||||
|
||||
def test_claim_doesnt_exist(self):
|
||||
@@ -633,7 +633,7 @@ class RedisPoolsTests(base.PoolsControllerTest):
|
||||
control_driver_class = driver.ControlDriver
|
||||
|
||||
def setUp(self):
|
||||
super(RedisPoolsTests, self).setUp()
|
||||
super().setUp()
|
||||
self.pools_controller = self.driver.pools_controller
|
||||
# Let's create one pool
|
||||
self.pool = str(uuid.uuid1())
|
||||
@@ -649,7 +649,7 @@ class RedisPoolsTests(base.PoolsControllerTest):
|
||||
|
||||
def tearDown(self):
|
||||
self.pools_controller.drop_all()
|
||||
super(RedisPoolsTests, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_delete_pool_used_by_flavor(self):
|
||||
with testing.expect(storage.errors.PoolInUseByFlavor):
|
||||
@@ -678,7 +678,7 @@ class RedisCatalogueTests(base.CatalogueControllerTest):
|
||||
config_file = 'wsgi_redis.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(RedisCatalogueTests, self).setUp()
|
||||
super().setUp()
|
||||
self.addCleanup(self.controller.drop_all)
|
||||
|
||||
|
||||
@@ -703,13 +703,13 @@ class PooledClaimsTests(base.ClaimControllerTest):
|
||||
controller_base_class = storage.Claim
|
||||
|
||||
def setUp(self):
|
||||
super(PooledClaimsTests, self).setUp()
|
||||
super().setUp()
|
||||
self.connection = self.controller._pool_catalog.lookup(
|
||||
self.queue_name, self.project)._storage.\
|
||||
claim_controller.driver.connection
|
||||
|
||||
def tearDown(self):
|
||||
super(PooledClaimsTests, self).tearDown()
|
||||
super().tearDown()
|
||||
self.connection.flushdb()
|
||||
|
||||
|
||||
@@ -722,5 +722,5 @@ class RedisFlavorsTest1(base.FlavorsControllerTest1):
|
||||
config_file = 'wsgi_redis.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(RedisFlavorsTest1, self).setUp()
|
||||
super().setUp()
|
||||
self.addCleanup(self.controller.drop_all)
|
||||
|
||||
@@ -23,7 +23,7 @@ from zaqar import tests as testing
|
||||
from zaqar.tests.unit.storage import base
|
||||
|
||||
|
||||
class DBCreateMixin(object):
|
||||
class DBCreateMixin:
|
||||
|
||||
def _prepare_conf(self):
|
||||
tables.metadata.create_all(self.driver.engine)
|
||||
@@ -43,7 +43,7 @@ class SqlalchemyPoolsTest(DBCreateMixin, base.PoolsControllerTest):
|
||||
control_driver_class = sqlalchemy.ControlDriver
|
||||
|
||||
def setUp(self):
|
||||
super(SqlalchemyPoolsTest, self).setUp()
|
||||
super().setUp()
|
||||
# self.pools_controller.create(self.pool, 100, 'localhost',
|
||||
# group=self.pool_group, options={})
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class PoolCatalogTest(testing.TestBase):
|
||||
config_file = 'wsgi_mongodb_pooled_disable_virtual_pool.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(PoolCatalogTest, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
oslo_cache.register_config(self.conf)
|
||||
cache = oslo_cache.get_cache(self.conf)
|
||||
@@ -71,7 +71,7 @@ class PoolCatalogTest(testing.TestBase):
|
||||
def tearDown(self):
|
||||
self.catalogue_ctrl.drop_all()
|
||||
self.pools_ctrl.drop_all()
|
||||
super(PoolCatalogTest, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_lookup_loads_correct_driver(self):
|
||||
storage = self.catalog.lookup(self.queue, self.project)
|
||||
|
||||
@@ -26,7 +26,7 @@ from zaqar.transport.wsgi import errors
|
||||
class TestAcl(base.TestBase):
|
||||
|
||||
def setUp(self):
|
||||
super(TestAcl, self).setUp()
|
||||
super().setUp()
|
||||
ctx = context.RequestContext()
|
||||
request_class = namedtuple("Request", ("env",))
|
||||
self.request = request_class({"zaqar.context": ctx})
|
||||
|
||||
@@ -26,7 +26,7 @@ class TestBase(testing.TestBase):
|
||||
config_file = None
|
||||
|
||||
def setUp(self):
|
||||
super(TestBase, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
if not self.config_file:
|
||||
self.skipTest("No config specified")
|
||||
@@ -53,7 +53,7 @@ class TestBase(testing.TestBase):
|
||||
if self.conf.pooling:
|
||||
self.boot.control.pools_controller.drop_all()
|
||||
self.boot.control.catalogue_controller.drop_all()
|
||||
super(TestBase, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
|
||||
class TestBaseFaulty(TestBase):
|
||||
|
||||
@@ -29,7 +29,7 @@ class TestMessagingProtocol(base.TestBase):
|
||||
config_file = "websocket_mongodb.conf"
|
||||
|
||||
def setUp(self):
|
||||
super(TestMessagingProtocol, self).setUp()
|
||||
super().setUp()
|
||||
self.protocol = self.transport.factory()
|
||||
self.project_id = 'protocol-test'
|
||||
self.headers = {
|
||||
|
||||
@@ -31,7 +31,7 @@ class AuthTest(base.V2Base):
|
||||
config_file = "websocket_mongodb_keystone_auth.conf"
|
||||
|
||||
def setUp(self):
|
||||
super(AuthTest, self).setUp()
|
||||
super().setUp()
|
||||
self.protocol = self.transport.factory()
|
||||
self.protocol.factory._secret_key = 'secret'
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ class ClaimsBaseTest(base.V1_1Base):
|
||||
config_file = "websocket_mongodb.conf"
|
||||
|
||||
def setUp(self):
|
||||
super(ClaimsBaseTest, self).setUp()
|
||||
super().setUp()
|
||||
self.protocol = self.transport.factory()
|
||||
self.defaults = self.api.get_defaults()
|
||||
|
||||
@@ -74,7 +74,7 @@ class ClaimsBaseTest(base.V1_1Base):
|
||||
self.assertEqual(201, resp['headers']['status'])
|
||||
|
||||
def tearDown(self):
|
||||
super(ClaimsBaseTest, self).tearDown()
|
||||
super().tearDown()
|
||||
action = consts.QUEUE_DELETE
|
||||
body = {'queue_name': 'skittle'}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class MessagesBaseTest(base.V2Base):
|
||||
config_file = "websocket_mongodb.conf"
|
||||
|
||||
def setUp(self):
|
||||
super(MessagesBaseTest, self).setUp()
|
||||
super().setUp()
|
||||
self.protocol = self.transport.factory()
|
||||
|
||||
self.default_message_ttl = 3600
|
||||
@@ -55,7 +55,7 @@ class MessagesBaseTest(base.V2Base):
|
||||
self.assertIn(resp['headers']['status'], [201, 204])
|
||||
|
||||
def tearDown(self):
|
||||
super(MessagesBaseTest, self).tearDown()
|
||||
super().tearDown()
|
||||
body = {"queue_name": "kitkat"}
|
||||
|
||||
send_mock = mock.Mock()
|
||||
@@ -87,7 +87,7 @@ class MessagesBaseTest(base.V2Base):
|
||||
self.msg_ids = resp['body']['message_ids']
|
||||
self.assertEqual(len(sample_messages), len(self.msg_ids))
|
||||
|
||||
lookup = dict([(m['ttl'], m['body']) for m in sample_messages])
|
||||
lookup = {m['ttl']: m['body'] for m in sample_messages}
|
||||
|
||||
# Test GET on the message resource directly
|
||||
# NOTE(cpp-cabrera): force the passing of time to age a message
|
||||
@@ -139,10 +139,10 @@ class MessagesBaseTest(base.V2Base):
|
||||
arg = send_mock.call_args[0][0]
|
||||
resp = loads(arg)
|
||||
self.assertEqual(200, resp['headers']['status'])
|
||||
expected_ttls = set(m['ttl'] for m in sample_messages)
|
||||
actual_ttls = set(m['ttl'] for m in resp['body']['messages'])
|
||||
expected_ttls = {m['ttl'] for m in sample_messages}
|
||||
actual_ttls = {m['ttl'] for m in resp['body']['messages']}
|
||||
self.assertFalse(expected_ttls - actual_ttls)
|
||||
actual_ids = set(m['id'] for m in resp['body']['messages'])
|
||||
actual_ids = {m['id'] for m in resp['body']['messages']}
|
||||
self.assertFalse(set(self.msg_ids) - actual_ids)
|
||||
|
||||
def test_exceeded_payloads(self):
|
||||
|
||||
@@ -31,7 +31,7 @@ class QueueLifecycleBaseTest(base.V2Base):
|
||||
config_file = "websocket_mongodb.conf"
|
||||
|
||||
def setUp(self):
|
||||
super(QueueLifecycleBaseTest, self).setUp()
|
||||
super().setUp()
|
||||
self.protocol = self.transport.factory()
|
||||
|
||||
def test_empty_project_id(self):
|
||||
@@ -662,7 +662,7 @@ class TestQueueLifecycleMongoDB(QueueLifecycleBaseTest):
|
||||
|
||||
@testing.requires_mongodb
|
||||
def setUp(self):
|
||||
super(TestQueueLifecycleMongoDB, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
def tearDown(self):
|
||||
storage = self.boot.storage._storage
|
||||
@@ -673,4 +673,4 @@ class TestQueueLifecycleMongoDB(QueueLifecycleBaseTest):
|
||||
for db in storage.message_databases:
|
||||
connection.drop_database(db)
|
||||
|
||||
super(TestQueueLifecycleMongoDB, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@@ -33,7 +33,7 @@ class SubscriptionTest(base.V1_1Base):
|
||||
config_file = 'websocket_mongodb_subscriptions.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(SubscriptionTest, self).setUp()
|
||||
super().setUp()
|
||||
self.protocol = self.transport.factory()
|
||||
|
||||
self.project_id = '7e55e1a7e'
|
||||
@@ -55,7 +55,7 @@ class SubscriptionTest(base.V1_1Base):
|
||||
self.protocol.onMessage(req, False)
|
||||
|
||||
def tearDown(self):
|
||||
super(SubscriptionTest, self).tearDown()
|
||||
super().tearDown()
|
||||
body = {'queue_name': 'kitkat'}
|
||||
|
||||
send_mock = mock.patch.object(self.protocol, 'sendMessage')
|
||||
|
||||
@@ -29,7 +29,7 @@ class TestBase(testing.TestBase):
|
||||
config_file = None
|
||||
|
||||
def setUp(self):
|
||||
super(TestBase, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
if not self.config_file:
|
||||
self.skipTest("No config specified")
|
||||
@@ -64,7 +64,7 @@ class TestBase(testing.TestBase):
|
||||
if self.conf.pooling:
|
||||
self.boot.control.pools_controller.drop_all()
|
||||
self.boot.control.catalogue_controller.drop_all()
|
||||
super(TestBase, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def simulate_request(self, path, project_id=None, **kwargs):
|
||||
"""Simulate a request.
|
||||
|
||||
@@ -114,7 +114,7 @@ class TestUtils(testtools.TestCase):
|
||||
self.assertEqual(doc, filtered)
|
||||
|
||||
def test_no_spec(self):
|
||||
obj = {u'body': {'event': 'start_backup'}, 'ttl': 300}
|
||||
obj = {'body': {'event': 'start_backup'}, 'ttl': 300}
|
||||
document = str(jsonutils.dumps(obj, ensure_ascii=False))
|
||||
doc_stream = io.StringIO(document)
|
||||
|
||||
@@ -127,7 +127,7 @@ class TestUtils(testtools.TestCase):
|
||||
self.assertEqual(filtered, filtered2)
|
||||
|
||||
def test_no_spec_array(self):
|
||||
things = [{u'body': {'event': 'start_backup'}, 'ttl': 300}]
|
||||
things = [{'body': {'event': 'start_backup'}, 'ttl': 300}]
|
||||
document = str(jsonutils.dumps(things, ensure_ascii=False))
|
||||
doc_stream = io.StringIO(document)
|
||||
|
||||
@@ -145,7 +145,7 @@ class TestUtils(testtools.TestCase):
|
||||
self.assertEqual(doc, filtered)
|
||||
|
||||
def test_deserialize_and_sanitize_json_obj(self):
|
||||
obj = {u'body': {'event': 'start_backup'}, 'id': 'DEADBEEF'}
|
||||
obj = {'body': {'event': 'start_backup'}, 'id': 'DEADBEEF'}
|
||||
|
||||
document = str(jsonutils.dumps(obj, ensure_ascii=False))
|
||||
stream = io.StringIO(document)
|
||||
@@ -162,7 +162,7 @@ class TestUtils(testtools.TestCase):
|
||||
doctype=utils.JSONArray)
|
||||
|
||||
def test_deserialize_and_sanitize_json_array(self):
|
||||
array = [{u'body': {u'x': 1}}, {u'body': {u'x': 2}}]
|
||||
array = [{'body': {'x': 1}}, {'body': {'x': 2}}]
|
||||
|
||||
document = str(jsonutils.dumps(array, ensure_ascii=False))
|
||||
stream = io.StringIO(document)
|
||||
|
||||
@@ -28,7 +28,7 @@ class TestAuth(base.V2Base):
|
||||
config_file = 'keystone_auth.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(TestAuth, self).setUp()
|
||||
super().setUp()
|
||||
self.headers = {'Client-ID': uuidutils.generate_uuid()}
|
||||
|
||||
def test_auth_install(self):
|
||||
|
||||
@@ -34,7 +34,7 @@ class TestClaimsMongoDB(base.V2Base):
|
||||
|
||||
@testing.requires_mongodb
|
||||
def setUp(self):
|
||||
super(TestClaimsMongoDB, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.default_claim_ttl = self.boot.transport._defaults.claim_ttl
|
||||
self.project_id = '737_abc8332832'
|
||||
@@ -68,7 +68,7 @@ class TestClaimsMongoDB(base.V2Base):
|
||||
|
||||
self.simulate_delete(self.queue_path, headers=self.headers)
|
||||
|
||||
super(TestClaimsMongoDB, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
@ddt.data('[', '[]', '.', '"fail"')
|
||||
def test_bad_claim(self, doc):
|
||||
|
||||
@@ -28,7 +28,7 @@ class TestDefaultLimits(base.V2Base):
|
||||
config_file = 'wsgi_mongodb_default_limits.conf'
|
||||
|
||||
def setUp(self):
|
||||
super(TestDefaultLimits, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.headers = {
|
||||
'Client-ID': uuidutils.generate_uuid(),
|
||||
@@ -44,7 +44,7 @@ class TestDefaultLimits(base.V2Base):
|
||||
|
||||
def tearDown(self):
|
||||
self.simulate_delete(self.queue_path, headers=self.headers)
|
||||
super(TestDefaultLimits, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_queue_listing(self):
|
||||
# 2 queues to list
|
||||
@@ -103,7 +103,7 @@ class TestDefaultLimits(base.V2Base):
|
||||
|
||||
@contextlib.contextmanager
|
||||
def _prepare_queues(self, count):
|
||||
queue_paths = [self.queue_path + '/multi-{0}'.format(i)
|
||||
queue_paths = [self.queue_path + '/multi-{}'.format(i)
|
||||
for i in range(count)]
|
||||
|
||||
for path in queue_paths:
|
||||
|
||||
@@ -95,7 +95,7 @@ class TestFlavorsMongoDB(base.V2Base):
|
||||
|
||||
@testing.requires_mongodb
|
||||
def setUp(self):
|
||||
super(TestFlavorsMongoDB, self).setUp()
|
||||
super().setUp()
|
||||
self.queue = 'test-queue'
|
||||
self.queue_path = self.url_prefix + '/queues/' + self.queue
|
||||
|
||||
@@ -118,7 +118,7 @@ class TestFlavorsMongoDB(base.V2Base):
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
self.simulate_delete(self.pool_path)
|
||||
|
||||
super(TestFlavorsMongoDB, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_put_flavor_works(self):
|
||||
name = str(uuid.uuid1())
|
||||
@@ -264,9 +264,9 @@ class TestFlavorsMongoDB(base.V2Base):
|
||||
# NOTE(cpp-cabrera): delete initial flavor - it will interfere
|
||||
# with listing tests
|
||||
self.simulate_delete(self.flavor_path)
|
||||
query = 'limit={0}&detailed={1}'.format(limit, detailed)
|
||||
query = 'limit={}&detailed={}'.format(limit, detailed)
|
||||
if marker:
|
||||
query += '&marker={0}'.format(marker)
|
||||
query += '&marker={}'.format(marker)
|
||||
|
||||
with flavors(self, count):
|
||||
result = self.simulate_get(self.url_prefix + '/flavors',
|
||||
@@ -333,7 +333,7 @@ class TestFlavorsMongoDB(base.V2Base):
|
||||
|
||||
def test_listing_error_with_invalid_limit(self):
|
||||
self.simulate_delete(self.flavor_path)
|
||||
query = 'limit={0}&detailed={1}'.format(0, True)
|
||||
query = 'limit={}&detailed={}'.format(0, True)
|
||||
|
||||
with flavors(self, 10):
|
||||
self.simulate_get(self.url_prefix + '/flavors', query_string=query)
|
||||
|
||||
@@ -33,7 +33,7 @@ class TestHealthMongoDB(base.V2Base):
|
||||
|
||||
@testing.requires_mongodb
|
||||
def setUp(self):
|
||||
super(TestHealthMongoDB, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
def test_basic(self):
|
||||
path = self.url_prefix + '/health'
|
||||
|
||||
@@ -34,7 +34,7 @@ class TestMessagesMongoDB(base.V2Base):
|
||||
|
||||
@testing.requires_mongodb
|
||||
def setUp(self):
|
||||
super(TestMessagesMongoDB, self).setUp()
|
||||
super().setUp()
|
||||
|
||||
self.default_message_ttl = self.boot.transport._defaults.message_ttl
|
||||
|
||||
@@ -43,7 +43,7 @@ class TestMessagesMongoDB(base.V2Base):
|
||||
for i in range(4):
|
||||
db_name = "zaqar_test_pools_" + str(i)
|
||||
# NOTE(dynarro): we need to create a unique uri.
|
||||
new_uri = "%s/%s" % (uri, db_name)
|
||||
new_uri = "{}/{}".format(uri, db_name)
|
||||
options = {'database': db_name}
|
||||
doc = {'weight': 100, 'uri': new_uri, 'options': options}
|
||||
self.simulate_put(self.url_prefix + '/pools/' + str(i),
|
||||
@@ -78,7 +78,7 @@ class TestMessagesMongoDB(base.V2Base):
|
||||
self.simulate_delete(self.url_prefix + '/pools/' + str(i),
|
||||
headers=self.headers)
|
||||
|
||||
super(TestMessagesMongoDB, self).tearDown()
|
||||
super().tearDown()
|
||||
|
||||
def test_name_restrictions(self):
|
||||
sample_messages = [
|
||||
@@ -126,7 +126,7 @@ class TestMessagesMongoDB(base.V2Base):
|
||||
|
||||
self.assertEqual(len(sample_messages), len(msg_ids))
|
||||
|
||||
lookup = dict([(m['ttl'], m['body']) for m in sample_messages])
|
||||
lookup = {m['ttl']: m['body'] for m in sample_messages}
|
||||
|
||||
# Test GET on the message resource directly
|
||||
# NOTE(cpp-cabrera): force the passing of time to age a message
|
||||
@@ -166,10 +166,10 @@ class TestMessagesMongoDB(base.V2Base):
|
||||
|
||||
self.assertEqual(falcon.HTTP_200, self.srmock.status)
|
||||
result_doc = jsonutils.loads(result[0])
|
||||
expected_ttls = set(m['ttl'] for m in sample_messages)
|
||||
actual_ttls = set(m['ttl'] for m in result_doc['messages'])
|
||||
expected_ttls = {m['ttl'] for m in sample_messages}
|
||||
actual_ttls = {m['ttl'] for m in result_doc['messages']}
|
||||
self.assertFalse(expected_ttls - actual_ttls)
|
||||
actual_ids = set(m['id'] for m in result_doc['messages'])
|
||||
actual_ids = {m['id'] for m in result_doc['messages']}
|
||||
self.assertFalse(set(msg_ids) - actual_ids)
|
||||
|
||||
def test_exceeded_payloads(self):
|
||||
|
||||
@@ -38,7 +38,7 @@ def pool(test, name, weight, uri, flavor=None, options={}):
|
||||
:returns: (name, weight, uri, options)
|
||||
:rtype: see above
|
||||
"""
|
||||
uri = "%s/%s" % (uri, uuidutils.generate_uuid())
|
||||
uri = "{}/{}".format(uri, uuidutils.generate_uuid())
|
||||
doc = {'weight': weight, 'uri': uri,
|
||||
'flavor': flavor, 'options': options}
|
||||
path = test.url_prefix + '/pools/' + name
|
||||
@@ -70,7 +70,7 @@ def pools(test, count, uri, flavor):
|
||||
{str(i): i})
|
||||
for i in range(count)]
|
||||
for path, weight, option in args:
|
||||
uri = "%s/%s" % (mongo_url, uuidutils.generate_uuid())
|
||||
uri = "{}/{}".format(mongo_url, uuidutils.generate_uuid())
|
||||
doc = {'weight': weight, 'uri': uri,
|
||||
'flavor': flavor, 'options': option}
|
||||
test.simulate_put(path, body=jsonutils.dumps(doc))
|
||||
@@ -93,7 +93,7 @@ class TestPoolsMongoDB(base.V2Base):
|
||||
|
||||
@testing.requires_mongodb
|
||||
def setUp(self):
|
||||
super(TestPoolsMongoDB, self).setUp()
|
||||
super().setUp()
|
||||
self.doc = {'weight': 100,
|
||||
'flavor': 'my-flavor',
|
||||
'uri': self.mongodb_url}
|
||||
@@ -102,7 +102,7 @@ class TestPoolsMongoDB(base.V2Base):
|
||||
self.assertEqual(falcon.HTTP_201, self.srmock.status)
|
||||
|
||||
def tearDown(self):
|
||||
super(TestPoolsMongoDB, self).tearDown()
|
||||
super().tearDown()
|
||||
self.simulate_delete(self.pool)
|
||||
self.assertEqual(falcon.HTTP_204, self.srmock.status)
|
||||
|
||||
@@ -294,9 +294,9 @@ class TestPoolsMongoDB(base.V2Base):
|
||||
# (gengchc): Remove flavor from the pool, so we can delete the pool.
|
||||
self.simulate_patch(self.pool, body=jsonutils.dumps({'flavor': ''}))
|
||||
self.simulate_delete(self.pool)
|
||||
query = 'limit={0}&detailed={1}'.format(limit, detailed)
|
||||
query = 'limit={}&detailed={}'.format(limit, detailed)
|
||||
if marker:
|
||||
query += '&marker={0}'.format(marker)
|
||||
query += '&marker={}'.format(marker)
|
||||
|
||||
with pools(self, count, self.doc['uri'], 'my-flavor') as expected:
|
||||
result = self.simulate_get(self.url_prefix + '/pools',
|
||||
@@ -376,7 +376,7 @@ class TestPoolsMongoDB(base.V2Base):
|
||||
|
||||
def test_listing_error_with_invalid_limit(self):
|
||||
self.simulate_delete(self.pool)
|
||||
query = 'limit={0}&detailed={1}'.format(0, True)
|
||||
query = 'limit={}&detailed={}'.format(0, True)
|
||||
|
||||
with pools(self, 10, self.doc['uri'], 'my-flavor'):
|
||||
self.simulate_get(self.url_prefix + '/pools', query_string=query)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user