diff --git a/api-ref/source/conf.py b/api-ref/source/conf.py index 8d45f2715..177107174 100644 --- a/api-ref/source/conf.py +++ b/api-ref/source/conf.py @@ -39,8 +39,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'Infrastructure Optimization API Reference' -copyright = u'2010-present, OpenStack Foundation' +project = 'Infrastructure Optimization API Reference' +copyright = '2010-present, OpenStack Foundation' # openstackdocstheme options openstackdocs_repo_name = 'openstack/watcher' @@ -70,6 +70,6 @@ html_theme_options = { # (source start file, target name, title, author, documentclass # [howto/manual]). latex_documents = [ - ('index', 'Watcher.tex', u'Infrastructure Optimization API Reference', - u'OpenStack Foundation', 'manual'), + ('index', 'Watcher.tex', 'Infrastructure Optimization API Reference', + 'OpenStack Foundation', 'manual'), ] diff --git a/doc/ext/term.py b/doc/ext/term.py index f50f634b9..7c1a21517 100644 --- a/doc/ext/term.py +++ b/doc/ext/term.py @@ -27,7 +27,7 @@ class BaseWatcherDirective(rst.Directive): def __init__(self, name, arguments, options, content, lineno, content_offset, block_text, state, state_machine): - super(BaseWatcherDirective, self).__init__( + super().__init__( name, arguments, options, content, lineno, content_offset, block_text, state, state_machine) self.result = statemachine.ViewList() diff --git a/doc/ext/versioned_notifications.py b/doc/ext/versioned_notifications.py index 3149f0c47..44cf9e10f 100644 --- a/doc/ext/versioned_notifications.py +++ b/doc/ext/versioned_notifications.py @@ -112,7 +112,7 @@ jQuery(document).ready(function(){ col = nodes.entry() row.append(col) - with open(self.SAMPLE_ROOT + sample_file, 'r') as f: + with open(self.SAMPLE_ROOT + sample_file) as f: sample_content = f.read() event_type = sample_file[0: -5] diff --git a/watcher/_i18n.py b/watcher/_i18n.py index b410850b4..f3380cbec 100644 --- a/watcher/_i18n.py +++ b/watcher/_i18n.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/api/acl.py b/watcher/api/acl.py index c8a8775e1..2b6c42afe 100644 --- a/watcher/api/acl.py +++ b/watcher/api/acl.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright © 2012 New Dream Network, LLC (DreamHost) # Copyright (c) 2016 Intel Corp diff --git a/watcher/api/app.py b/watcher/api/app.py index 3e125adce..3366da4b6 100644 --- a/watcher/api/app.py +++ b/watcher/api/app.py @@ -1,5 +1,3 @@ -# -*- encoding: utf-8 -*- - # Copyright © 2012 New Dream Network, LLC (DreamHost) # All Rights Reserved. # Copyright (c) 2016 Intel Corp @@ -70,7 +68,7 @@ def _wrap_app(app): return app -class VersionSelectorApplication(object): +class VersionSelectorApplication: def __init__(self): pc = get_pecan_config() self.v1 = setup_app(config=pc) diff --git a/watcher/api/config.py b/watcher/api/config.py index 7064ad340..4dfb65067 100644 --- a/watcher/api/config.py +++ b/watcher/api/config.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/watcher/api/controllers/base.py b/watcher/api/controllers/base.py index 462c256c7..0b0e68141 100644 --- a/watcher/api/controllers/base.py +++ b/watcher/api/controllers/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -35,10 +34,10 @@ class APIBase(wtypes.Base): def as_dict(self): """Render this object as a dict of its fields.""" - return dict((k, getattr(self, k)) - for k in self.fields - if hasattr(self, k) and - getattr(self, k) != wsme.Unset) + return {k: getattr(self, k) + for k in self.fields + if hasattr(self, k) and + getattr(self, k) != wsme.Unset} def unset_fields_except(self, except_list=None): """Unset fields so they don't appear in the message body. @@ -55,7 +54,7 @@ class APIBase(wtypes.Base): @functools.total_ordering -class Version(object): +class Version: """API Version object.""" string = 'OpenStack-API-Version' diff --git a/watcher/api/controllers/link.py b/watcher/api/controllers/link.py index 91094323e..29347c1f2 100644 --- a/watcher/api/controllers/link.py +++ b/watcher/api/controllers/link.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 Red Hat, Inc. # All Rights Reserved. # diff --git a/watcher/api/controllers/root.py b/watcher/api/controllers/root.py index a2706edbd..99c98f40c 100644 --- a/watcher/api/controllers/root.py +++ b/watcher/api/controllers/root.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright © 2012 New Dream Network, LLC (DreamHost) # @@ -26,7 +25,7 @@ from watcher.api.controllers import link from watcher.api.controllers import v1 -class APIStatus(object): +class APIStatus: CURRENT = "CURRENT" SUPPORTED = "SUPPORTED" DEPRECATED = "DEPRECATED" @@ -118,4 +117,5 @@ class RootController(rest.RestController): if args[0] and args[0] not in self._versions: args = [self._default_version] + args - return super(RootController, self)._route(args, request) + + return super()._route(args, request) diff --git a/watcher/api/controllers/v1/__init__.py b/watcher/api/controllers/v1/__init__.py index 8e578691f..7f32f5d21 100644 --- a/watcher/api/controllers/v1/__init__.py +++ b/watcher/api/controllers/v1/__init__.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -72,10 +71,10 @@ class APIBase(wtypes.Base): def as_dict(self): """Render this object as a dict of its fields.""" - return dict((k, getattr(self, k)) - for k in self.fields - if hasattr(self, k) and - getattr(self, k) != wsme.Unset) + return {k: getattr(self, k) + for k in self.fields + if hasattr(self, k) and + getattr(self, k) != wsme.Unset} def unset_fields_except(self, except_list=None): """Unset fields so they don't appear in the message body. @@ -282,7 +281,7 @@ class Controller(rest.RestController): ' '.join([versions.service_type_string(), str(v)])) pecan.request.version = v - return super(Controller, self)._route(args, request) + return super()._route(args, request) __all__ = ("Controller", ) diff --git a/watcher/api/controllers/v1/action.py b/watcher/api/controllers/v1/action.py index 8893ad790..e9e208f1c 100644 --- a/watcher/api/controllers/v1/action.py +++ b/watcher/api/controllers/v1/action.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 Red Hat, Inc. # All Rights Reserved. # @@ -173,7 +172,7 @@ class Action(base.APIBase): """Status message""" def __init__(self, **kwargs): - super(Action, self).__init__() + super().__init__() self.fields = [] fields = list(objects.Action.fields) @@ -263,7 +262,7 @@ class ActionsController(rest.RestController): """REST controller for Actions.""" def __init__(self): - super(ActionsController, self).__init__() + super().__init__() _custom_actions = { 'detail': ['GET'], diff --git a/watcher/api/controllers/v1/action_plan.py b/watcher/api/controllers/v1/action_plan.py index 52c40d0d0..71dc8335f 100644 --- a/watcher/api/controllers/v1/action_plan.py +++ b/watcher/api/controllers/v1/action_plan.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 Red Hat, Inc. # All Rights Reserved. # @@ -253,7 +252,7 @@ class ActionPlan(base.APIBase): """Status message of the action plan""" def __init__(self, **kwargs): - super(ActionPlan, self).__init__() + super().__init__() self.fields = [] fields = list(objects.ActionPlan.fields) for field in fields: @@ -342,7 +341,7 @@ class ActionPlansController(rest.RestController): """REST controller for Actions.""" def __init__(self): - super(ActionPlansController, self).__init__() + super().__init__() self.applier_client = rpcapi.ApplierAPI() _custom_actions = { diff --git a/watcher/api/controllers/v1/audit.py b/watcher/api/controllers/v1/audit.py index 1918f3937..66b9df30d 100644 --- a/watcher/api/controllers/v1/audit.py +++ b/watcher/api/controllers/v1/audit.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 Red Hat, Inc. # All Rights Reserved. # @@ -162,7 +161,7 @@ class AuditPostType(wtypes.Base): 'strategy': 'strategy_id', 'scope': 'scope', } - to_string_fields = set(['goal', 'strategy']) + to_string_fields = {'goal', 'strategy'} for k in at2a: if not getattr(self, k): try: @@ -466,7 +465,7 @@ class AuditCollection(collection.Collection): """A list containing audits objects""" def __init__(self, **kwargs): - super(AuditCollection, self).__init__() + super().__init__() self._type = 'audits' @staticmethod @@ -489,7 +488,7 @@ class AuditsController(rest.RestController): """REST controller for Audits.""" def __init__(self): - super(AuditsController, self).__init__() + super().__init__() self.dc_client = rpcapi.DecisionEngineAPI() _custom_actions = { diff --git a/watcher/api/controllers/v1/audit_template.py b/watcher/api/controllers/v1/audit_template.py index 461a164ec..49527f3a4 100644 --- a/watcher/api/controllers/v1/audit_template.py +++ b/watcher/api/controllers/v1/audit_template.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 Red Hat, Inc. # All Rights Reserved. # @@ -376,7 +375,7 @@ class AuditTemplate(base.APIBase): """Audit Scope""" def __init__(self, **kwargs): - super(AuditTemplate, self).__init__() + super().__init__() self.fields = [] fields = list(objects.AuditTemplate.fields) @@ -453,7 +452,7 @@ class AuditTemplateCollection(collection.Collection): """A list containing audit templates objects""" def __init__(self, **kwargs): - super(AuditTemplateCollection, self).__init__() + super().__init__() self._type = 'audit_templates' @staticmethod @@ -477,7 +476,7 @@ class AuditTemplatesController(rest.RestController): """REST controller for AuditTemplates.""" def __init__(self): - super(AuditTemplatesController, self).__init__() + super().__init__() _custom_actions = { 'detail': ['GET'], diff --git a/watcher/api/controllers/v1/collection.py b/watcher/api/controllers/v1/collection.py index 05e05df1f..7fca387dd 100644 --- a/watcher/api/controllers/v1/collection.py +++ b/watcher/api/controllers/v1/collection.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 Red Hat, Inc. # All Rights Reserved. # diff --git a/watcher/api/controllers/v1/data_model.py b/watcher/api/controllers/v1/data_model.py index 9e6d164f5..3a6ed22b1 100644 --- a/watcher/api/controllers/v1/data_model.py +++ b/watcher/api/controllers/v1/data_model.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 ZTE Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -50,7 +49,7 @@ class DataModelController(rest.RestController): """REST controller for data model""" def __init__(self): - super(DataModelController, self).__init__() + super().__init__() @wsme_pecan.wsexpose(wtypes.text, wtypes.text, types.uuid) def get_all(self, data_model_type='compute', audit_uuid=None): diff --git a/watcher/api/controllers/v1/efficacy_indicator.py b/watcher/api/controllers/v1/efficacy_indicator.py index b17ccf2f3..39e2ebd00 100644 --- a/watcher/api/controllers/v1/efficacy_indicator.py +++ b/watcher/api/controllers/v1/efficacy_indicator.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -60,7 +59,7 @@ class EfficacyIndicator(base.APIBase): """Value of this efficacy indicator""" def __init__(self, **kwargs): - super(EfficacyIndicator, self).__init__() + super().__init__() self.fields = [] fields = list(objects.EfficacyIndicator.fields) diff --git a/watcher/api/controllers/v1/goal.py b/watcher/api/controllers/v1/goal.py index cdd9d7c3b..5f8433f3b 100644 --- a/watcher/api/controllers/v1/goal.py +++ b/watcher/api/controllers/v1/goal.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 Red Hat, Inc. # All Rights Reserved. # @@ -131,7 +130,7 @@ class GoalCollection(collection.Collection): """A list containing goals objects""" def __init__(self, **kwargs): - super(GoalCollection, self).__init__() + super().__init__() self._type = 'goals' @staticmethod @@ -155,7 +154,7 @@ class GoalsController(rest.RestController): """REST controller for Goals.""" def __init__(self): - super(GoalsController, self).__init__() + super().__init__() _custom_actions = { 'detail': ['GET'], diff --git a/watcher/api/controllers/v1/scoring_engine.py b/watcher/api/controllers/v1/scoring_engine.py index 06f5c0322..a9b35c64e 100644 --- a/watcher/api/controllers/v1/scoring_engine.py +++ b/watcher/api/controllers/v1/scoring_engine.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2016 Intel # All Rights Reserved. # @@ -76,7 +75,7 @@ class ScoringEngine(base.APIBase): """A list containing a self link and associated action links""" def __init__(self, **kwargs): - super(ScoringEngine, self).__init__() + super().__init__() self.fields = [] self.fields.append('uuid') @@ -123,7 +122,7 @@ class ScoringEngineCollection(collection.Collection): """A list containing scoring engine objects""" def __init__(self, **kwargs): - super(ScoringEngineCollection, self).__init__() + super().__init__() self._type = 'scoring_engines' @staticmethod @@ -147,7 +146,7 @@ class ScoringEngineController(rest.RestController): """REST controller for Scoring Engines.""" def __init__(self): - super(ScoringEngineController, self).__init__() + super().__init__() _custom_actions = { 'detail': ['GET'], diff --git a/watcher/api/controllers/v1/service.py b/watcher/api/controllers/v1/service.py index 1199c58cc..2e3768312 100644 --- a/watcher/api/controllers/v1/service.py +++ b/watcher/api/controllers/v1/service.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -109,7 +108,7 @@ class Service(base.APIBase): """A list containing a self link.""" def __init__(self, **kwargs): - super(Service, self).__init__() + super().__init__() fields = list(objects.Service.fields) + ['status'] self.fields = [] @@ -153,7 +152,7 @@ class ServiceCollection(collection.Collection): """A list containing services objects""" def __init__(self, **kwargs): - super(ServiceCollection, self).__init__() + super().__init__() self._type = 'services' @staticmethod @@ -177,7 +176,7 @@ class ServicesController(rest.RestController): """REST controller for Services.""" def __init__(self): - super(ServicesController, self).__init__() + super().__init__() _custom_actions = { 'detail': ['GET'], diff --git a/watcher/api/controllers/v1/strategy.py b/watcher/api/controllers/v1/strategy.py index 90754226d..595ef0fc1 100644 --- a/watcher/api/controllers/v1/strategy.py +++ b/watcher/api/controllers/v1/strategy.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -123,7 +122,7 @@ class Strategy(base.APIBase): """Parameters spec dict""" def __init__(self, **kwargs): - super(Strategy, self).__init__() + super().__init__() self.fields = [] self.fields.append('uuid') @@ -174,7 +173,7 @@ class StrategyCollection(collection.Collection): """A list containing strategies objects""" def __init__(self, **kwargs): - super(StrategyCollection, self).__init__() + super().__init__() self._type = 'strategies' @staticmethod @@ -198,7 +197,7 @@ class StrategiesController(rest.RestController): """REST controller for Strategies.""" def __init__(self): - super(StrategiesController, self).__init__() + super().__init__() _custom_actions = { 'detail': ['GET'], diff --git a/watcher/api/controllers/v1/types.py b/watcher/api/controllers/v1/types.py index a89728fdf..f071dfb9a 100644 --- a/watcher/api/controllers/v1/types.py +++ b/watcher/api/controllers/v1/types.py @@ -218,7 +218,7 @@ class JsonPatchType(wtypes.Base): @staticmethod def validate(patch): - _path = '/{0}'.format(patch.path.split('/')[1]) + _path = '/{}'.format(patch.path.split('/')[1]) if len(patch.allowed_attrs()) > 0: if _path not in patch.allowed_attrs(): msg = _("'%s' is not an allowed attribute and can not be " diff --git a/watcher/api/controllers/v1/webhooks.py b/watcher/api/controllers/v1/webhooks.py index 61ae40a0c..88787e3ba 100644 --- a/watcher/api/controllers/v1/webhooks.py +++ b/watcher/api/controllers/v1/webhooks.py @@ -34,7 +34,7 @@ class WebhookController(rest.RestController): """REST controller for webhooks resource.""" def __init__(self): - super(WebhookController, self).__init__() + super().__init__() self.dc_client = rpcapi.DecisionEngineAPI() @wsme_pecan.wsexpose(None, wtypes.text, body=types.jsontype, diff --git a/watcher/api/hooks.py b/watcher/api/hooks.py index 9bcf4d81f..72d39ef9a 100644 --- a/watcher/api/hooks.py +++ b/watcher/api/hooks.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright © 2012 New Dream Network, LLC (DreamHost) # diff --git a/watcher/api/middleware/auth_token.py b/watcher/api/middleware/auth_token.py index 7d9409f80..b33866134 100644 --- a/watcher/api/middleware/auth_token.py +++ b/watcher/api/middleware/auth_token.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -45,7 +44,7 @@ class AuthTokenMiddleware(auth_token.AuthProtocol): raise exception.ConfigInvalid( error_msg=_('Cannot compile public API routes')) - super(AuthTokenMiddleware, self).__init__(app, conf) + super().__init__(app, conf) def __call__(self, env, start_response): path = utils.safe_rstrip(env.get('PATH_INFO'), '/') @@ -59,4 +58,4 @@ class AuthTokenMiddleware(auth_token.AuthProtocol): if env['is_public_api']: return self._app(env, start_response) - return super(AuthTokenMiddleware, self).__call__(env, start_response) + return super().__call__(env, start_response) diff --git a/watcher/api/middleware/parsable_error.py b/watcher/api/middleware/parsable_error.py index e6ab542f8..41206d093 100644 --- a/watcher/api/middleware/parsable_error.py +++ b/watcher/api/middleware/parsable_error.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright © 2012 New Dream Network, LLC (DreamHost) # @@ -31,7 +30,7 @@ from watcher._i18n import _ LOG = log.getLogger(__name__) -class ParsableErrorMiddleware(object): +class ParsableErrorMiddleware: """Replace error body with something the client can parse.""" def __init__(self, app): diff --git a/watcher/api/scheduling.py b/watcher/api/scheduling.py index d981e7380..688b850b0 100644 --- a/watcher/api/scheduling.py +++ b/watcher/api/scheduling.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +34,7 @@ class APISchedulingService(scheduling.BackgroundSchedulerService): def __init__(self, gconfig={}, **options): self.services_status = {} - super(APISchedulingService, self).__init__(gconfig, **options) + super().__init__(gconfig, **options) def get_services_status(self, context): services = objects.service.Service.list(context) @@ -110,7 +109,7 @@ class APISchedulingService(scheduling.BackgroundSchedulerService): trigger='interval', jobstore='default', args=[context], next_run_time=datetime.datetime.now(), seconds=CONF.periodic_interval) - super(APISchedulingService, self).start() + super().start() def stop(self): """Stop service.""" diff --git a/watcher/applier/action_plan/base.py b/watcher/applier/action_plan/base.py index a47388ad0..c30787726 100644 --- a/watcher/applier/action_plan/base.py +++ b/watcher/applier/action_plan/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -20,7 +19,7 @@ import abc -class BaseActionPlanHandler(object, metaclass=abc.ABCMeta): +class BaseActionPlanHandler(metaclass=abc.ABCMeta): @abc.abstractmethod def execute(self): raise NotImplementedError() diff --git a/watcher/applier/action_plan/default.py b/watcher/applier/action_plan/default.py index 530cd1c1a..59463781a 100644 --- a/watcher/applier/action_plan/default.py +++ b/watcher/applier/action_plan/default.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -34,7 +33,7 @@ LOG = log.getLogger(__name__) class DefaultActionPlanHandler(base.BaseActionPlanHandler): def __init__(self, context, service, action_plan_uuid): - super(DefaultActionPlanHandler, self).__init__() + super().__init__() self.ctx = context self.service = service self.action_plan_uuid = action_plan_uuid diff --git a/watcher/applier/actions/base.py b/watcher/applier/actions/base.py index 738f124e8..c3b9540a8 100644 --- a/watcher/applier/actions/base.py +++ b/watcher/applier/actions/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -42,7 +41,7 @@ class BaseAction(loadable.Loadable, metaclass=abc.ABCMeta): :param osc: an OpenStackClients instance, defaults to None :type osc: :py:class:`~.OpenStackClients` instance, optional """ - super(BaseAction, self).__init__(config) + super().__init__(config) self._input_parameters = {} self._osc = osc diff --git a/watcher/applier/actions/change_node_power_state.py b/watcher/applier/actions/change_node_power_state.py index 6755343bd..7b3ef000b 100644 --- a/watcher/applier/actions/change_node_power_state.py +++ b/watcher/applier/actions/change_node_power_state.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE # # Authors: Li Canwei diff --git a/watcher/applier/actions/change_nova_service_state.py b/watcher/applier/actions/change_nova_service_state.py index c557a5a9b..3a16ce9fe 100644 --- a/watcher/applier/actions/change_nova_service_state.py +++ b/watcher/applier/actions/change_nova_service_state.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS diff --git a/watcher/applier/actions/factory.py b/watcher/applier/actions/factory.py index 5d773a609..62852cfcb 100644 --- a/watcher/applier/actions/factory.py +++ b/watcher/applier/actions/factory.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +21,7 @@ from watcher.applier.loading import default LOG = log.getLogger(__name__) -class ActionFactory(object): +class ActionFactory: def __init__(self): self.action_loader = default.DefaultActionLoader() diff --git a/watcher/applier/actions/migration.py b/watcher/applier/actions/migration.py index d94bfaeda..4b326d12c 100644 --- a/watcher/applier/actions/migration.py +++ b/watcher/applier/actions/migration.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS diff --git a/watcher/applier/actions/nop.py b/watcher/applier/actions/nop.py index a3d9c46ab..cf0a801e3 100644 --- a/watcher/applier/actions/nop.py +++ b/watcher/applier/actions/nop.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS diff --git a/watcher/applier/actions/resize.py b/watcher/applier/actions/resize.py index 34ca1c2c9..42acab55e 100644 --- a/watcher/applier/actions/resize.py +++ b/watcher/applier/actions/resize.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica # # Authors: Alexander Chadin diff --git a/watcher/applier/actions/sleep.py b/watcher/applier/actions/sleep.py index 5865c221d..70f2f44f4 100644 --- a/watcher/applier/actions/sleep.py +++ b/watcher/applier/actions/sleep.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS diff --git a/watcher/applier/actions/stop.py b/watcher/applier/actions/stop.py index af6c78322..4625b8f64 100644 --- a/watcher/applier/actions/stop.py +++ b/watcher/applier/actions/stop.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/watcher/applier/actions/volume_migration.py b/watcher/applier/actions/volume_migration.py index 8575eea47..04ae2effe 100644 --- a/watcher/applier/actions/volume_migration.py +++ b/watcher/applier/actions/volume_migration.py @@ -66,7 +66,7 @@ class VolumeMigrate(base.BaseAction): DESTINATION_TYPE = "destination_type" def __init__(self, config, osc=None): - super(VolumeMigrate, self).__init__(config) + super().__init__(config) self.cinder_util = cinder_helper.CinderHelper(osc=self.osc) self.nova_util = nova_helper.NovaHelper(osc=self.osc) diff --git a/watcher/applier/base.py b/watcher/applier/base.py index 3aedba613..cbec4f1d5 100644 --- a/watcher/applier/base.py +++ b/watcher/applier/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -28,7 +27,7 @@ See: :doc:`../architecture` for more details on this component. import abc -class BaseApplier(object, metaclass=abc.ABCMeta): +class BaseApplier(metaclass=abc.ABCMeta): @abc.abstractmethod def execute(self, action_plan_uuid): raise NotImplementedError() diff --git a/watcher/applier/default.py b/watcher/applier/default.py index aac85d689..13a044cdd 100644 --- a/watcher/applier/default.py +++ b/watcher/applier/default.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -29,7 +28,7 @@ CONF = cfg.CONF class DefaultApplier(base.BaseApplier): def __init__(self, context, applier_manager): - super(DefaultApplier, self).__init__() + super().__init__() self._applier_manager = applier_manager self._loader = default.DefaultWorkFlowEngineLoader() self._engine = None diff --git a/watcher/applier/loading/default.py b/watcher/applier/loading/default.py index c3ca90099..bfce51a34 100644 --- a/watcher/applier/loading/default.py +++ b/watcher/applier/loading/default.py @@ -16,11 +16,11 @@ from watcher.common.loader import default class DefaultWorkFlowEngineLoader(default.DefaultLoader): def __init__(self): - super(DefaultWorkFlowEngineLoader, self).__init__( + super().__init__( namespace='watcher_workflow_engines') class DefaultActionLoader(default.DefaultLoader): def __init__(self): - super(DefaultActionLoader, self).__init__( + super().__init__( namespace='watcher_actions') diff --git a/watcher/applier/manager.py b/watcher/applier/manager.py index 03a2356fe..900bc97c7 100644 --- a/watcher/applier/manager.py +++ b/watcher/applier/manager.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # Copyright (c) 2016 Intel Corp # diff --git a/watcher/applier/messaging/trigger.py b/watcher/applier/messaging/trigger.py index 03502cd66..acb0b2867 100644 --- a/watcher/applier/messaging/trigger.py +++ b/watcher/applier/messaging/trigger.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -27,7 +26,7 @@ LOG = log.getLogger(__name__) CONF = cfg.CONF -class TriggerActionPlan(object): +class TriggerActionPlan: def __init__(self, applier_manager): self.applier_manager = applier_manager workers = CONF.watcher_applier.workers diff --git a/watcher/applier/rpcapi.py b/watcher/applier/rpcapi.py index 6788dc6d8..33250d706 100644 --- a/watcher/applier/rpcapi.py +++ b/watcher/applier/rpcapi.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # Copyright (c) 2016 Intel Corp # @@ -30,7 +29,7 @@ CONF = conf.CONF class ApplierAPI(service.Service): def __init__(self): - super(ApplierAPI, self).__init__(ApplierAPIManager) + super().__init__(ApplierAPIManager) def launch_action_plan(self, context, action_plan_uuid=None): if not utils.is_uuid_like(action_plan_uuid): diff --git a/watcher/applier/sync.py b/watcher/applier/sync.py index 9fd97b321..aa49ebac7 100644 --- a/watcher/applier/sync.py +++ b/watcher/applier/sync.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +27,7 @@ CONF = cfg.CONF LOG = log.getLogger(__name__) -class Syncer(object): +class Syncer: """Syncs all available actions with the Watcher DB""" def sync(self): diff --git a/watcher/applier/workflow_engine/base.py b/watcher/applier/workflow_engine/base.py index 798939ccb..0a6d9bd84 100644 --- a/watcher/applier/workflow_engine/base.py +++ b/watcher/applier/workflow_engine/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # @@ -48,7 +47,7 @@ class BaseWorkFlowEngine(loadable.Loadable, metaclass=abc.ABCMeta): :param osc: an OpenStackClients object, defaults to None :type osc: :py:class:`~.OpenStackClients` instance, optional """ - super(BaseWorkFlowEngine, self).__init__(config) + super().__init__(config) self._context = context self._applier_manager = applier_manager self._action_factory = factory.ActionFactory() @@ -111,7 +110,7 @@ class BaseWorkFlowEngine(loadable.Loadable, metaclass=abc.ABCMeta): class BaseTaskFlowActionContainer(flow_task.Task): def __init__(self, name, db_action, engine, **kwargs): - super(BaseTaskFlowActionContainer, self).__init__(name=name) + super().__init__(name=name) self._db_action = db_action self._engine = engine self.loaded_action = None diff --git a/watcher/applier/workflow_engine/default.py b/watcher/applier/workflow_engine/default.py index afd22a3da..2be85b38a 100644 --- a/watcher/applier/workflow_engine/default.py +++ b/watcher/applier/workflow_engine/default.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -130,11 +129,11 @@ class DefaultWorkFlowEngine(base.BaseWorkFlowEngine): class TaskFlowActionContainer(base.BaseTaskFlowActionContainer): def __init__(self, db_action, engine): - self.name = "action_type:{0} uuid:{1}".format(db_action.action_type, - db_action.uuid) - super(TaskFlowActionContainer, self).__init__(self.name, - db_action, - engine) + self.name = "action_type:{} uuid:{}".format(db_action.action_type, + db_action.uuid) + super().__init__(self.name, + db_action, + engine) def do_pre_execute(self): LOG.debug("Pre-condition action: %s", self.name) diff --git a/watcher/cmd/dbmanage.py b/watcher/cmd/dbmanage.py index 883efaaec..8b45bf3b8 100644 --- a/watcher/cmd/dbmanage.py +++ b/watcher/cmd/dbmanage.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright 2013 Hewlett-Packard Development Company, L.P. # All Rights Reserved. @@ -31,7 +30,7 @@ from watcher.db import purge CONF = conf.CONF -class DBCommand(object): +class DBCommand: @staticmethod def upgrade(): @@ -145,11 +144,11 @@ def main(): register_sub_command_opts() # this is hack to work with previous usage of watcher-dbsync # pls change it to watcher-dbsync upgrade - valid_commands = set([ + valid_commands = { 'upgrade', 'downgrade', 'revision', 'version', 'stamp', 'create_schema', 'purge', - ]) + } if not set(sys.argv).intersection(valid_commands): sys.argv.append('upgrade') diff --git a/watcher/cmd/eventlet/api.py b/watcher/cmd/eventlet/api.py index 8e85a0c54..6021eca42 100644 --- a/watcher/cmd/eventlet/api.py +++ b/watcher/cmd/eventlet/api.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright 2013 Hewlett-Packard Development Company, L.P. # All Rights Reserved. diff --git a/watcher/cmd/eventlet/applier.py b/watcher/cmd/eventlet/applier.py index 8db5a2491..bf7365998 100644 --- a/watcher/cmd/eventlet/applier.py +++ b/watcher/cmd/eventlet/applier.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright 2013 Hewlett-Packard Development Company, L.P. # All Rights Reserved. diff --git a/watcher/cmd/eventlet/decisionengine.py b/watcher/cmd/eventlet/decisionengine.py index 836e3d396..5bdfdde13 100644 --- a/watcher/cmd/eventlet/decisionengine.py +++ b/watcher/cmd/eventlet/decisionengine.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright 2013 Hewlett-Packard Development Company, L.P. # All Rights Reserved. diff --git a/watcher/cmd/sync.py b/watcher/cmd/sync.py index 408fa89da..b5f86c056 100644 --- a/watcher/cmd/sync.py +++ b/watcher/cmd/sync.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright (c) 2016 Intel # diff --git a/watcher/common/cinder_helper.py b/watcher/common/cinder_helper.py index c00eaaad5..4e66de53b 100644 --- a/watcher/common/cinder_helper.py +++ b/watcher/common/cinder_helper.py @@ -27,7 +27,7 @@ CONF = conf.CONF LOG = log.getLogger(__name__) -class CinderHelper(object): +class CinderHelper: def __init__(self, osc=None): """:param osc: an OpenStackClients instance""" diff --git a/watcher/common/clients.py b/watcher/common/clients.py index 5e58b4a6d..de5a12656 100644 --- a/watcher/common/clients.py +++ b/watcher/common/clients.py @@ -61,7 +61,7 @@ def check_min_nova_api_version(config_version): MIN_NOVA_API_VERSION)) -class OpenStackClients(object): +class OpenStackClients: """Convenience class to create and cache client instances.""" def __init__(self): diff --git a/watcher/common/exception.py b/watcher/common/exception.py index 3b7202ce4..36bef1d77 100644 --- a/watcher/common/exception.py +++ b/watcher/common/exception.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -93,7 +92,7 @@ class WatcherException(Exception): # at least get the core msg_fmt out if something happened message = self.msg_fmt - super(WatcherException, self).__init__(message) + super().__init__(message) def __str__(self): """Encode to utf-8 then wsme api can consume it as well""" diff --git a/watcher/common/executor.py b/watcher/common/executor.py index 2892a1451..d9c651215 100644 --- a/watcher/common/executor.py +++ b/watcher/common/executor.py @@ -48,4 +48,4 @@ class APSchedulerThreadPoolExecutor(pool_executor.BasePoolExecutor): def __init__(self, max_workers=10): pool = get_futurist_pool_executor(max_workers) - super(APSchedulerThreadPoolExecutor, self).__init__(pool) + super().__init__(pool) diff --git a/watcher/common/ironic_helper.py b/watcher/common/ironic_helper.py index e8b0b56a4..507705aeb 100644 --- a/watcher/common/ironic_helper.py +++ b/watcher/common/ironic_helper.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE Corporation # # Authors:Yumeng Bao @@ -26,7 +25,7 @@ from watcher.common import utils LOG = log.getLogger(__name__) -class IronicHelper(object): +class IronicHelper: def __init__(self, osc=None): """:param osc: an OpenStackClients instance""" diff --git a/watcher/common/keystone_helper.py b/watcher/common/keystone_helper.py index 4cfcaec14..a0d4ac71b 100644 --- a/watcher/common/keystone_helper.py +++ b/watcher/common/keystone_helper.py @@ -24,7 +24,7 @@ CONF = conf.CONF LOG = log.getLogger(__name__) -class KeystoneHelper(object): +class KeystoneHelper: def __init__(self, osc=None): """:param osc: an OpenStackClients instance""" diff --git a/watcher/common/loader/base.py b/watcher/common/loader/base.py index 8a88e9fc4..b86943c76 100644 --- a/watcher/common/loader/base.py +++ b/watcher/common/loader/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,7 +16,7 @@ import abc -class BaseLoader(object, metaclass=abc.ABCMeta): +class BaseLoader(metaclass=abc.ABCMeta): @abc.abstractmethod def list_available(self): diff --git a/watcher/common/loader/default.py b/watcher/common/loader/default.py index aad9689b9..271395fac 100644 --- a/watcher/common/loader/default.py +++ b/watcher/common/loader/default.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +34,7 @@ class DefaultLoader(base.BaseLoader): :type namespace: str :param conf: ConfigOpts instance, defaults to cfg.CONF """ - super(DefaultLoader, self).__init__() + super().__init__() self.namespace = namespace self.conf = conf diff --git a/watcher/common/loader/loadable.py b/watcher/common/loader/loadable.py index 02fe212b4..b7bae5fee 100644 --- a/watcher/common/loader/loadable.py +++ b/watcher/common/loader/loadable.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,7 +18,7 @@ import abc from watcher.common import service -class Loadable(object, metaclass=abc.ABCMeta): +class Loadable(metaclass=abc.ABCMeta): """Generic interface for dynamically loading a driver/entry point. This defines the contract in order to let the loader manager inject @@ -27,7 +26,7 @@ class Loadable(object, metaclass=abc.ABCMeta): """ def __init__(self, config): - super(Loadable, self).__init__() + super().__init__() self.config = config @classmethod @@ -45,7 +44,7 @@ LoadableSingletonMeta = type( "LoadableSingletonMeta", (abc.ABCMeta, service.Singleton), {}) -class LoadableSingleton(object, metaclass=LoadableSingletonMeta): +class LoadableSingleton(metaclass=LoadableSingletonMeta): """Generic interface for dynamically loading a driver as a singleton. This defines the contract in order to let the loader manager inject @@ -54,7 +53,7 @@ class LoadableSingleton(object, metaclass=LoadableSingletonMeta): """ def __init__(self, config): - super(LoadableSingleton, self).__init__() + super().__init__() self.config = config @classmethod diff --git a/watcher/common/nova_helper.py b/watcher/common/nova_helper.py index e8719d8ca..7e6766d43 100644 --- a/watcher/common/nova_helper.py +++ b/watcher/common/nova_helper.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -34,7 +33,7 @@ LOG = log.getLogger(__name__) CONF = conf.CONF -class NovaHelper(object): +class NovaHelper: def __init__(self, osc=None): """:param osc: an OpenStackClients instance""" diff --git a/watcher/common/oslo_service_helper.py b/watcher/common/oslo_service_helper.py index 8da661563..f7c672aca 100644 --- a/watcher/common/oslo_service_helper.py +++ b/watcher/common/oslo_service_helper.py @@ -1,4 +1,3 @@ - # Copyright 2025 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may diff --git a/watcher/common/placement_helper.py b/watcher/common/placement_helper.py index c4ecdc174..346b21774 100644 --- a/watcher/common/placement_helper.py +++ b/watcher/common/placement_helper.py @@ -21,7 +21,7 @@ CONF = cfg.CONF LOG = logging.getLogger(__name__) -class PlacementHelper(object): +class PlacementHelper: def __init__(self, osc=None): """:param osc: an OpenStackClients instance""" diff --git a/watcher/common/scheduling.py b/watcher/common/scheduling.py index c02b9e9eb..c3b3e2a03 100644 --- a/watcher/common/scheduling.py +++ b/watcher/common/scheduling.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/common/service.py b/watcher/common/service.py index 49f009369..152caa15b 100644 --- a/watcher/common/service.py +++ b/watcher/common/service.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright © 2012 eNovance ## @@ -109,7 +108,7 @@ class ServiceHeartbeat(scheduling.BackgroundSchedulerService): def __init__(self, gconfig=None, service_name=None, **kwargs): gconfig = None or {} - super(ServiceHeartbeat, self).__init__(gconfig, **kwargs) + super().__init__(gconfig, **kwargs) ServiceHeartbeat.service_name = service_name self.context = context.make_context() self.send_beat() @@ -140,7 +139,7 @@ class ServiceHeartbeat(scheduling.BackgroundSchedulerService): def start(self): """Start service.""" self.add_heartbeat_job() - super(ServiceHeartbeat, self).start() + super().start() def stop(self): """Stop service.""" @@ -161,7 +160,7 @@ class Service(service.ServiceBase): API_VERSION = '1.0' def __init__(self, manager_class): - super(Service, self).__init__() + super().__init__() self.manager = manager_class() self.publisher_id = self.manager.publisher_id diff --git a/watcher/common/service_manager.py b/watcher/common/service_manager.py index f3d770080..1272562e8 100644 --- a/watcher/common/service_manager.py +++ b/watcher/common/service_manager.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright © 2016 Servionica ## @@ -17,7 +16,7 @@ import abc -class ServiceManager(object, metaclass=abc.ABCMeta): +class ServiceManager(metaclass=abc.ABCMeta): @property @abc.abstractmethod diff --git a/watcher/common/utils.py b/watcher/common/utils.py index 0d5076185..033a26388 100644 --- a/watcher/common/utils.py +++ b/watcher/common/utils.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -126,10 +125,9 @@ def extend_with_default(validator_class): if "default" in subschema and instance is not None: instance.setdefault(prop, subschema["default"]) - for error in validate_properties( + yield from validate_properties( validator, properties, instance, schema - ): - yield error + ) return validators.extend(validator_class, {"properties": set_defaults}) @@ -147,10 +145,9 @@ def extend_with_strict_schema(validator_class): if para not in properties.keys(): raise exception.AuditParameterNotAllowed(parameter=para) - for error in validate_properties( + yield from validate_properties( validator, properties, instance, schema - ): - yield error + ) return validators.extend(validator_class, {"properties": strict_schema}) diff --git a/watcher/conf/__init__.py b/watcher/conf/__init__.py index 337339e6d..570d52a59 100644 --- a/watcher/conf/__init__.py +++ b/watcher/conf/__init__.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # Copyright (c) 2016 Intel Corp # diff --git a/watcher/conf/api.py b/watcher/conf/api.py index ceffc7fe3..2071e5a84 100644 --- a/watcher/conf/api.py +++ b/watcher/conf/api.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/applier.py b/watcher/conf/applier.py index 3d0c58733..ac3ba0df3 100644 --- a/watcher/conf/applier.py +++ b/watcher/conf/applier.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/cinder_client.py b/watcher/conf/cinder_client.py index d3cf86ba0..c389b0d45 100644 --- a/watcher/conf/cinder_client.py +++ b/watcher/conf/cinder_client.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/clients_auth.py b/watcher/conf/clients_auth.py index 257d1abd1..84a5e8e0a 100644 --- a/watcher/conf/clients_auth.py +++ b/watcher/conf/clients_auth.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/datasources.py b/watcher/conf/datasources.py index c69903ac9..a5468938c 100644 --- a/watcher/conf/datasources.py +++ b/watcher/conf/datasources.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken diff --git a/watcher/conf/db.py b/watcher/conf/db.py index 53de882a0..dc8bcc617 100644 --- a/watcher/conf/db.py +++ b/watcher/conf/db.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi @@ -21,7 +20,7 @@ from oslo_db import options as oslo_db_options from watcher.conf import paths -_DEFAULT_SQL_CONNECTION = 'sqlite:///{0}'.format( +_DEFAULT_SQL_CONNECTION = 'sqlite:///{}'.format( paths.state_path_def('watcher.sqlite')) database = cfg.OptGroup(name='database', diff --git a/watcher/conf/decision_engine.py b/watcher/conf/decision_engine.py index b48f5750f..b57d16486 100644 --- a/watcher/conf/decision_engine.py +++ b/watcher/conf/decision_engine.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/exception.py b/watcher/conf/exception.py index 3d9f67d9c..3fe9bbbed 100644 --- a/watcher/conf/exception.py +++ b/watcher/conf/exception.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/glance_client.py b/watcher/conf/glance_client.py index 50437d38b..14f2270ac 100644 --- a/watcher/conf/glance_client.py +++ b/watcher/conf/glance_client.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/gnocchi_client.py b/watcher/conf/gnocchi_client.py index 637002f27..2d11a1c8c 100644 --- a/watcher/conf/gnocchi_client.py +++ b/watcher/conf/gnocchi_client.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica # # Authors: Alexander Chadin diff --git a/watcher/conf/grafana_client.py b/watcher/conf/grafana_client.py index 066ae72f4..c33eca7f2 100644 --- a/watcher/conf/grafana_client.py +++ b/watcher/conf/grafana_client.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken diff --git a/watcher/conf/grafana_translators.py b/watcher/conf/grafana_translators.py index f8920e5f9..e7e15f99c 100644 --- a/watcher/conf/grafana_translators.py +++ b/watcher/conf/grafana_translators.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken diff --git a/watcher/conf/ironic_client.py b/watcher/conf/ironic_client.py index 016ee34d2..95f9d1c60 100644 --- a/watcher/conf/ironic_client.py +++ b/watcher/conf/ironic_client.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/keystone_client.py b/watcher/conf/keystone_client.py index 3e0102e71..425efdd64 100644 --- a/watcher/conf/keystone_client.py +++ b/watcher/conf/keystone_client.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 ZTE Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/conf/monasca_client.py b/watcher/conf/monasca_client.py index d1f52f48d..a35e3e163 100644 --- a/watcher/conf/monasca_client.py +++ b/watcher/conf/monasca_client.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/neutron_client.py b/watcher/conf/neutron_client.py index 7f3888cf3..28dc0b5a8 100644 --- a/watcher/conf/neutron_client.py +++ b/watcher/conf/neutron_client.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/nova_client.py b/watcher/conf/nova_client.py index 5287b373b..5bb46c525 100644 --- a/watcher/conf/nova_client.py +++ b/watcher/conf/nova_client.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/paths.py b/watcher/conf/paths.py index a499614e8..5e0b79a59 100644 --- a/watcher/conf/paths.py +++ b/watcher/conf/paths.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/planner.py b/watcher/conf/planner.py index 45e12dfd1..6d16917dd 100644 --- a/watcher/conf/planner.py +++ b/watcher/conf/planner.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Prudhvi Rao Shedimbi diff --git a/watcher/conf/plugins.py b/watcher/conf/plugins.py index d770520a8..0edd0b9e4 100644 --- a/watcher/conf/plugins.py +++ b/watcher/conf/plugins.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/conf/service.py b/watcher/conf/service.py index d0c824b6c..c0cd66ac9 100644 --- a/watcher/conf/service.py +++ b/watcher/conf/service.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/db/api.py b/watcher/db/api.py index 295ae48cf..9f893cb38 100644 --- a/watcher/db/api.py +++ b/watcher/db/api.py @@ -29,7 +29,7 @@ def get_instance(): return IMPL -class BaseConnection(object, metaclass=abc.ABCMeta): +class BaseConnection(metaclass=abc.ABCMeta): """Base class for storage system connections.""" @abc.abstractmethod diff --git a/watcher/db/purge.py b/watcher/db/purge.py index b39944027..cb2a6d1f9 100644 --- a/watcher/db/purge.py +++ b/watcher/db/purge.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -34,7 +33,7 @@ from watcher import objects LOG = log.getLogger(__name__) -class WatcherObjectsMap(object): +class WatcherObjectsMap: """Wrapper to deal with watcher objects per type This wrapper object contains a list of watcher objects per type. @@ -109,7 +108,7 @@ class WatcherObjectsMap(object): return table.get_string() -class PurgeCommand(object): +class PurgeCommand: """Purges the DB by removing soft deleted entries The workflow for this purge is the following: @@ -193,7 +192,7 @@ class PurgeCommand(object): action_plans = objects.ActionPlan.list(self.ctx, filters=filters) actions = objects.Action.list(self.ctx, filters=filters) - goal_ids = set(g.id for g in goals) + goal_ids = {g.id for g in goals} orphans.strategies = [ strategy for strategy in strategies if strategy.goal_id not in goal_ids] diff --git a/watcher/db/sqlalchemy/api.py b/watcher/db/sqlalchemy/api.py index dfd0615cf..8a9af46bc 100644 --- a/watcher/db/sqlalchemy/api.py +++ b/watcher/db/sqlalchemy/api.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright 2013 Hewlett-Packard Development Company, L.P. # @@ -111,7 +110,7 @@ class Connection(api.BaseConnection): } def __init__(self): - super(Connection, self).__init__() + super().__init__() def __add_simple_filter(self, query, model, fieldname, value, operator_): field = getattr(model, fieldname) diff --git a/watcher/db/sqlalchemy/job_store.py b/watcher/db/sqlalchemy/job_store.py index cf0fbc4a7..347b3de81 100644 --- a/watcher/db/sqlalchemy/job_store.py +++ b/watcher/db/sqlalchemy/job_store.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica LTD # # Authors: Alexander Chadin @@ -52,8 +51,8 @@ class WatcherJobStore(sqlalchemy.SQLAlchemyJobStore): def __init__(self, url=None, engine=None, tablename='apscheduler_jobs', metadata=None, pickle_protocol=pickle.HIGHEST_PROTOCOL, tag=None): - super(WatcherJobStore, self).__init__(url, engine, tablename, - metadata, pickle_protocol) + super().__init__(url, engine, tablename, + metadata, pickle_protocol) metadata = maybe_ref(metadata) or MetaData() self.jobs_t = Table(tablename, metadata, autoload_with=engine) service_ident = service.ServiceHeartbeat.get_service_name() diff --git a/watcher/decision_engine/audit/base.py b/watcher/decision_engine/audit/base.py index 37cf72182..abd2207fd 100644 --- a/watcher/decision_engine/audit/base.py +++ b/watcher/decision_engine/audit/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -39,7 +38,7 @@ class BaseMetaClass(service.Singleton, abc.ABCMeta): pass -class BaseAuditHandler(object, metaclass=BaseMetaClass): +class BaseAuditHandler(metaclass=BaseMetaClass): @abc.abstractmethod def execute(self, audit, request_context): @@ -61,7 +60,7 @@ class BaseAuditHandler(object, metaclass=BaseMetaClass): class AuditHandler(BaseAuditHandler, metaclass=abc.ABCMeta): def __init__(self): - super(AuditHandler, self).__init__() + super().__init__() self._strategy_context = default_context.DefaultStrategyContext() self._planner_loader = loader.DefaultPlannerLoader() self.applier_client = rpcapi.ApplierAPI() diff --git a/watcher/decision_engine/audit/continuous.py b/watcher/decision_engine/audit/continuous.py index ebb0eb6dd..3582a85dc 100644 --- a/watcher/decision_engine/audit/continuous.py +++ b/watcher/decision_engine/audit/continuous.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica LTD # Copyright (c) 2016 Intel Corp # @@ -39,7 +38,7 @@ CONF = conf.CONF class ContinuousAuditHandler(base.AuditHandler): def __init__(self): - super(ContinuousAuditHandler, self).__init__() + super().__init__() # scheduler for executing audits self._audit_scheduler = None # scheduler for a periodic task to launch audit @@ -82,7 +81,7 @@ class ContinuousAuditHandler(base.AuditHandler): return False def do_execute(self, audit, request_context): - solution = super(ContinuousAuditHandler, self)\ + solution = super()\ .do_execute(audit, request_context) if audit.audit_type == objects.audit.AuditType.CONTINUOUS.value: diff --git a/watcher/decision_engine/audit/event.py b/watcher/decision_engine/audit/event.py index 3cb1b8686..a01ccd22d 100644 --- a/watcher/decision_engine/audit/event.py +++ b/watcher/decision_engine/audit/event.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 ZTE Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +20,7 @@ from watcher import objects class EventAuditHandler(base.AuditHandler): def post_execute(self, audit, solution, request_context): - super(EventAuditHandler, self).post_execute(audit, solution, - request_context) + super().post_execute(audit, solution, + request_context) # change state of the audit to SUCCEEDED self.update_audit_state(audit, objects.audit.State.SUCCEEDED) diff --git a/watcher/decision_engine/audit/oneshot.py b/watcher/decision_engine/audit/oneshot.py index a3628be33..fff5c7bac 100644 --- a/watcher/decision_engine/audit/oneshot.py +++ b/watcher/decision_engine/audit/oneshot.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +20,7 @@ from watcher import objects class OneShotAuditHandler(base.AuditHandler): def post_execute(self, audit, solution, request_context): - super(OneShotAuditHandler, self).post_execute(audit, solution, - request_context) + super().post_execute(audit, solution, + request_context) # change state of the audit to SUCCEEDED self.update_audit_state(audit, objects.audit.State.SUCCEEDED) diff --git a/watcher/decision_engine/datasources/aetos.py b/watcher/decision_engine/datasources/aetos.py index 6a507fda1..6abc86f28 100644 --- a/watcher/decision_engine/datasources/aetos.py +++ b/watcher/decision_engine/datasources/aetos.py @@ -38,7 +38,7 @@ class AetosHelper(prometheus_base.PrometheusBase): :param osc: OpenStackClients instance for Keystone authentication """ self.osc = osc if osc else clients.OpenStackClients() - super(AetosHelper, self).__init__() + super().__init__() def _get_fqdn_label(self): """Get the FQDN label from aetos_client config""" diff --git a/watcher/decision_engine/datasources/base.py b/watcher/decision_engine/datasources/base.py index 9dfa664e8..de04de8ba 100644 --- a/watcher/decision_engine/datasources/base.py +++ b/watcher/decision_engine/datasources/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2017 NEC Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,7 +24,7 @@ CONF = cfg.CONF LOG = log.getLogger(__name__) -class DataSourceBase(object): +class DataSourceBase: """Base Class for datasources in Watcher This base class defines the abstract methods that datasources should diff --git a/watcher/decision_engine/datasources/gnocchi.py b/watcher/decision_engine/datasources/gnocchi.py index fc9920ded..a7ff11d90 100644 --- a/watcher/decision_engine/datasources/gnocchi.py +++ b/watcher/decision_engine/datasources/gnocchi.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica # # Authors: Alexander Chadin @@ -64,7 +63,7 @@ class GnocchiHelper(base.DataSourceBase): if not response: return set() else: - return set([metric['name'] for metric in response]) + return {metric['name'] for metric in response} def statistic_aggregation(self, resource=None, resource_type=None, meter_name=None, period=300, aggregate='mean', diff --git a/watcher/decision_engine/datasources/grafana.py b/watcher/decision_engine/datasources/grafana.py index 059e78dd0..d47a2add3 100644 --- a/watcher/decision_engine/datasources/grafana.py +++ b/watcher/decision_engine/datasources/grafana.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken diff --git a/watcher/decision_engine/datasources/grafana_translator/base.py b/watcher/decision_engine/datasources/grafana_translator/base.py index 5edbf9321..c9f548ac8 100644 --- a/watcher/decision_engine/datasources/grafana_translator/base.py +++ b/watcher/decision_engine/datasources/grafana_translator/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken @@ -23,7 +22,7 @@ from watcher.common import exception from watcher.decision_engine.datasources import base -class BaseGrafanaTranslator(object): +class BaseGrafanaTranslator: """Grafana translator baseclass to use with grafana for different databases Specific databasses that are proxied through grafana require some diff --git a/watcher/decision_engine/datasources/grafana_translator/influxdb.py b/watcher/decision_engine/datasources/grafana_translator/influxdb.py index b68d1779d..c2f1a8291 100644 --- a/watcher/decision_engine/datasources/grafana_translator/influxdb.py +++ b/watcher/decision_engine/datasources/grafana_translator/influxdb.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken @@ -34,7 +33,7 @@ class InfluxDBGrafanaTranslator(BaseGrafanaTranslator): NAME = 'influxdb' def __init__(self, data): - super(InfluxDBGrafanaTranslator, self).__init__(data) + super().__init__(data) def build_params(self): """""" diff --git a/watcher/decision_engine/datasources/manager.py b/watcher/decision_engine/datasources/manager.py index 17f94040f..9c75e7524 100644 --- a/watcher/decision_engine/datasources/manager.py +++ b/watcher/decision_engine/datasources/manager.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2017 NEC Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +29,7 @@ from watcher.decision_engine.datasources import prometheus as prom LOG = log.getLogger(__name__) -class DataSourceManager(object): +class DataSourceManager: metric_map = OrderedDict([ (gnoc.GnocchiHelper.NAME, gnoc.GnocchiHelper.METRIC_MAP), @@ -188,7 +187,7 @@ class DataSourceManager(object): def load_metric_map(self, file_path): """Load metrics from the metric_map_path""" if file_path and os.path.exists(file_path): - with open(file_path, 'r') as f: + with open(file_path) as f: try: ret = yaml.safe_load(f.read()) # return {} if the file is empty diff --git a/watcher/decision_engine/datasources/monasca.py b/watcher/decision_engine/datasources/monasca.py index a85923e59..a88df7f25 100644 --- a/watcher/decision_engine/datasources/monasca.py +++ b/watcher/decision_engine/datasources/monasca.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/decision_engine/gmr.py b/watcher/decision_engine/gmr.py index 8ddc56116..de57743fa 100644 --- a/watcher/decision_engine/gmr.py +++ b/watcher/decision_engine/gmr.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/decision_engine/goal/__init__.py b/watcher/decision_engine/goal/__init__.py index ec1295c30..017f32783 100644 --- a/watcher/decision_engine/goal/__init__.py +++ b/watcher/decision_engine/goal/__init__.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/goal/base.py b/watcher/decision_engine/goal/base.py index 9d0969070..e797b2574 100644 --- a/watcher/decision_engine/goal/base.py +++ b/watcher/decision_engine/goal/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +21,7 @@ from watcher.common.loader import loadable class Goal(loadable.Loadable, metaclass=abc.ABCMeta): def __init__(self, config): - super(Goal, self).__init__(config) + super().__init__(config) self.name = self.get_name() self.display_name = self.get_display_name() self.efficacy_specification = self.get_efficacy_specification() diff --git a/watcher/decision_engine/goal/efficacy/base.py b/watcher/decision_engine/goal/efficacy/base.py index fa8693b24..412d77370 100644 --- a/watcher/decision_engine/goal/efficacy/base.py +++ b/watcher/decision_engine/goal/efficacy/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +27,7 @@ import jsonschema from oslo_serialization import jsonutils -class EfficacySpecification(object, metaclass=abc.ABCMeta): +class EfficacySpecification(metaclass=abc.ABCMeta): def __init__(self): self._indicators_specs = self.get_indicators_specifications() diff --git a/watcher/decision_engine/goal/efficacy/indicators.py b/watcher/decision_engine/goal/efficacy/indicators.py index 7d44bb98a..349326cc4 100644 --- a/watcher/decision_engine/goal/efficacy/indicators.py +++ b/watcher/decision_engine/goal/efficacy/indicators.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +27,7 @@ from watcher.common import exception LOG = log.getLogger(__name__) -class IndicatorSpecification(object, metaclass=abc.ABCMeta): +class IndicatorSpecification(metaclass=abc.ABCMeta): def __init__(self, name=None, description=None, unit=None, required=True): self.name = name @@ -78,7 +77,7 @@ class IndicatorSpecification(object, metaclass=abc.ABCMeta): class ComputeNodesCount(IndicatorSpecification): def __init__(self): - super(ComputeNodesCount, self).__init__( + super().__init__( name="compute_nodes_count", description=_("The total number of enabled compute nodes."), unit=None, @@ -94,7 +93,7 @@ class ComputeNodesCount(IndicatorSpecification): class ReleasedComputeNodesCount(IndicatorSpecification): def __init__(self): - super(ReleasedComputeNodesCount, self).__init__( + super().__init__( name="released_compute_nodes_count", description=_("The number of compute nodes to be released."), unit=None, @@ -110,7 +109,7 @@ class ReleasedComputeNodesCount(IndicatorSpecification): class InstancesCount(IndicatorSpecification): def __init__(self): - super(InstancesCount, self).__init__( + super().__init__( name="instances_count", description=_("The total number of audited instances in " "strategy."), @@ -128,7 +127,7 @@ class InstancesCount(IndicatorSpecification): class InstanceMigrationsCount(IndicatorSpecification): def __init__(self): - super(InstanceMigrationsCount, self).__init__( + super().__init__( name="instance_migrations_count", description=_("The number of VM migrations to be performed."), unit=None, @@ -144,7 +143,7 @@ class InstanceMigrationsCount(IndicatorSpecification): class LiveInstanceMigrateCount(IndicatorSpecification): def __init__(self): - super(LiveInstanceMigrateCount, self).__init__( + super().__init__( name="live_migrate_instance_count", description=_("The number of instances actually live migrated."), unit=None, @@ -160,7 +159,7 @@ class LiveInstanceMigrateCount(IndicatorSpecification): class PlannedLiveInstanceMigrateCount(IndicatorSpecification): def __init__(self): - super(PlannedLiveInstanceMigrateCount, self).__init__( + super().__init__( name="planned_live_migrate_instance_count", description=_("The number of instances planned to live migrate."), unit=None, @@ -176,7 +175,7 @@ class PlannedLiveInstanceMigrateCount(IndicatorSpecification): class ColdInstanceMigrateCount(IndicatorSpecification): def __init__(self): - super(ColdInstanceMigrateCount, self).__init__( + super().__init__( name="cold_migrate_instance_count", description=_("The number of instances actually cold migrated."), unit=None, @@ -192,7 +191,7 @@ class ColdInstanceMigrateCount(IndicatorSpecification): class PlannedColdInstanceMigrateCount(IndicatorSpecification): def __init__(self): - super(PlannedColdInstanceMigrateCount, self).__init__( + super().__init__( name="planned_cold_migrate_instance_count", description=_("The number of instances planned to cold migrate."), unit=None, @@ -208,7 +207,7 @@ class PlannedColdInstanceMigrateCount(IndicatorSpecification): class VolumeMigrateCount(IndicatorSpecification): def __init__(self): - super(VolumeMigrateCount, self).__init__( + super().__init__( name="volume_migrate_count", description=_("The number of detached volumes actually migrated."), unit=None, @@ -224,7 +223,7 @@ class VolumeMigrateCount(IndicatorSpecification): class PlannedVolumeMigrateCount(IndicatorSpecification): def __init__(self): - super(PlannedVolumeMigrateCount, self).__init__( + super().__init__( name="planned_volume_migrate_count", description=_("The number of detached volumes planned" " to migrate."), @@ -241,7 +240,7 @@ class PlannedVolumeMigrateCount(IndicatorSpecification): class VolumeUpdateCount(IndicatorSpecification): def __init__(self): - super(VolumeUpdateCount, self).__init__( + super().__init__( name="volume_update_count", description=_("The number of attached volumes actually" " migrated."), @@ -258,7 +257,7 @@ class VolumeUpdateCount(IndicatorSpecification): class PlannedVolumeUpdateCount(IndicatorSpecification): def __init__(self): - super(PlannedVolumeUpdateCount, self).__init__( + super().__init__( name="planned_volume_update_count", description=_("The number of attached volumes planned to" " migrate."), @@ -275,7 +274,7 @@ class PlannedVolumeUpdateCount(IndicatorSpecification): class StandardDeviationValue(IndicatorSpecification): def __init__(self): - super(StandardDeviationValue, self).__init__( + super().__init__( name="standard_deviation_after_audit", description=_("The value of resulted standard deviation."), unit=None, @@ -292,7 +291,7 @@ class StandardDeviationValue(IndicatorSpecification): class OriginalStandardDeviationValue(IndicatorSpecification): def __init__(self): - super(OriginalStandardDeviationValue, self).__init__( + super().__init__( name="standard_deviation_before_audit", description=_("The value of original standard deviation."), unit=None, diff --git a/watcher/decision_engine/goal/efficacy/specs.py b/watcher/decision_engine/goal/efficacy/specs.py index 7997d7b35..9ef2ffc35 100644 --- a/watcher/decision_engine/goal/efficacy/specs.py +++ b/watcher/decision_engine/goal/efficacy/specs.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/goal/goals.py b/watcher/decision_engine/goal/goals.py index 54b9e7945..47c6b5a4d 100644 --- a/watcher/decision_engine/goal/goals.py +++ b/watcher/decision_engine/goal/goals.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/loading/default.py b/watcher/decision_engine/loading/default.py index 013c76ee5..24efbc911 100644 --- a/watcher/decision_engine/loading/default.py +++ b/watcher/decision_engine/loading/default.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -24,35 +23,35 @@ from watcher.common.loader import default class DefaultStrategyLoader(default.DefaultLoader): def __init__(self): - super(DefaultStrategyLoader, self).__init__( + super().__init__( namespace='watcher_strategies') class DefaultGoalLoader(default.DefaultLoader): def __init__(self): - super(DefaultGoalLoader, self).__init__( + super().__init__( namespace='watcher_goals') class DefaultPlannerLoader(default.DefaultLoader): def __init__(self): - super(DefaultPlannerLoader, self).__init__( + super().__init__( namespace='watcher_planners') class ClusterDataModelCollectorLoader(default.DefaultLoader): def __init__(self): - super(ClusterDataModelCollectorLoader, self).__init__( + super().__init__( namespace='watcher_cluster_data_model_collectors') class DefaultScoringLoader(default.DefaultLoader): def __init__(self): - super(DefaultScoringLoader, self).__init__( + super().__init__( namespace='watcher_scoring_engines') class DefaultScoringContainerLoader(default.DefaultLoader): def __init__(self): - super(DefaultScoringContainerLoader, self).__init__( + super().__init__( namespace='watcher_scoring_engine_containers') diff --git a/watcher/decision_engine/manager.py b/watcher/decision_engine/manager.py index 907aca81e..465d65cba 100644 --- a/watcher/decision_engine/manager.py +++ b/watcher/decision_engine/manager.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # Copyright (c) 2016 Intel Corp # diff --git a/watcher/decision_engine/messaging/audit_endpoint.py b/watcher/decision_engine/messaging/audit_endpoint.py index c3947273c..7cf0f3e7e 100644 --- a/watcher/decision_engine/messaging/audit_endpoint.py +++ b/watcher/decision_engine/messaging/audit_endpoint.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -29,7 +28,7 @@ CONF = cfg.CONF LOG = log.getLogger(__name__) -class AuditEndpoint(object): +class AuditEndpoint: def __init__(self, messaging): self._messaging = messaging diff --git a/watcher/decision_engine/messaging/data_model_endpoint.py b/watcher/decision_engine/messaging/data_model_endpoint.py index ae02abe56..6051d9e04 100644 --- a/watcher/decision_engine/messaging/data_model_endpoint.py +++ b/watcher/decision_engine/messaging/data_model_endpoint.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2019 ZTE corporation. # All Rights Reserved. # @@ -21,7 +20,7 @@ from watcher.decision_engine.model.collector import manager from watcher import objects -class DataModelEndpoint(object): +class DataModelEndpoint: def __init__(self, messaging): self._messaging = messaging diff --git a/watcher/decision_engine/model/base.py b/watcher/decision_engine/model/base.py index 97cde4cb0..085332960 100644 --- a/watcher/decision_engine/model/base.py +++ b/watcher/decision_engine/model/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -27,7 +26,7 @@ See: :doc:`../architecture` for more details on this component. import abc -class Model(object, metaclass=abc.ABCMeta): +class Model(metaclass=abc.ABCMeta): @abc.abstractmethod def to_string(self): diff --git a/watcher/decision_engine/model/collector/base.py b/watcher/decision_engine/model/collector/base.py index 412855f90..2c3e8083a 100644 --- a/watcher/decision_engine/model/collector/base.py +++ b/watcher/decision_engine/model/collector/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -125,7 +124,7 @@ class BaseClusterDataModelCollector(loadable.LoadableSingleton, STALE_MODEL = model_root.ModelRoot(stale=True) def __init__(self, config, osc=None): - super(BaseClusterDataModelCollector, self).__init__(config) + super().__init__(config) self.osc = osc if osc else clients.OpenStackClients() self.lock = threading.RLock() self._audit_scope_handler = None @@ -194,7 +193,7 @@ class BaseClusterDataModelCollector(loadable.LoadableSingleton, self.cluster_data_model = self.execute() -class BaseModelBuilder(object): +class BaseModelBuilder: def call_retry(self, f, *args, **kwargs): """Attempts to call external service diff --git a/watcher/decision_engine/model/collector/cinder.py b/watcher/decision_engine/model/collector/cinder.py index dd6b28a07..b1b8e6d82 100644 --- a/watcher/decision_engine/model/collector/cinder.py +++ b/watcher/decision_engine/model/collector/cinder.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2017 NEC Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -113,7 +112,7 @@ class CinderClusterDataModelCollector(base.BaseClusterDataModelCollector): } def __init__(self, config, osc=None): - super(CinderClusterDataModelCollector, self).__init__(config, osc) + super().__init__(config, osc) @property def notification_endpoints(self): diff --git a/watcher/decision_engine/model/collector/ironic.py b/watcher/decision_engine/model/collector/ironic.py index 142fc3cd1..b7393f87d 100644 --- a/watcher/decision_engine/model/collector/ironic.py +++ b/watcher/decision_engine/model/collector/ironic.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE Corporation # # Authors:Yumeng Bao @@ -34,7 +33,7 @@ class BaremetalClusterDataModelCollector(base.BaseClusterDataModelCollector): """ def __init__(self, config, osc=None): - super(BaremetalClusterDataModelCollector, self).__init__(config, osc) + super().__init__(config, osc) @property def notification_endpoints(self): diff --git a/watcher/decision_engine/model/collector/manager.py b/watcher/decision_engine/model/collector/manager.py index c508370ea..fb6160633 100644 --- a/watcher/decision_engine/model/collector/manager.py +++ b/watcher/decision_engine/model/collector/manager.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -28,7 +27,7 @@ from watcher.decision_engine.loading import default LOG = log.getLogger(__name__) -class CollectorManager(object): +class CollectorManager: def __init__(self, osc=None): self.collector_loader = default.ClusterDataModelCollectorLoader() diff --git a/watcher/decision_engine/model/collector/nova.py b/watcher/decision_engine/model/collector/nova.py index b65631031..6f49d4d76 100644 --- a/watcher/decision_engine/model/collector/nova.py +++ b/watcher/decision_engine/model/collector/nova.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Intel Innovation and Research Ireland Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -154,7 +153,7 @@ class NovaClusterDataModelCollector(base.BaseClusterDataModelCollector): } def __init__(self, config, osc=None): - super(NovaClusterDataModelCollector, self).__init__(config, osc) + super().__init__(config, osc) @property def notification_endpoints(self): @@ -322,8 +321,8 @@ class NovaModelBuilder(base.BaseModelBuilder): self.no_model_scope_flag = True all_nodes = self.call_retry( f=self.nova_helper.get_compute_node_list) - compute_nodes = set( - [node.hypervisor_hostname for node in all_nodes]) + compute_nodes = { + node.hypervisor_hostname for node in all_nodes} LOG.debug("compute nodes: %s", compute_nodes) node_futures = [self.executor.submit( diff --git a/watcher/decision_engine/model/element/__init__.py b/watcher/decision_engine/model/element/__init__.py index d80596da6..856957949 100644 --- a/watcher/decision_engine/model/element/__init__.py +++ b/watcher/decision_engine/model/element/__init__.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/decision_engine/model/element/baremetal_resource.py b/watcher/decision_engine/model/element/baremetal_resource.py index 359c7c1dc..c2479aec6 100644 --- a/watcher/decision_engine/model/element/baremetal_resource.py +++ b/watcher/decision_engine/model/element/baremetal_resource.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/model/element/base.py b/watcher/decision_engine/model/element/base.py index be2495ccd..3cdc23b0e 100644 --- a/watcher/decision_engine/model/element/base.py +++ b/watcher/decision_engine/model/element/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -43,7 +42,7 @@ class Element(base.WatcherObject, base.WatcherObjectDictCompat, if (name not in kwargs and not field.nullable and field.default != wfields.UnspecifiedDefault): kwargs[name] = field.default - super(Element, self).__init__(context, **kwargs) + super().__init__(context, **kwargs) @abc.abstractmethod def accept(self, visitor): diff --git a/watcher/decision_engine/model/element/compute_resource.py b/watcher/decision_engine/model/element/compute_resource.py index 76ba93277..317004d78 100644 --- a/watcher/decision_engine/model/element/compute_resource.py +++ b/watcher/decision_engine/model/element/compute_resource.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/model/element/instance.py b/watcher/decision_engine/model/element/instance.py index bb892e874..45d3f5e2e 100644 --- a/watcher/decision_engine/model/element/instance.py +++ b/watcher/decision_engine/model/element/instance.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/model/element/node.py b/watcher/decision_engine/model/element/node.py index 74b6d3895..1b07a77b4 100644 --- a/watcher/decision_engine/model/element/node.py +++ b/watcher/decision_engine/model/element/node.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/model/element/storage_resource.py b/watcher/decision_engine/model/element/storage_resource.py index 6ea67cb70..0aab340b7 100644 --- a/watcher/decision_engine/model/element/storage_resource.py +++ b/watcher/decision_engine/model/element/storage_resource.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2017 NEC Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/model/element/volume.py b/watcher/decision_engine/model/element/volume.py index c3e08f45a..00f6ecc66 100644 --- a/watcher/decision_engine/model/element/volume.py +++ b/watcher/decision_engine/model/element/volume.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2017 NEC Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/model/model_root.py b/watcher/decision_engine/model/model_root.py index 4a7b740e5..18ef7ac53 100644 --- a/watcher/decision_engine/model/model_root.py +++ b/watcher/decision_engine/model/model_root.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Innovation and Research Ireland Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -37,7 +36,7 @@ class ModelRoot(nx.DiGraph, base.Model): """Cluster graph for an Openstack cluster.""" def __init__(self, stale=False): - super(ModelRoot, self).__init__() + super().__init__() self.stale = stale self._extended_attributes_enabled = None @@ -72,13 +71,13 @@ class ModelRoot(nx.DiGraph, base.Model): @lockutils.synchronized("model_root") def add_node(self, node): self.assert_node(node) - super(ModelRoot, self).add_node(node.uuid, attr=node) + super().add_node(node.uuid, attr=node) @lockutils.synchronized("model_root") def remove_node(self, node): self.assert_node(node) try: - super(ModelRoot, self).remove_node(node.uuid) + super().remove_node(node.uuid) except nx.NetworkXError as exc: LOG.exception(exc) raise exception.ComputeNodeNotFound(name=node.uuid) @@ -87,7 +86,7 @@ class ModelRoot(nx.DiGraph, base.Model): def add_instance(self, instance): self.assert_instance(instance) try: - super(ModelRoot, self).add_node(instance.uuid, attr=instance) + super().add_node(instance.uuid, attr=instance) except nx.NetworkXError as exc: LOG.exception(exc) raise exception.InstanceNotFound(name=instance.uuid) @@ -95,7 +94,7 @@ class ModelRoot(nx.DiGraph, base.Model): @lockutils.synchronized("model_root") def remove_instance(self, instance): self.assert_instance(instance) - super(ModelRoot, self).remove_node(instance.uuid) + super().remove_node(instance.uuid) @lockutils.synchronized("model_root") def map_instance(self, instance, node): @@ -320,7 +319,7 @@ class StorageModelRoot(nx.DiGraph, base.Model): """Cluster graph for an Openstack cluster.""" def __init__(self, stale=False): - super(StorageModelRoot, self).__init__() + super().__init__() self.stale = stale def __nonzero__(self): @@ -349,18 +348,18 @@ class StorageModelRoot(nx.DiGraph, base.Model): @lockutils.synchronized("storage_model") def add_node(self, node): self.assert_node(node) - super(StorageModelRoot, self).add_node(node.host, attr=node) + super().add_node(node.host, attr=node) @lockutils.synchronized("storage_model") def add_pool(self, pool): self.assert_pool(pool) - super(StorageModelRoot, self).add_node(pool.name, attr=pool) + super().add_node(pool.name, attr=pool) @lockutils.synchronized("storage_model") def remove_node(self, node): self.assert_node(node) try: - super(StorageModelRoot, self).remove_node(node.host) + super().remove_node(node.host) except nx.NetworkXError as exc: LOG.exception(exc) raise exception.StorageNodeNotFound(name=node.host) @@ -369,7 +368,7 @@ class StorageModelRoot(nx.DiGraph, base.Model): def remove_pool(self, pool): self.assert_pool(pool) try: - super(StorageModelRoot, self).remove_node(pool.name) + super().remove_node(pool.name) except nx.NetworkXError as exc: LOG.exception(exc) raise exception.PoolNotFound(name=pool.name) @@ -407,13 +406,13 @@ class StorageModelRoot(nx.DiGraph, base.Model): @lockutils.synchronized("storage_model") def add_volume(self, volume): self.assert_volume(volume) - super(StorageModelRoot, self).add_node(volume.uuid, attr=volume) + super().add_node(volume.uuid, attr=volume) @lockutils.synchronized("storage_model") def remove_volume(self, volume): self.assert_volume(volume) try: - super(StorageModelRoot, self).remove_node(volume.uuid) + super().remove_node(volume.uuid) except nx.NetworkXError as exc: LOG.exception(exc) raise exception.VolumeNotFound(name=volume.uuid) @@ -620,7 +619,7 @@ class BaremetalModelRoot(nx.DiGraph, base.Model): """Cluster graph for an Openstack cluster: Baremetal Cluster.""" def __init__(self, stale=False): - super(BaremetalModelRoot, self).__init__() + super().__init__() self.stale = stale def __nonzero__(self): @@ -637,13 +636,13 @@ class BaremetalModelRoot(nx.DiGraph, base.Model): @lockutils.synchronized("baremetal_model") def add_node(self, node): self.assert_node(node) - super(BaremetalModelRoot, self).add_node(node.uuid, attr=node) + super().add_node(node.uuid, attr=node) @lockutils.synchronized("baremetal_model") def remove_node(self, node): self.assert_node(node) try: - super(BaremetalModelRoot, self).remove_node(node.uuid) + super().remove_node(node.uuid) except nx.NetworkXError as exc: LOG.exception(exc) raise exception.IronicNodeNotFound(uuid=node.uuid) diff --git a/watcher/decision_engine/model/notification/base.py b/watcher/decision_engine/model/notification/base.py index e7fc29e25..321d9ad39 100644 --- a/watcher/decision_engine/model/notification/base.py +++ b/watcher/decision_engine/model/notification/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -19,10 +18,10 @@ import abc -class NotificationEndpoint(object, metaclass=abc.ABCMeta): +class NotificationEndpoint(metaclass=abc.ABCMeta): def __init__(self, collector): - super(NotificationEndpoint, self).__init__() + super().__init__() self.collector = collector self._notifier = None diff --git a/watcher/decision_engine/model/notification/cinder.py b/watcher/decision_engine/model/notification/cinder.py index 4a248506c..475835ca3 100644 --- a/watcher/decision_engine/model/notification/cinder.py +++ b/watcher/decision_engine/model/notification/cinder.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2017 NEC Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +26,7 @@ LOG = log.getLogger(__name__) class CinderNotification(base.NotificationEndpoint): def __init__(self, collector): - super(CinderNotification, self).__init__(collector) + super().__init__(collector) self._cinder = None @property diff --git a/watcher/decision_engine/model/notification/filtering.py b/watcher/decision_engine/model/notification/filtering.py index 181fbb144..41f11b7c9 100644 --- a/watcher/decision_engine/model/notification/filtering.py +++ b/watcher/decision_engine/model/notification/filtering.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/decision_engine/model/notification/nova.py b/watcher/decision_engine/model/notification/nova.py index 7a11645bd..f5a219154 100644 --- a/watcher/decision_engine/model/notification/nova.py +++ b/watcher/decision_engine/model/notification/nova.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -34,7 +33,7 @@ LOG = log.getLogger(__name__) class NovaNotification(base.NotificationEndpoint): def __init__(self, collector): - super(NovaNotification, self).__init__(collector) + super().__init__(collector) self._nova = None self._placement_helper = None diff --git a/watcher/decision_engine/planner/base.py b/watcher/decision_engine/planner/base.py index 7e8a132d1..bd85e34f2 100644 --- a/watcher/decision_engine/planner/base.py +++ b/watcher/decision_engine/planner/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS diff --git a/watcher/decision_engine/planner/manager.py b/watcher/decision_engine/planner/manager.py index 921be0d3e..807d62a48 100644 --- a/watcher/decision_engine/planner/manager.py +++ b/watcher/decision_engine/planner/manager.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -22,7 +21,7 @@ from watcher.decision_engine.loading import default as loader LOG = log.getLogger(__name__) -class PlannerManager(object): +class PlannerManager: def __init__(self): self._loader = loader.DefaultPlannerLoader() diff --git a/watcher/decision_engine/planner/node_resource_consolidation.py b/watcher/decision_engine/planner/node_resource_consolidation.py index 9f0602975..3e15218e0 100644 --- a/watcher/decision_engine/planner/node_resource_consolidation.py +++ b/watcher/decision_engine/planner/node_resource_consolidation.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/watcher/decision_engine/planner/weight.py b/watcher/decision_engine/planner/weight.py index 531b43785..b111a98b6 100644 --- a/watcher/decision_engine/planner/weight.py +++ b/watcher/decision_engine/planner/weight.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Authors: Vincent Francoise # Alexander Chadin @@ -43,7 +42,7 @@ class WeightPlanner(base.BasePlanner): """ def __init__(self, config): - super(WeightPlanner, self).__init__(config) + super().__init__(config) action_weights = { 'nop': 70, diff --git a/watcher/decision_engine/planner/workload_stabilization.py b/watcher/decision_engine/planner/workload_stabilization.py index 9b9d0d38b..7b7c97bde 100644 --- a/watcher/decision_engine/planner/workload_stabilization.py +++ b/watcher/decision_engine/planner/workload_stabilization.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -45,7 +44,7 @@ class WorkloadStabilizationPlanner(base.BasePlanner): """ def __init__(self, config): - super(WorkloadStabilizationPlanner, self).__init__(config) + super().__init__(config) self._osc = clients.OpenStackClients() @property @@ -218,11 +217,11 @@ class WorkloadStabilizationPlanner(base.BasePlanner): raise -class BaseActionValidator(object): +class BaseActionValidator: action_name = None def __init__(self): - super(BaseActionValidator, self).__init__() + super().__init__() self._osc = None @property diff --git a/watcher/decision_engine/rpcapi.py b/watcher/decision_engine/rpcapi.py index bbeef938f..6c14e80ef 100644 --- a/watcher/decision_engine/rpcapi.py +++ b/watcher/decision_engine/rpcapi.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # Copyright (c) 2016 Intel Corp # @@ -31,7 +30,7 @@ CONF = conf.CONF class DecisionEngineAPI(service.Service): def __init__(self): - super(DecisionEngineAPI, self).__init__(DecisionEngineAPIManager) + super().__init__(DecisionEngineAPIManager) def trigger_audit(self, context, audit_uuid=None): if not utils.is_uuid_like(audit_uuid): diff --git a/watcher/decision_engine/scheduling.py b/watcher/decision_engine/scheduling.py index 141c1ea40..f36f22df8 100644 --- a/watcher/decision_engine/scheduling.py +++ b/watcher/decision_engine/scheduling.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -36,7 +35,7 @@ class DecisionEngineSchedulingService(scheduling.BackgroundSchedulerService): def __init__(self, gconfig=None, **options): gconfig = None or {} - super(DecisionEngineSchedulingService, self).__init__( + super().__init__( gconfig, **options) self.collector_manager = manager.CollectorManager() @@ -113,7 +112,7 @@ class DecisionEngineSchedulingService(scheduling.BackgroundSchedulerService): self.add_sync_jobs() self.add_checkstate_job() self.cancel_ongoing_audits() - super(DecisionEngineSchedulingService, self).start() + super().start() def stop(self): """Stop service.""" diff --git a/watcher/decision_engine/scope/baremetal.py b/watcher/decision_engine/scope/baremetal.py index 5d8af161f..d0584e8ef 100644 --- a/watcher/decision_engine/scope/baremetal.py +++ b/watcher/decision_engine/scope/baremetal.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2018 ZTE Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +20,7 @@ class BaremetalScope(base.BaseScope): """Baremetal Audit Scope Handler""" def __init__(self, scope, config, osc=None): - super(BaremetalScope, self).__init__(scope, config) + super().__init__(scope, config) self._osc = osc def exclude_resources(self, resources, **kwargs): diff --git a/watcher/decision_engine/scope/base.py b/watcher/decision_engine/scope/base.py index 34aaff824..89fe1813b 100644 --- a/watcher/decision_engine/scope/base.py +++ b/watcher/decision_engine/scope/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -20,7 +19,7 @@ import abc from watcher.common import context -class BaseScope(object, metaclass=abc.ABCMeta): +class BaseScope(metaclass=abc.ABCMeta): """A base class for Scope mechanism Child of this class is called when audit launches strategy. This strategy diff --git a/watcher/decision_engine/scope/compute.py b/watcher/decision_engine/scope/compute.py index e60661e19..ae6785717 100644 --- a/watcher/decision_engine/scope/compute.py +++ b/watcher/decision_engine/scope/compute.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +27,7 @@ class ComputeScope(base.BaseScope): """Compute Audit Scope Handler""" def __init__(self, scope, config, osc=None): - super(ComputeScope, self).__init__(scope, config) + super().__init__(scope, config) self._osc = osc self.wrapper = nova_helper.NovaHelper(osc=self._osc) diff --git a/watcher/decision_engine/scope/storage.py b/watcher/decision_engine/scope/storage.py index 7f9eb56b2..de8a8408e 100644 --- a/watcher/decision_engine/scope/storage.py +++ b/watcher/decision_engine/scope/storage.py @@ -21,7 +21,7 @@ class StorageScope(base.BaseScope): """Storage Audit Scope Handler""" def __init__(self, scope, config, osc=None): - super(StorageScope, self).__init__(scope, config) + super().__init__(scope, config) self._osc = osc self.wrapper = cinder_helper.CinderHelper(osc=self._osc) diff --git a/watcher/decision_engine/scoring/base.py b/watcher/decision_engine/scoring/base.py index 0c1e27745..9e0846ccd 100644 --- a/watcher/decision_engine/scoring/base.py +++ b/watcher/decision_engine/scoring/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel # # Authors: Tomasz Kaczynski diff --git a/watcher/decision_engine/scoring/dummy_scorer.py b/watcher/decision_engine/scoring/dummy_scorer.py index 735dbac65..26e122f44 100644 --- a/watcher/decision_engine/scoring/dummy_scorer.py +++ b/watcher/decision_engine/scoring/dummy_scorer.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel # # Authors: Tomasz Kaczynski diff --git a/watcher/decision_engine/scoring/dummy_scoring_container.py b/watcher/decision_engine/scoring/dummy_scoring_container.py index daf44f5ec..04e5331b5 100644 --- a/watcher/decision_engine/scoring/dummy_scoring_container.py +++ b/watcher/decision_engine/scoring/dummy_scoring_container.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel # # Authors: Tomasz Kaczynski @@ -64,7 +63,7 @@ class SimpleFunctionScorer(base.ScoringEngine): """ def __init__(self, name, description, aggregate_function): - super(SimpleFunctionScorer, self).__init__(config=None) + super().__init__(config=None) self._name = name self._description = description self._aggregate_function = aggregate_function diff --git a/watcher/decision_engine/scoring/scoring_factory.py b/watcher/decision_engine/scoring/scoring_factory.py index 6da59c5a1..5011e0a30 100644 --- a/watcher/decision_engine/scoring/scoring_factory.py +++ b/watcher/decision_engine/scoring/scoring_factory.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel # # Authors: Tomasz Kaczynski diff --git a/watcher/decision_engine/solution/base.py b/watcher/decision_engine/solution/base.py index af07f6a5b..fe44f10bc 100644 --- a/watcher/decision_engine/solution/base.py +++ b/watcher/decision_engine/solution/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -60,7 +59,7 @@ import abc from watcher.decision_engine.solution import efficacy -class BaseSolution(object, metaclass=abc.ABCMeta): +class BaseSolution(metaclass=abc.ABCMeta): def __init__(self, goal, strategy): """Base Solution constructor diff --git a/watcher/decision_engine/solution/default.py b/watcher/decision_engine/solution/default.py index be895df27..f5a6ff5e7 100644 --- a/watcher/decision_engine/solution/default.py +++ b/watcher/decision_engine/solution/default.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -37,7 +36,7 @@ class DefaultSolution(base.BaseSolution): :param strategy: Strategy associated to this solution :type strategy: :py:class:`~.BaseStrategy` instance """ - super(DefaultSolution, self).__init__(goal, strategy) + super().__init__(goal, strategy) self._actions = [] def add_action(self, action_type, input_parameters=None, resource_id=None): diff --git a/watcher/decision_engine/solution/efficacy.py b/watcher/decision_engine/solution/efficacy.py index a0813d8d5..14a7d6c43 100644 --- a/watcher/decision_engine/solution/efficacy.py +++ b/watcher/decision_engine/solution/efficacy.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +31,7 @@ class IndicatorsMap(utils.Struct): class Indicator(utils.Struct): def __init__(self, name, description, unit, value): - super(Indicator, self).__init__() + super().__init__() self.name = name self.description = description self.unit = unit @@ -42,7 +41,7 @@ class Indicator(utils.Struct): self.value = value -class Efficacy(object): +class Efficacy: """Solution efficacy""" def __init__(self, goal, strategy): diff --git a/watcher/decision_engine/solution/solution_comparator.py b/watcher/decision_engine/solution/solution_comparator.py index 768ea80b9..9a7361e1e 100644 --- a/watcher/decision_engine/solution/solution_comparator.py +++ b/watcher/decision_engine/solution/solution_comparator.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -19,7 +18,7 @@ import abc -class BaseSolutionComparator(object, metaclass=abc.ABCMeta): +class BaseSolutionComparator(metaclass=abc.ABCMeta): @abc.abstractmethod def compare(self, sol1, sol2): raise NotImplementedError() diff --git a/watcher/decision_engine/solution/solution_evaluator.py b/watcher/decision_engine/solution/solution_evaluator.py index aad340e88..05f1fbff1 100644 --- a/watcher/decision_engine/solution/solution_evaluator.py +++ b/watcher/decision_engine/solution/solution_evaluator.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -19,7 +18,7 @@ import abc -class BaseSolutionEvaluator(object, metaclass=abc.ABCMeta): +class BaseSolutionEvaluator(metaclass=abc.ABCMeta): @abc.abstractmethod def evaluate(self, solution): raise NotImplementedError() diff --git a/watcher/decision_engine/strategy/common/level.py b/watcher/decision_engine/strategy/common/level.py index 83d95c0de..c4a7544e0 100644 --- a/watcher/decision_engine/strategy/common/level.py +++ b/watcher/decision_engine/strategy/common/level.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS diff --git a/watcher/decision_engine/strategy/context/base.py b/watcher/decision_engine/strategy/context/base.py index 1e59871c8..ff02ee972 100644 --- a/watcher/decision_engine/strategy/context/base.py +++ b/watcher/decision_engine/strategy/context/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -23,7 +22,7 @@ from watcher import notifications from watcher.objects import fields -class StrategyContext(object, metaclass=abc.ABCMeta): +class StrategyContext(metaclass=abc.ABCMeta): def execute_strategy(self, audit, request_context): """Execute the strategy for the given an audit diff --git a/watcher/decision_engine/strategy/context/default.py b/watcher/decision_engine/strategy/context/default.py index f0536938b..b9fc989ba 100644 --- a/watcher/decision_engine/strategy/context/default.py +++ b/watcher/decision_engine/strategy/context/default.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +26,7 @@ LOG = log.getLogger(__name__) class DefaultStrategyContext(base.StrategyContext): def __init__(self): - super(DefaultStrategyContext, self).__init__() + super().__init__() LOG.debug("Initializing Strategy Context") @staticmethod diff --git a/watcher/decision_engine/strategy/selection/base.py b/watcher/decision_engine/strategy/selection/base.py index d21e36d63..4263f677d 100644 --- a/watcher/decision_engine/strategy/selection/base.py +++ b/watcher/decision_engine/strategy/selection/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -19,7 +18,7 @@ import abc -class BaseSelector(object, metaclass=abc.ABCMeta): +class BaseSelector(metaclass=abc.ABCMeta): @abc.abstractmethod def select(self): diff --git a/watcher/decision_engine/strategy/selection/default.py b/watcher/decision_engine/strategy/selection/default.py index ea8b91049..6bf1708e7 100644 --- a/watcher/decision_engine/strategy/selection/default.py +++ b/watcher/decision_engine/strategy/selection/default.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,7 +32,7 @@ class DefaultStrategySelector(base.BaseSelector): :param strategy_name: Name of the strategy :param osc: an OpenStackClients instance """ - super(DefaultStrategySelector, self).__init__() + super().__init__() self.goal_name = goal_name self.strategy_name = strategy_name self.osc = osc diff --git a/watcher/decision_engine/strategy/strategies/__init__.py b/watcher/decision_engine/strategy/strategies/__init__.py index c3287dd9c..cd249ab9b 100644 --- a/watcher/decision_engine/strategy/strategies/__init__.py +++ b/watcher/decision_engine/strategy/strategies/__init__.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/strategy/strategies/actuation.py b/watcher/decision_engine/strategy/strategies/actuation.py index 8501dd8b7..0e441384b 100644 --- a/watcher/decision_engine/strategy/strategies/actuation.py +++ b/watcher/decision_engine/strategy/strategies/actuation.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/decision_engine/strategy/strategies/base.py b/watcher/decision_engine/strategy/strategies/base.py index 6f1200eb3..de4583769 100644 --- a/watcher/decision_engine/strategy/strategies/base.py +++ b/watcher/decision_engine/strategy/strategies/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -57,7 +56,7 @@ LOG = log.getLogger(__name__) CONF = cfg.CONF -class StrategyEndpoint(object): +class StrategyEndpoint: def __init__(self, messaging): self._messaging = messaging @@ -141,7 +140,7 @@ class BaseStrategy(loadable.Loadable, metaclass=abc.ABCMeta): :param osc: An OpenStackClients instance :type osc: :py:class:`~.OpenStackClients` instance """ - super(BaseStrategy, self).__init__(config) + super().__init__(config) self.ctx = context.make_context() self._name = self.get_name() self._display_name = self.get_display_name() @@ -208,7 +207,7 @@ class BaseStrategy(loadable.Loadable, metaclass=abc.ABCMeta): "datasources", help="Datasources to use in order to query the needed metrics." " This option overrides the global preference." - " options: {0}".format(datasources_ops), + " options: {}".format(datasources_ops), item_type=cfg.types.String(choices=datasources_ops), default=None) ] @@ -512,8 +511,7 @@ class ThermalOptimizationBaseStrategy(BaseStrategy, metaclass=abc.ABCMeta): class WorkloadStabilizationBaseStrategy(BaseStrategy, metaclass=abc.ABCMeta): def __init__(self, *args, **kwargs): - super(WorkloadStabilizationBaseStrategy, self - ).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self._planner = 'workload_stabilization' @classmethod diff --git a/watcher/decision_engine/strategy/strategies/basic_consolidation.py b/watcher/decision_engine/strategy/strategies/basic_consolidation.py index 5b621cd31..8cc07a2b1 100644 --- a/watcher/decision_engine/strategy/strategies/basic_consolidation.py +++ b/watcher/decision_engine/strategy/strategies/basic_consolidation.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -59,7 +58,7 @@ class BasicConsolidation(base.ServerConsolidationBaseStrategy): :type config: :py:class:`~.Struct` instance :param osc: :py:class:`~.OpenStackClients` instance """ - super(BasicConsolidation, self).__init__(config, osc) + super().__init__(config, osc) # set default value for the number of enabled compute nodes self.number_of_enabled_nodes = 0 @@ -170,7 +169,7 @@ class BasicConsolidation(base.ServerConsolidationBaseStrategy): @classmethod def get_config_opts(cls): - return super(BasicConsolidation, cls).get_config_opts() + [ + return super().get_config_opts() + [ cfg.BoolOpt( 'check_optimize_metadata', help='Check optimize metadata field in instance before' diff --git a/watcher/decision_engine/strategy/strategies/dummy_strategy.py b/watcher/decision_engine/strategy/strategies/dummy_strategy.py index 9b1a9d73f..e49b47bdf 100644 --- a/watcher/decision_engine/strategy/strategies/dummy_strategy.py +++ b/watcher/decision_engine/strategy/strategies/dummy_strategy.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS diff --git a/watcher/decision_engine/strategy/strategies/dummy_with_resize.py b/watcher/decision_engine/strategy/strategies/dummy_with_resize.py index 1a10d5c5b..14c011355 100644 --- a/watcher/decision_engine/strategy/strategies/dummy_with_resize.py +++ b/watcher/decision_engine/strategy/strategies/dummy_with_resize.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/watcher/decision_engine/strategy/strategies/dummy_with_scorer.py b/watcher/decision_engine/strategy/strategies/dummy_with_scorer.py index 728229445..79357dc49 100644 --- a/watcher/decision_engine/strategy/strategies/dummy_with_scorer.py +++ b/watcher/decision_engine/strategy/strategies/dummy_with_scorer.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel # # Authors: Tomasz Kaczynski @@ -61,7 +60,7 @@ class DummyWithScorer(base.DummyBaseStrategy): :type osc: :py:class:`~.OpenStackClients` instance """ - super(DummyWithScorer, self).__init__(config, osc) + super().__init__(config, osc) # Setup Scoring Engines self._workload_scorer = (scoring_factory diff --git a/watcher/decision_engine/strategy/strategies/host_maintenance.py b/watcher/decision_engine/strategy/strategies/host_maintenance.py index 9c5926468..9e13a061f 100644 --- a/watcher/decision_engine/strategy/strategies/host_maintenance.py +++ b/watcher/decision_engine/strategy/strategies/host_maintenance.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 chinac.com # # Authors: suzhengwei @@ -61,7 +60,7 @@ class HostMaintenance(base.HostMaintenanceBaseStrategy): INSTANCE_STOP = "stop" def __init__(self, config, osc=None): - super(HostMaintenance, self).__init__(config, osc) + super().__init__(config, osc) @classmethod def get_name(cls): diff --git a/watcher/decision_engine/strategy/strategies/node_resource_consolidation.py b/watcher/decision_engine/strategy/strategies/node_resource_consolidation.py index b002bcfc4..fcc1a57ba 100644 --- a/watcher/decision_engine/strategy/strategies/node_resource_consolidation.py +++ b/watcher/decision_engine/strategy/strategies/node_resource_consolidation.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 ZTE Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -61,7 +60,7 @@ class NodeResourceConsolidation(base.ServerConsolidationBaseStrategy): :type config: :py:class:`~.Struct` instance :param osc: :py:class:`~.OpenStackClients` instance """ - super(NodeResourceConsolidation, self).__init__(config, osc) + super().__init__(config, osc) self.host_choice = 'auto' self.audit = None self.compute_nodes_count = 0 diff --git a/watcher/decision_engine/strategy/strategies/noisy_neighbor.py b/watcher/decision_engine/strategy/strategies/noisy_neighbor.py index 5f2fd8bfe..3396d7178 100644 --- a/watcher/decision_engine/strategy/strategies/noisy_neighbor.py +++ b/watcher/decision_engine/strategy/strategies/noisy_neighbor.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Intel Corp # # Authors: Prudhvi Rao Shedimbi @@ -62,7 +61,7 @@ class NoisyNeighbor(base.NoisyNeighborBaseStrategy): DEFAULT_WATCHER_PRIORITY = 5 def __init__(self, config, osc=None): - super(NoisyNeighbor, self).__init__(config, osc) + super().__init__(config, osc) self.meter_name = 'instance_l3_cache_usage' diff --git a/watcher/decision_engine/strategy/strategies/outlet_temp_control.py b/watcher/decision_engine/strategy/strategies/outlet_temp_control.py index f8959a8ea..e64cfdb16 100644 --- a/watcher/decision_engine/strategy/strategies/outlet_temp_control.py +++ b/watcher/decision_engine/strategy/strategies/outlet_temp_control.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 Intel Corp # # Authors: Junjie-Huang @@ -86,7 +85,7 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy): :param osc: an OpenStackClients object, defaults to None :type osc: :py:class:`~.OpenStackClients` instance, optional """ - super(OutletTempControl, self).__init__(config, osc) + super().__init__(config, osc) @classmethod def get_name(cls): diff --git a/watcher/decision_engine/strategy/strategies/saving_energy.py b/watcher/decision_engine/strategy/strategies/saving_energy.py index 6c706b06d..294442a20 100644 --- a/watcher/decision_engine/strategy/strategies/saving_energy.py +++ b/watcher/decision_engine/strategy/strategies/saving_energy.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE Corporation # # Authors: licanwei @@ -82,7 +81,7 @@ class SavingEnergy(base.SavingEnergyBaseStrategy): def __init__(self, config, osc=None): - super(SavingEnergy, self).__init__(config, osc) + super().__init__(config, osc) self._metal_helper = None self._nova_client = None diff --git a/watcher/decision_engine/strategy/strategies/storage_capacity_balance.py b/watcher/decision_engine/strategy/strategies/storage_capacity_balance.py index 7fdf753d0..9c60f63c0 100644 --- a/watcher/decision_engine/strategy/strategies/storage_capacity_balance.py +++ b/watcher/decision_engine/strategy/strategies/storage_capacity_balance.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -59,7 +58,7 @@ class StorageCapacityBalance(base.WorkloadStabilizationBaseStrategy): :type config: :py:class:`~.Struct` instance :param osc: :py:class:`~.OpenStackClients` instance """ - super(StorageCapacityBalance, self).__init__(config, osc) + super().__init__(config, osc) self._cinder = None self.volume_threshold = 80.0 self.pool_type_cache = dict() @@ -99,7 +98,7 @@ class StorageCapacityBalance(base.WorkloadStabilizationBaseStrategy): @classmethod def get_config_opts(cls): - return super(StorageCapacityBalance, cls).get_config_opts() + [ + return super().get_config_opts() + [ cfg.ListOpt( "ex_pools", help="exclude pools", diff --git a/watcher/decision_engine/strategy/strategies/uniform_airflow.py b/watcher/decision_engine/strategy/strategies/uniform_airflow.py index abe9691f4..29d2a8eeb 100644 --- a/watcher/decision_engine/strategy/strategies/uniform_airflow.py +++ b/watcher/decision_engine/strategy/strategies/uniform_airflow.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Junjie-Huang @@ -64,7 +63,7 @@ class UniformAirflow(base.BaseStrategy): :type config: dict :param osc: an OpenStackClients object """ - super(UniformAirflow, self).__init__(config, osc) + super().__init__(config, osc) # The migration plan will be triggered when the airflow reaches # threshold self._period = self.PERIOD diff --git a/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py b/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py index 07fbc06e9..e0aaa799a 100644 --- a/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py +++ b/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Authors: Vojtech CIMA # Bruno GRAZIOLI @@ -77,7 +76,7 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): CHANGE_NOVA_SERVICE_STATE = "change_nova_service_state" def __init__(self, config, osc=None): - super(VMWorkloadConsolidation, self).__init__(config, osc) + super().__init__(config, osc) self.number_of_migrations = 0 self.number_of_released_nodes = 0 self.datasource_instance_data_cache = dict() diff --git a/watcher/decision_engine/strategy/strategies/workload_balance.py b/watcher/decision_engine/strategy/strategies/workload_balance.py index dbeb0427f..bab2575f6 100644 --- a/watcher/decision_engine/strategy/strategies/workload_balance.py +++ b/watcher/decision_engine/strategy/strategies/workload_balance.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Junjie-Huang @@ -72,7 +71,7 @@ class WorkloadBalance(base.WorkloadStabilizationBaseStrategy): :type config: :py:class:`~.Struct` instance :param osc: :py:class:`~.OpenStackClients` instance """ - super(WorkloadBalance, self).__init__(config, osc) + super().__init__(config, osc) # the migration plan will be triggered when the CPU or RAM # utilization % reaches threshold self._meter = None diff --git a/watcher/decision_engine/strategy/strategies/workload_stabilization.py b/watcher/decision_engine/strategy/strategies/workload_stabilization.py index 4913ecb62..9c12fc103 100644 --- a/watcher/decision_engine/strategy/strategies/workload_stabilization.py +++ b/watcher/decision_engine/strategy/strategies/workload_stabilization.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica LLC # # Authors: Alexander Chadin @@ -79,7 +78,7 @@ class WorkloadStabilization(base.WorkloadStabilizationBaseStrategy): :type config: :py:class:`~.Struct` instance :param osc: :py:class:`~.OpenStackClients` instance """ - super(WorkloadStabilization, self).__init__(config, osc) + super().__init__(config, osc) self.weights = None self.metrics = None self.thresholds = None diff --git a/watcher/decision_engine/strategy/strategies/zone_migration.py b/watcher/decision_engine/strategy/strategies/zone_migration.py index e5182d5c8..77ff00765 100644 --- a/watcher/decision_engine/strategy/strategies/zone_migration.py +++ b/watcher/decision_engine/strategy/strategies/zone_migration.py @@ -46,7 +46,7 @@ class ZoneMigration(base.ZoneMigrationBaseStrategy): def __init__(self, config, osc=None): - super(ZoneMigration, self).__init__(config, osc) + super().__init__(config, osc) self._nova = None self._cinder = None @@ -630,7 +630,7 @@ class ZoneMigration(base.ZoneMigrationBaseStrategy): } -class ActionCounter(object): +class ActionCounter: """Manage the number of actions in parallel""" def __init__(self, total_limit=6, per_pool_limit=2, per_node_limit=2): @@ -710,7 +710,7 @@ class ActionCounter(object): return self.per_node_count[node] >= self.per_node_limit -class BaseFilter(object): +class BaseFilter: """Base class for Filter""" apply_targets = ('ALL',) @@ -782,7 +782,7 @@ class ProjectSortFilter(SortMovingToFrontFilter): apply_targets = ('instance', 'volume') def __init__(self, values=[], **kwargs): - super(ProjectSortFilter, self).__init__(values, **kwargs) + super().__init__(values, **kwargs) def compare_func(self, item, sort_key): """Compare project id of item with sort_key @@ -816,7 +816,7 @@ class ComputeHostSortFilter(SortMovingToFrontFilter): apply_targets = ('instance',) def __init__(self, values=[], **kwargs): - super(ComputeHostSortFilter, self).__init__(values, **kwargs) + super().__init__(values, **kwargs) def compare_func(self, item, sort_key): """Compare compute name of item with sort_key @@ -870,7 +870,7 @@ class ComputeSpecSortFilter(BaseFilter): accept_keys = ['vcpu_num', 'mem_size', 'disk_size', 'created_at'] def __init__(self, values=[], **kwargs): - super(ComputeSpecSortFilter, self).__init__(values, **kwargs) + super().__init__(values, **kwargs) self._nova = None @property diff --git a/watcher/decision_engine/sync.py b/watcher/decision_engine/sync.py index fd6025d80..443ed8a19 100644 --- a/watcher/decision_engine/sync.py +++ b/watcher/decision_engine/sync.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,7 +38,7 @@ IndicatorSpec = collections.namedtuple( 'IndicatorSpec', ['name', 'description', 'unit', 'schema']) -class Syncer(object): +class Syncer: """Syncs all available goals and strategies with the Watcher DB""" def __init__(self): diff --git a/watcher/decision_engine/threading.py b/watcher/decision_engine/threading.py index c9c85017c..8b59f6670 100644 --- a/watcher/decision_engine/threading.py +++ b/watcher/decision_engine/threading.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken @@ -29,7 +28,7 @@ CONF = cfg.CONF LOG = log.getLogger(__name__) -class DecisionEngineThreadPool(object, metaclass=service.Singleton): +class DecisionEngineThreadPool(metaclass=service.Singleton): """Singleton threadpool to submit general tasks to""" def __init__(self): diff --git a/watcher/hacking/checks.py b/watcher/hacking/checks.py index 0ae625a8b..4332937f3 100644 --- a/watcher/hacking/checks.py +++ b/watcher/hacking/checks.py @@ -54,7 +54,7 @@ _all_hints = set(_all_log_levels.values()) def _regex_for_level(level, hint): return r".*LOG\.%(level)s\(\s*((%(wrong_hints)s)\(|'|\")" % { 'level': level, - 'wrong_hints': '|'.join(_all_hints - set([hint])), + 'wrong_hints': '|'.join(_all_hints - {hint}), } diff --git a/watcher/notifications/__init__.py b/watcher/notifications/__init__.py index cfed437bc..97f34c37c 100644 --- a/watcher/notifications/__init__.py +++ b/watcher/notifications/__init__.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/notifications/action.py b/watcher/notifications/action.py index 9f79ffbfa..8b973ecaf 100644 --- a/watcher/notifications/action.py +++ b/watcher/notifications/action.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica # # Authors: Alexander Chadin @@ -67,7 +66,7 @@ class ActionPayload(notificationbase.NotificationPayloadBase): } def __init__(self, action, **kwargs): - super(ActionPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.populate_schema(action=action) @@ -92,7 +91,7 @@ class ActionCreatePayload(ActionPayload): fields = {} def __init__(self, action, action_plan): - super(ActionCreatePayload, self).__init__( + super().__init__( action=action, action_plan=action_plan) @@ -107,7 +106,7 @@ class ActionUpdatePayload(ActionPayload): } def __init__(self, action, state_update, action_plan): - super(ActionUpdatePayload, self).__init__( + super().__init__( action=action, state_update=state_update, action_plan=action_plan) @@ -123,7 +122,7 @@ class ActionExecutionPayload(ActionPayload): } def __init__(self, action, action_plan, **kwargs): - super(ActionExecutionPayload, self).__init__( + super().__init__( action=action, action_plan=action_plan, **kwargs) @@ -139,7 +138,7 @@ class ActionCancelPayload(ActionPayload): } def __init__(self, action, action_plan, **kwargs): - super(ActionCancelPayload, self).__init__( + super().__init__( action=action, action_plan=action_plan, **kwargs) @@ -153,7 +152,7 @@ class ActionDeletePayload(ActionPayload): fields = {} def __init__(self, action, action_plan): - super(ActionDeletePayload, self).__init__( + super().__init__( action=action, action_plan=action_plan) diff --git a/watcher/notifications/action_plan.py b/watcher/notifications/action_plan.py index 857bd0fdb..e3f1dedc7 100644 --- a/watcher/notifications/action_plan.py +++ b/watcher/notifications/action_plan.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 b<>com # # Authors: Vincent FRANCOISE @@ -64,9 +63,9 @@ class TerseActionPlanPayload(notificationbase.NotificationPayloadBase): } def __init__(self, action_plan, audit=None, strategy=None, **kwargs): - super(TerseActionPlanPayload, self).__init__(audit=audit, - strategy=strategy, - **kwargs) + super().__init__(audit=audit, + strategy=strategy, + **kwargs) self.populate_schema(action_plan=action_plan) @@ -101,7 +100,7 @@ class ActionPlanPayload(TerseActionPlanPayload): if strategy and not kwargs.get('strategy_uuid'): kwargs['strategy_uuid'] = strategy.uuid - super(ActionPlanPayload, self).__init__( + super().__init__( action_plan, audit=audit, strategy=strategy, **kwargs) @@ -127,7 +126,7 @@ class ActionPlanCreatePayload(ActionPlanPayload): fields = {} def __init__(self, action_plan, audit, strategy): - super(ActionPlanCreatePayload, self).__init__( + super().__init__( action_plan=action_plan, audit=audit, strategy=strategy) @@ -144,7 +143,7 @@ class ActionPlanUpdatePayload(ActionPlanPayload): } def __init__(self, action_plan, state_update, audit, strategy): - super(ActionPlanUpdatePayload, self).__init__( + super().__init__( action_plan=action_plan, state_update=state_update, audit=audit, @@ -162,7 +161,7 @@ class ActionPlanActionPayload(ActionPlanPayload): } def __init__(self, action_plan, audit, strategy, **kwargs): - super(ActionPlanActionPayload, self).__init__( + super().__init__( action_plan=action_plan, audit=audit, strategy=strategy, @@ -178,7 +177,7 @@ class ActionPlanDeletePayload(ActionPlanPayload): fields = {} def __init__(self, action_plan, audit, strategy): - super(ActionPlanDeletePayload, self).__init__( + super().__init__( action_plan=action_plan, audit=audit, strategy=strategy) @@ -195,7 +194,7 @@ class ActionPlanCancelPayload(ActionPlanPayload): } def __init__(self, action_plan, audit, strategy, **kwargs): - super(ActionPlanCancelPayload, self).__init__( + super().__init__( action_plan=action_plan, audit=audit, strategy=strategy, diff --git a/watcher/notifications/audit.py b/watcher/notifications/audit.py index eb45acc25..7adbde5ca 100644 --- a/watcher/notifications/audit.py +++ b/watcher/notifications/audit.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -78,7 +77,7 @@ class TerseAuditPayload(notificationbase.NotificationPayloadBase): } def __init__(self, audit, goal_uuid, strategy_uuid=None, **kwargs): - super(TerseAuditPayload, self).__init__( + super().__init__( goal_uuid=goal_uuid, strategy_uuid=strategy_uuid, **kwargs) self.populate_schema(audit=audit) @@ -122,7 +121,7 @@ class AuditPayload(TerseAuditPayload): if strategy and not kwargs.get('strategy_uuid'): kwargs['strategy_uuid'] = strategy.uuid - super(AuditPayload, self).__init__( + super().__init__( audit=audit, goal=goal, strategy=strategy, **kwargs) @@ -150,7 +149,7 @@ class AuditCreatePayload(AuditPayload): fields = {} def __init__(self, audit, goal, strategy): - super(AuditCreatePayload, self).__init__( + super().__init__( audit=audit, goal=goal, goal_uuid=goal.uuid, @@ -169,7 +168,7 @@ class AuditUpdatePayload(AuditPayload): } def __init__(self, audit, state_update, goal, strategy): - super(AuditUpdatePayload, self).__init__( + super().__init__( audit=audit, state_update=state_update, goal=goal, @@ -189,7 +188,7 @@ class AuditActionPayload(AuditPayload): } def __init__(self, audit, goal, strategy, **kwargs): - super(AuditActionPayload, self).__init__( + super().__init__( audit=audit, goal=goal, goal_uuid=goal.uuid, @@ -207,7 +206,7 @@ class AuditDeletePayload(AuditPayload): fields = {} def __init__(self, audit, goal, strategy): - super(AuditDeletePayload, self).__init__( + super().__init__( audit=audit, goal=goal, goal_uuid=goal.uuid, diff --git a/watcher/notifications/base.py b/watcher/notifications/base.py index d1c2d0ec0..cfc69e3db 100644 --- a/watcher/notifications/base.py +++ b/watcher/notifications/base.py @@ -41,7 +41,7 @@ class NotificationObject(base.WatcherObject): VERSION = '1.0' def __init__(self, **kwargs): - super(NotificationObject, self).__init__(**kwargs) + super().__init__(**kwargs) # The notification objects are created on the fly when watcher emits # the notification. This causes that every object shows every field as # changed. We don't want to send this meaningless information so we @@ -104,7 +104,7 @@ class NotificationPayloadBase(NotificationObject): VERSION = '1.0' def __init__(self, **kwargs): - super(NotificationPayloadBase, self).__init__(**kwargs) + super().__init__(**kwargs) self.populated = not self.SCHEMA def populate_schema(self, **kwargs): diff --git a/watcher/notifications/goal.py b/watcher/notifications/goal.py index 8c76bad54..415e9fe91 100644 --- a/watcher/notifications/goal.py +++ b/watcher/notifications/goal.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -49,5 +48,5 @@ class GoalPayload(notificationbase.NotificationPayloadBase): } def __init__(self, goal, **kwargs): - super(GoalPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.populate_schema(goal=goal) diff --git a/watcher/notifications/service.py b/watcher/notifications/service.py index 1d2ab8a8e..273c3dcd0 100644 --- a/watcher/notifications/service.py +++ b/watcher/notifications/service.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -40,7 +39,7 @@ class ServicePayload(notificationbase.NotificationPayloadBase): } def __init__(self, failed_service, status_update, **kwargs): - super(ServicePayload, self).__init__( + super().__init__( failed_service=failed_service, status_update=status_update, **kwargs) self.populate_schema(failed_service=failed_service) @@ -65,7 +64,7 @@ class ServiceUpdatePayload(ServicePayload): } def __init__(self, failed_service, status_update): - super(ServiceUpdatePayload, self).__init__( + super().__init__( failed_service=failed_service, status_update=status_update) diff --git a/watcher/notifications/strategy.py b/watcher/notifications/strategy.py index f7da10919..d850b88bb 100644 --- a/watcher/notifications/strategy.py +++ b/watcher/notifications/strategy.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -49,5 +48,5 @@ class StrategyPayload(notificationbase.NotificationPayloadBase): } def __init__(self, strategy, **kwargs): - super(StrategyPayload, self).__init__(**kwargs) + super().__init__(**kwargs) self.populate_schema(strategy=strategy) diff --git a/watcher/objects/action.py b/watcher/objects/action.py index a75b2792f..11e93431e 100644 --- a/watcher/objects/action.py +++ b/watcher/objects/action.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,7 +22,7 @@ from watcher.objects import base from watcher.objects import fields as wfields -class State(object): +class State: PENDING = 'PENDING' ONGOING = 'ONGOING' FAILED = 'FAILED' diff --git a/watcher/objects/action_description.py b/watcher/objects/action_description.py index 1d9e1937b..7aa5e28f0 100644 --- a/watcher/objects/action_description.py +++ b/watcher/objects/action_description.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/objects/action_plan.py b/watcher/objects/action_plan.py index 91eac9623..69b9502f5 100644 --- a/watcher/objects/action_plan.py +++ b/watcher/objects/action_plan.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -87,7 +86,7 @@ from watcher.objects import fields as wfields CONF = conf.CONF -class State(object): +class State: RECOMMENDED = 'RECOMMENDED' PENDING = 'PENDING' ONGOING = 'ONGOING' @@ -334,7 +333,7 @@ class ActionPlan(base.WatcherPersistentObject, base.WatcherObject, _notify() -class StateManager(object): +class StateManager: def check_expired(self, context): action_plan_expiry = ( CONF.watcher_decision_engine.action_plan_expiry) diff --git a/watcher/objects/audit.py b/watcher/objects/audit.py index 9b53baf32..59919fe29 100644 --- a/watcher/objects/audit.py +++ b/watcher/objects/audit.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -62,7 +61,7 @@ from watcher.objects import base from watcher.objects import fields as wfields -class State(object): +class State: ONGOING = 'ONGOING' SUCCEEDED = 'SUCCEEDED' FAILED = 'FAILED' @@ -129,7 +128,7 @@ class Audit(base.WatcherPersistentObject, base.WatcherObject, def __init__(self, *args, **kwargs): if 'force' not in kwargs: kwargs['force'] = False - super(Audit, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) # Proxified field so we can keep the previous value after an update _state = None @@ -343,7 +342,7 @@ class Audit(base.WatcherPersistentObject, base.WatcherObject, _notify() -class AuditStateTransitionManager(object): +class AuditStateTransitionManager: TRANSITIONS = { State.PENDING: [State.ONGOING, State.CANCELLED], diff --git a/watcher/objects/audit_template.py b/watcher/objects/audit_template.py index 11a0c2d25..424c57112 100644 --- a/watcher/objects/audit_template.py +++ b/watcher/objects/audit_template.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/objects/base.py b/watcher/objects/base.py index 8b9341814..f8e4ccfb6 100644 --- a/watcher/objects/base.py +++ b/watcher/objects/base.py @@ -96,7 +96,7 @@ class WatcherComparableObject(ovo_base.ComparableVersionedObject): pass -class WatcherPersistentObject(object): +class WatcherPersistentObject: """Mixin class for Persistent objects. This adds the fields that we use in common for all persistent objects. diff --git a/watcher/objects/efficacy_indicator.py b/watcher/objects/efficacy_indicator.py index 13027e1c7..4f9f3094a 100644 --- a/watcher/objects/efficacy_indicator.py +++ b/watcher/objects/efficacy_indicator.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/objects/fields.py b/watcher/objects/fields.py index abe7f1f0a..bd9787b34 100644 --- a/watcher/objects/fields.py +++ b/watcher/objects/fields.py @@ -80,7 +80,7 @@ class FlexibleDictField(fields.AutoTypedField): def _null(self, obj, attr): if self.nullable: return {} - super(FlexibleDictField, self)._null(obj, attr) + super()._null(obj, attr) class FlexibleListOfDict(fields.FieldType): @@ -100,7 +100,7 @@ class FlexibleListOfDictField(fields.AutoTypedField): def _null(self, obj, attr): if self.nullable: return [] - super(FlexibleListOfDictField, self)._null(obj, attr) + super()._null(obj, attr) class Json(fields.FieldType): @@ -128,7 +128,7 @@ class BaseWatcherEnum(Enum): ALL = () def __init__(self, **kwargs): - super(BaseWatcherEnum, self).__init__(valid_values=self.__class__.ALL) + super().__init__(valid_values=self.__class__.ALL) class NotificationPriority(BaseWatcherEnum): diff --git a/watcher/objects/goal.py b/watcher/objects/goal.py index e947ff635..3c102089b 100644 --- a/watcher/objects/goal.py +++ b/watcher/objects/goal.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2013 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/objects/scoring_engine.py b/watcher/objects/scoring_engine.py index 0c95e724b..14e865cac 100644 --- a/watcher/objects/scoring_engine.py +++ b/watcher/objects/scoring_engine.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2016 Intel # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/objects/service.py b/watcher/objects/service.py index 0b261b85e..6bf7311aa 100644 --- a/watcher/objects/service.py +++ b/watcher/objects/service.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +20,7 @@ from watcher.objects import base from watcher.objects import fields as wfields -class ServiceStatus(object): +class ServiceStatus: ACTIVE = 'ACTIVE' FAILED = 'FAILED' diff --git a/watcher/objects/strategy.py b/watcher/objects/strategy.py index 584c8ff23..09b1091fb 100644 --- a/watcher/objects/strategy.py +++ b/watcher/objects/strategy.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/api/base.py b/watcher/tests/api/base.py index 389b87d00..10f19d37f 100644 --- a/watcher/tests/api/base.py +++ b/watcher/tests/api/base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Copyright 2013 Hewlett-Packard Development Company, L.P. # All Rights Reserved. @@ -49,7 +48,7 @@ class FunctionalTest(base.DbTestCase): SOURCE_DATA = {'test_source': {'somekey': '666'}} def setUp(self): - super(FunctionalTest, self).setUp() + super().setUp() cfg.CONF.set_override("auth_version", "v2.0", group='keystone_authtoken') cfg.CONF.set_override("admin_user", "admin", @@ -255,7 +254,7 @@ class FunctionalTest(base.DbTestCase): class AdminRoleTest(base.DbTestCase): def setUp(self): - super(AdminRoleTest, self).setUp() + super().setUp() token_info = { 'token': { 'project': { diff --git a/watcher/tests/api/test_hooks.py b/watcher/tests/api/test_hooks.py index 6c81d87b0..6192a04e7 100644 --- a/watcher/tests/api/test_hooks.py +++ b/watcher/tests/api/test_hooks.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -25,7 +24,7 @@ from watcher.common import context from watcher.tests.api import base -class FakeRequest(object): +class FakeRequest: def __init__(self, headers, context, environ): self.headers = headers self.context = context @@ -34,7 +33,7 @@ class FakeRequest(object): self.host_url = 'http://127.0.0.1:6385' -class FakeRequestState(object): +class FakeRequestState: def __init__(self, headers=None, context=None, environ=None): self.request = FakeRequest(headers, context, environ) self.response = FakeRequest(headers, context, environ) @@ -111,7 +110,7 @@ class TestNoExceptionTracebackHook(base.FunctionalTest): MSG_WITH_TRACE = MSG_WITHOUT_TRACE + "\n" + "\n".join(TRACE) def setUp(self): - super(TestNoExceptionTracebackHook, self).setUp() + super().setUp() p = mock.patch.object(root.Root, 'convert') self.root_convert_mock = p.start() self.addCleanup(p.stop) diff --git a/watcher/tests/api/test_scheduling.py b/watcher/tests/api/test_scheduling.py index f18e97f23..9f793afd6 100644 --- a/watcher/tests/api/test_scheduling.py +++ b/watcher/tests/api/test_scheduling.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -40,7 +39,7 @@ class TestSchedulingService(base.TestCase): class TestSchedulingServiceFunctions(db_base.DbTestCase): def setUp(self): - super(TestSchedulingServiceFunctions, self).setUp() + super().setUp() fake_service = utils.get_test_service( created_at=timeutils.utcnow()) self.fake_service = objects.Service(**fake_service) diff --git a/watcher/tests/api/test_utils.py b/watcher/tests/api/test_utils.py index fb76f80e3..17dd96a63 100644 --- a/watcher/tests/api/test_utils.py +++ b/watcher/tests/api/test_utils.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/api/utils.py b/watcher/tests/api/utils.py index 4766be6de..7f74d6ff6 100644 --- a/watcher/tests/api/utils.py +++ b/watcher/tests/api/utils.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain @@ -31,7 +30,7 @@ ADMIN_TOKEN = '4562138218392831' MEMBER_TOKEN = '4562138218392832' -class FakeMemcache(object): +class FakeMemcache: """Fake cache that is used for keystone tokens lookup.""" _cache = { @@ -78,9 +77,9 @@ class FakeMemcache(object): def remove_internal(values, internal): # NOTE(yuriyz): internal attributes should not be posted, except uuid int_attr = [attr.lstrip('/') for attr in internal if attr != '/uuid'] - return dict( - (k, v) for (k, v) in values.items() if k not in int_attr - ) + return { + k: v for (k, v) in values.items() if k not in int_attr + } def audit_post_data(**kw): diff --git a/watcher/tests/api/v1/test_actions.py b/watcher/tests/api/v1/test_actions.py index 10bc1e7b2..b9275b9d5 100644 --- a/watcher/tests/api/v1/test_actions.py +++ b/watcher/tests/api/v1/test_actions.py @@ -52,7 +52,7 @@ class TestActionObject(base.TestCase): class TestListAction(api_base.FunctionalTest): def setUp(self): - super(TestListAction, self).setUp() + super().setUp() self.goal = obj_utils.create_test_goal(self.context) self.strategy = obj_utils.create_test_strategy(self.context) self.audit = obj_utils.create_test_audit(self.context) @@ -237,7 +237,7 @@ class TestListAction(api_base.FunctionalTest): audit2 = obj_utils.create_test_audit( self.context, id=2, uuid=utils.generate_uuid(), - name='My Audit {0}'.format(2)) + name='My Audit {}'.format(2)) action_plan_2 = obj_utils.create_test_action_plan( self.context, uuid=utils.generate_uuid(), @@ -378,7 +378,7 @@ class TestListAction(api_base.FunctionalTest): for direction in ['asc', 'desc']: response = self.get_json( - '/actions?sort_key={0}&sort_dir={1}' + '/actions?sort_key={}&sort_dir={}' .format('action_plan_uuid', direction)) action_plan_uuids = \ @@ -439,9 +439,9 @@ class TestListAction(api_base.FunctionalTest): # Here are the 2 actions left self.assertEqual( - set([act.as_dict()['uuid'] for act in ap2_action_list]), - set([act['uuid'] for act in response['actions'] - if act['action_plan_uuid'] == action_plan2.uuid])) + {act.as_dict()['uuid'] for act in ap2_action_list}, + {act['uuid'] for act in response['actions'] + if act['action_plan_uuid'] == action_plan2.uuid}) def test_list_with_parents(self): action_list = [] @@ -527,7 +527,7 @@ class TestListAction(api_base.FunctionalTest): class TestPatchAction(api_base.FunctionalTest): def setUp(self): - super(TestPatchAction, self).setUp() + super().setUp() self.goal = obj_utils.create_test_goal(self.context) self.strategy = obj_utils.create_test_strategy(self.context) self.audit = obj_utils.create_test_audit(self.context) @@ -715,7 +715,7 @@ class TestPatchAction(api_base.FunctionalTest): class TestActionPolicyEnforcement(api_base.FunctionalTest): def setUp(self): - super(TestActionPolicyEnforcement, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) @@ -766,7 +766,7 @@ class TestActionPolicyEnforcementWithAdminContext(TestListAction, api_base.AdminRoleTest): def setUp(self): - super(TestActionPolicyEnforcementWithAdminContext, self).setUp() + super().setUp() self.policy.set_rules({ "admin_api": "(role:admin or role:administrator)", "default": "rule:admin_api", diff --git a/watcher/tests/api/v1/test_actions_plans.py b/watcher/tests/api/v1/test_actions_plans.py index e428750d6..ca3e559cf 100644 --- a/watcher/tests/api/v1/test_actions_plans.py +++ b/watcher/tests/api/v1/test_actions_plans.py @@ -29,7 +29,7 @@ from watcher.tests.objects import utils as obj_utils class TestListActionPlan(api_base.FunctionalTest): def setUp(self): - super(TestListActionPlan, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) @@ -189,10 +189,10 @@ class TestListActionPlan(api_base.FunctionalTest): action_plan_list = [] audit1 = obj_utils.create_test_audit( self.context, id=2, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(2)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(2)) audit2 = obj_utils.create_test_audit( self.context, id=3, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(3)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(3)) for id_ in range(0, 2): action_plan = obj_utils.create_test_action_plan( @@ -229,7 +229,7 @@ class TestListActionPlan(api_base.FunctionalTest): action_plan_list = [] audit = obj_utils.create_test_audit( self.context, id=2, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(2)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(2)) for id_ in range(2, 5): action_plan = obj_utils.create_test_action_plan( self.context, id=id_, uuid=utils.generate_uuid(), @@ -244,7 +244,7 @@ class TestListActionPlan(api_base.FunctionalTest): action_plan_list1 = [] audit1 = obj_utils.create_test_audit( self.context, id=2, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(2)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(2)) for id_ in range(2, 5): action_plan = obj_utils.create_test_action_plan( self.context, id=id_, uuid=utils.generate_uuid(), @@ -253,7 +253,7 @@ class TestListActionPlan(api_base.FunctionalTest): audit2 = obj_utils.create_test_audit( self.context, id=3, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(3)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(3)) action_plan_list2 = [] for id_ in [5, 6, 7]: action_plan = obj_utils.create_test_action_plan( @@ -303,7 +303,7 @@ class TestListActionPlan(api_base.FunctionalTest): for id_ in range(2, 5): audit = obj_utils.create_test_audit( self.context, id=id_, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(id_)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(id_)) obj_utils.create_test_action_plan( self.context, id=id_, uuid=utils.generate_uuid(), audit_id=audit.id) @@ -358,7 +358,7 @@ class TestListActionPlan(api_base.FunctionalTest): class TestDelete(api_base.FunctionalTest): def setUp(self): - super(TestDelete, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) @@ -426,7 +426,7 @@ class TestDelete(api_base.FunctionalTest): class TestStart(api_base.FunctionalTest): def setUp(self): - super(TestStart, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) @@ -473,7 +473,7 @@ class TestStart(api_base.FunctionalTest): class TestPatch(api_base.FunctionalTest): def setUp(self): - super(TestPatch, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) @@ -635,7 +635,7 @@ class TestPatchStateTransitionDenied(api_base.FunctionalTest): ] def setUp(self): - super(TestPatchStateTransitionDenied, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) @@ -674,7 +674,7 @@ class TestPatchStateTransitionOk(api_base.FunctionalTest): ] def setUp(self): - super(TestPatchStateTransitionOk, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) @@ -702,7 +702,7 @@ class TestPatchStateTransitionOk(api_base.FunctionalTest): class TestActionPlanPolicyEnforcement(api_base.FunctionalTest): def setUp(self): - super(TestActionPlanPolicyEnforcement, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit(self.context) @@ -758,7 +758,7 @@ class TestActionPlanPolicyEnforcementWithAdminContext(TestListActionPlan, api_base.AdminRoleTest): def setUp(self): - super(TestActionPlanPolicyEnforcementWithAdminContext, self).setUp() + super().setUp() self.policy.set_rules({ "admin_api": "(role:admin or role:administrator)", "default": "rule:admin_api", diff --git a/watcher/tests/api/v1/test_audit_templates.py b/watcher/tests/api/v1/test_audit_templates.py index 639f55108..afca25c02 100644 --- a/watcher/tests/api/v1/test_audit_templates.py +++ b/watcher/tests/api/v1/test_audit_templates.py @@ -56,7 +56,7 @@ class TestAuditTemplateObject(base.TestCase): class FunctionalTestWithSetup(api_base.FunctionalTest): def setUp(self): - super(FunctionalTestWithSetup, self).setUp() + super().setUp() self.fake_goal1 = obj_utils.create_test_goal( self.context, id=1, uuid=utils.generate_uuid(), name="dummy_1") self.fake_goal2 = obj_utils.create_test_goal( @@ -161,7 +161,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): audit_template = obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_)) + name='My Audit Template {}'.format(id_)) audit_template_list.append(audit_template) response = self.get_json('/audit_templates') @@ -177,7 +177,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): for id_ in range(1, 6): audit_template = obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_)) + name='My Audit Template {}'.format(id_)) audit_template_list.append(audit_template) # We soft delete the ones with ID 4 and 5 @@ -195,7 +195,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): for id_ in range(1, 6): audit_template = obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_)) + name='My Audit Template {}'.format(id_)) audit_template_list.append(audit_template) # We soft delete the ones with ID 4 and 5 @@ -225,7 +225,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): for id_ in range(5): obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_)) + name='My Audit Template {}'.format(id_)) response = self.get_json('/audit_templates/?limit=3') self.assertEqual(3, len(response['audit_templates'])) @@ -237,7 +237,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): for id_ in range(5): obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_)) + name='My Audit Template {}'.format(id_)) response = self.get_json('/audit_templates') self.assertEqual(3, len(response['audit_templates'])) @@ -250,7 +250,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): itertools.repeat(self.fake_goal2.id, 2)]), 1): obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_), + name='My Audit Template {}'.format(id_), goal_id=goal_id) response = self.get_json( @@ -263,7 +263,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): itertools.repeat(self.fake_goal2.id, 2)]), 1): obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_), + name='My Audit Template {}'.format(id_), goal_id=goal_id) response = self.get_json( @@ -276,7 +276,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): itertools.repeat(self.fake_strategy2.id, 2)]), 1): obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_), + name='My Audit Template {}'.format(id_), strategy_id=strategy_id) response = self.get_json( @@ -289,7 +289,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): itertools.repeat(self.fake_strategy2.id, 2)]), 1): obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_), + name='My Audit Template {}'.format(id_), strategy_id=strategy_id) response = self.get_json( @@ -301,7 +301,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): for id_ in range(1, 6): audit_template = obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_)) + name='My Audit Template {}'.format(id_)) audit_template_list.append(audit_template) response = self.get_json('/audit_templates?sort_key=%s' % 'name') @@ -319,13 +319,13 @@ class TestListAuditTemplate(FunctionalTestWithSetup): itertools.repeat(self.fake_goal2.id, 2)]), 1): audit_template = obj_utils.create_test_audit_template( self.context, id=id_, uuid=utils.generate_uuid(), - name='My Audit Template {0}'.format(id_), + name='My Audit Template {}'.format(id_), goal_id=goal_id) goal_names_list.append(audit_template.goal.name) for direction in ['asc', 'desc']: response = self.get_json( - '/audit_templates?sort_key={0}&sort_dir={1}' + '/audit_templates?sort_key={}&sort_dir={}' .format('goal_name', direction)) goal_names = [s['goal_name'] for s in response['audit_templates']] @@ -344,7 +344,7 @@ class TestListAuditTemplate(FunctionalTestWithSetup): class TestPatch(FunctionalTestWithSetup): def setUp(self): - super(TestPatch, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) self.audit_template = obj_utils.create_test_audit_template( self.context, strategy_id=None) @@ -719,7 +719,7 @@ class TestPost(FunctionalTestWithSetup): class TestDelete(api_base.FunctionalTest): def setUp(self): - super(TestDelete, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) self.audit_template = obj_utils.create_test_audit_template( self.context) @@ -848,7 +848,7 @@ class TestAuditTemplatePolicyEnforcement(api_base.FunctionalTest): class TestAuditTemplatePolicyWithAdminContext(TestListAuditTemplate, api_base.AdminRoleTest): def setUp(self): - super(TestAuditTemplatePolicyWithAdminContext, self).setUp() + super().setUp() self.policy.set_rules({ "admin_api": "(role:admin or role:administrator)", "default": "rule:admin_api", diff --git a/watcher/tests/api/v1/test_audits.py b/watcher/tests/api/v1/test_audits.py index d4e52820b..f83b1ccb2 100644 --- a/watcher/tests/api/v1/test_audits.py +++ b/watcher/tests/api/v1/test_audits.py @@ -84,7 +84,7 @@ class TestAuditObject(base.TestCase): class TestListAudit(api_base.FunctionalTest): def setUp(self): - super(TestListAudit, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit_template(self.context) @@ -214,7 +214,7 @@ class TestListAudit(api_base.FunctionalTest): for id_ in range(5): audit = obj_utils.create_test_audit( self.context, id=id_, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(id_)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(id_)) audit_list.append(audit.uuid) response = self.get_json('/audits') self.assertEqual(len(audit_list), len(response['audits'])) @@ -226,12 +226,12 @@ class TestListAudit(api_base.FunctionalTest): for id_ in [1, 2, 3]: audit = obj_utils.create_test_audit( self.context, id=id_, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(id_)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(id_)) audit_list.append(audit.uuid) for id_ in [4, 5]: audit = obj_utils.create_test_audit( self.context, id=id_, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(id_)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(id_)) audit.soft_delete() response = self.get_json('/audits') self.assertEqual(3, len(response['audits'])) @@ -243,12 +243,12 @@ class TestListAudit(api_base.FunctionalTest): for id_ in [1, 2, 3]: audit = obj_utils.create_test_audit( self.context, id=id_, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(id_)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(id_)) audit_list.append(audit.uuid) for id_ in [4, 5]: audit = obj_utils.create_test_audit( self.context, id=id_, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(id_)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(id_)) audit.soft_delete() audit_list.append(audit.uuid) response = self.get_json('/audits', @@ -262,11 +262,11 @@ class TestListAudit(api_base.FunctionalTest): for id_ in range(5): goal = obj_utils.create_test_goal( self.context, - name='gl{0}'.format(id_), + name='gl{}'.format(id_), uuid=utils.generate_uuid()) obj_utils.create_test_audit( self.context, id=id_, uuid=utils.generate_uuid(), - goal_id=goal.id, name='My Audit {0}'.format(id_)) + goal_id=goal.id, name='My Audit {}'.format(id_)) goal_list.append(goal.uuid) response = self.get_json('/audits/?sort_key=goal_uuid') @@ -285,7 +285,7 @@ class TestListAudit(api_base.FunctionalTest): uuid = utils.generate_uuid() obj_utils.create_test_audit( self.context, id=1, uuid=uuid, - name='My Audit {0}'.format(1)) + name='My Audit {}'.format(1)) response = self.get_json('/audits/%s' % uuid) self.assertIn('links', response.keys()) self.assertEqual(2, len(response['links'])) @@ -299,7 +299,7 @@ class TestListAudit(api_base.FunctionalTest): for id_ in range(5): obj_utils.create_test_audit( self.context, id=id_, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(id_)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(id_)) response = self.get_json('/audits/?limit=3') self.assertEqual(3, len(response['audits'])) @@ -311,7 +311,7 @@ class TestListAudit(api_base.FunctionalTest): for id_ in range(5): obj_utils.create_test_audit( self.context, id=id_, - uuid=utils.generate_uuid(), name='My Audit {0}'.format(id_)) + uuid=utils.generate_uuid(), name='My Audit {}'.format(id_)) response = self.get_json('/audits') self.assertEqual(3, len(response['audits'])) @@ -322,7 +322,7 @@ class TestListAudit(api_base.FunctionalTest): class TestPatch(api_base.FunctionalTest): def setUp(self): - super(TestPatch, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit_template(self.context) @@ -454,7 +454,7 @@ class TestPatchStateTransitionDenied(api_base.FunctionalTest): ] def setUp(self): - super(TestPatchStateTransitionDenied, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit_template(self.context) @@ -498,7 +498,7 @@ class TestPatchStateTransitionOk(api_base.FunctionalTest): ] def setUp(self): - super(TestPatchStateTransitionOk, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit_template(self.context) @@ -542,7 +542,7 @@ class TestPostBase(api_base.FunctionalTest): return audit def setUp(self): - super(TestPostBase, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit_template(self.context) @@ -1100,7 +1100,7 @@ class TestPost(TestPostBase): class TestDelete(api_base.FunctionalTest): def setUp(self): - super(TestDelete, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit_template(self.context) @@ -1162,7 +1162,7 @@ class TestDelete(api_base.FunctionalTest): class TestAuditPolicyEnforcement(api_base.FunctionalTest): def setUp(self): - super(TestAuditPolicyEnforcement, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) def _common_policy_check(self, rule, func, *arg, **kwarg): @@ -1223,7 +1223,7 @@ class TestAuditEnforcementWithAdminContext(TestListAudit, api_base.AdminRoleTest): def setUp(self): - super(TestAuditEnforcementWithAdminContext, self).setUp() + super().setUp() self.policy.set_rules({ "admin_api": "(role:admin or role:administrator)", "default": "rule:admin_api", @@ -1237,7 +1237,7 @@ class TestAuditEnforcementWithAdminContext(TestListAudit, class TestAuditZoneMigration(TestPostBase): def setUp(self): - super(TestAuditZoneMigration, self).setUp() + super().setUp() # create strategy having the same spec as Zone Migration self.zm_spec = strategies.ZoneMigration.get_schema() diff --git a/watcher/tests/api/v1/test_data_model.py b/watcher/tests/api/v1/test_data_model.py index d2f4e9bee..fb94e8aa4 100644 --- a/watcher/tests/api/v1/test_data_model.py +++ b/watcher/tests/api/v1/test_data_model.py @@ -28,7 +28,7 @@ from watcher.tests.decision_engine.model import faker_cluster_state class TestListDataModel(api_base.FunctionalTest): def setUp(self): - super(TestListDataModel, self).setUp() + super().setUp() p_dcapi = mock.patch.object(deapi, 'DecisionEngineAPI') self.mock_dcapi = p_dcapi.start() self.fake_response = {'context': [{'server_uuid': 'fake_uuid'}]} @@ -103,7 +103,7 @@ class TestListDataModelResponse(api_base.FunctionalTest): } def setUp(self): - super(TestListDataModelResponse, self).setUp() + super().setUp() p_dcapi = mock.patch.object(deapi, 'DecisionEngineAPI') self.mock_dcapi = p_dcapi.start() self.addCleanup(p_dcapi.stop) @@ -149,7 +149,7 @@ class TestListDataModelResponse(api_base.FunctionalTest): class TestDataModelPolicyEnforcement(api_base.FunctionalTest): def setUp(self): - super(TestDataModelPolicyEnforcement, self).setUp() + super().setUp() p_dcapi = mock.patch.object(deapi, 'DecisionEngineAPI') self.mock_dcapi = p_dcapi.start() self.addCleanup(p_dcapi.stop) @@ -178,7 +178,7 @@ class TestDataModelEnforcementWithAdminContext( TestListDataModel, api_base.AdminRoleTest): def setUp(self): - super(TestDataModelEnforcementWithAdminContext, self).setUp() + super().setUp() self.policy.set_rules({ "admin_api": "(role:admin or role:administrator)", "default": "rule:admin_api", diff --git a/watcher/tests/api/v1/test_goals.py b/watcher/tests/api/v1/test_goals.py index 54c8c6314..ff5dd6c6a 100644 --- a/watcher/tests/api/v1/test_goals.py +++ b/watcher/tests/api/v1/test_goals.py @@ -80,7 +80,7 @@ class TestListGoal(api_base.FunctionalTest): goal = obj_utils.create_test_goal( self.context, id=idx, uuid=utils.generate_uuid(), - name='GOAL_{0}'.format(idx)) + name='GOAL_{}'.format(idx)) goal_list.append(goal.uuid) response = self.get_json('/goals') self.assertGreater(len(response['goals']), 2) @@ -90,12 +90,12 @@ class TestListGoal(api_base.FunctionalTest): for id_ in [1, 2, 3]: goal = obj_utils.create_test_goal( self.context, id=id_, uuid=utils.generate_uuid(), - name='GOAL_{0}'.format(id_)) + name='GOAL_{}'.format(id_)) goal_list.append(goal.uuid) for id_ in [4, 5]: goal = obj_utils.create_test_goal( self.context, id=id_, uuid=utils.generate_uuid(), - name='GOAL_{0}'.format(id_)) + name='GOAL_{}'.format(id_)) goal.soft_delete() response = self.get_json('/goals') self.assertEqual(3, len(response['goals'])) @@ -107,7 +107,7 @@ class TestListGoal(api_base.FunctionalTest): obj_utils.create_test_goal( self.context, id=idx, uuid=utils.generate_uuid(), - name='GOAL_{0}'.format(idx)) + name='GOAL_{}'.format(idx)) response = self.get_json('/goals/?limit=2') self.assertEqual(2, len(response['goals'])) @@ -116,7 +116,7 @@ class TestListGoal(api_base.FunctionalTest): obj_utils.create_test_goal( self.context, id=idx, uuid=utils.generate_uuid(), - name='GOAL_{0}'.format(idx)) + name='GOAL_{}'.format(idx)) cfg.CONF.set_override('max_limit', 3, 'api') response = self.get_json('/goals') self.assertEqual(3, len(response['goals'])) @@ -127,7 +127,7 @@ class TestListGoal(api_base.FunctionalTest): goal = obj_utils.create_test_goal( self.context, id=idx, uuid=utils.generate_uuid(), - name='GOAL_{0}'.format(idx)) + name='GOAL_{}'.format(idx)) goal_list.append(goal.uuid) response = self.get_json('/goals/?sort_key=uuid') @@ -180,7 +180,7 @@ class TestGoalPolicyEnforcementWithAdminContext(TestListGoal, api_base.AdminRoleTest): def setUp(self): - super(TestGoalPolicyEnforcementWithAdminContext, self).setUp() + super().setUp() self.policy.set_rules({ "admin_api": "(role:admin or role:administrator)", "default": "rule:admin_api", diff --git a/watcher/tests/api/v1/test_microversions.py b/watcher/tests/api/v1/test_microversions.py index 939c176c6..0025df3be 100644 --- a/watcher/tests/api/v1/test_microversions.py +++ b/watcher/tests/api/v1/test_microversions.py @@ -31,7 +31,7 @@ class TestMicroversions(api_base.FunctionalTest): 'action_plans', 'services'] def setUp(self): - super(TestMicroversions, self).setUp() + super().setUp() def test_wrong_major_version(self): response = self.get_json( diff --git a/watcher/tests/api/v1/test_scoring_engines.py b/watcher/tests/api/v1/test_scoring_engines.py index 7aa31b0d7..048ae9283 100644 --- a/watcher/tests/api/v1/test_scoring_engines.py +++ b/watcher/tests/api/v1/test_scoring_engines.py @@ -71,7 +71,7 @@ class TestListScoringEngine(api_base.FunctionalTest): for idx in range(1, 6): scoring_engine = obj_utils.create_test_scoring_engine( self.context, id=idx, uuid=utils.generate_uuid(), - name=str(idx), description='SE_{0}'.format(idx)) + name=str(idx), description='SE_{}'.format(idx)) scoring_engine_list.append(scoring_engine.name) response = self.get_json('/scoring_engines') self.assertEqual(5, len(response['scoring_engines'])) @@ -85,12 +85,12 @@ class TestListScoringEngine(api_base.FunctionalTest): for id_ in [1, 2, 3]: scoring_engine = obj_utils.create_test_scoring_engine( self.context, id=id_, uuid=utils.generate_uuid(), - name=str(id_), description='SE_{0}'.format(id_)) + name=str(id_), description='SE_{}'.format(id_)) scoring_engine_list.append(scoring_engine.name) for id_ in [4, 5]: scoring_engine = obj_utils.create_test_scoring_engine( self.context, id=id_, uuid=utils.generate_uuid(), - name=str(id_), description='SE_{0}'.format(id_)) + name=str(id_), description='SE_{}'.format(id_)) scoring_engine.soft_delete() response = self.get_json('/scoring_engines') self.assertEqual(3, len(response['scoring_engines'])) @@ -101,7 +101,7 @@ class TestListScoringEngine(api_base.FunctionalTest): for idx in range(1, 6): obj_utils.create_test_scoring_engine( self.context, id=idx, uuid=utils.generate_uuid(), - name=str(idx), description='SE_{0}'.format(idx)) + name=str(idx), description='SE_{}'.format(idx)) response = self.get_json('/scoring_engines/?limit=2') self.assertEqual(2, len(response['scoring_engines'])) @@ -109,7 +109,7 @@ class TestListScoringEngine(api_base.FunctionalTest): for idx in range(1, 6): obj_utils.create_test_scoring_engine( self.context, id=idx, uuid=utils.generate_uuid(), - name=str(idx), description='SE_{0}'.format(idx)) + name=str(idx), description='SE_{}'.format(idx)) cfg.CONF.set_override('max_limit', 3, 'api') response = self.get_json('/scoring_engines') self.assertEqual(3, len(response['scoring_engines'])) @@ -119,7 +119,7 @@ class TestListScoringEngine(api_base.FunctionalTest): for idx in range(1, 6): scoring_engine = obj_utils.create_test_scoring_engine( self.context, id=idx, uuid=utils.generate_uuid(), - name=str(idx), description='SE_{0}'.format(idx)) + name=str(idx), description='SE_{}'.format(idx)) scoring_engine_list.append(scoring_engine.uuid) response = self.get_json('/scoring_engines/?sort_key=uuid') @@ -172,7 +172,7 @@ class TestScoringEnginePolicyEnforcementWithAdminContext( TestListScoringEngine, api_base.AdminRoleTest): def setUp(self): - super(TestScoringEnginePolicyEnforcementWithAdminContext, self).setUp() + super().setUp() self.policy.set_rules({ "admin_api": "(role:admin or role:administrator)", "default": "rule:admin_api", diff --git a/watcher/tests/api/v1/test_services.py b/watcher/tests/api/v1/test_services.py index 60962e5dc..3726111a2 100644 --- a/watcher/tests/api/v1/test_services.py +++ b/watcher/tests/api/v1/test_services.py @@ -82,12 +82,12 @@ class TestListService(api_base.FunctionalTest): for idx in range(1, 4): service = obj_utils.create_test_service( self.context, id=idx, host='CONTROLLER1', - name='SERVICE_{0}'.format(idx)) + name='SERVICE_{}'.format(idx)) service_list.append(service.id) for idx in range(1, 4): service = obj_utils.create_test_service( self.context, id=3+idx, host='CONTROLLER2', - name='SERVICE_{0}'.format(idx)) + name='SERVICE_{}'.format(idx)) service_list.append(service.id) response = self.get_json('/services') self.assertEqual(6, len(response['services'])) @@ -101,12 +101,12 @@ class TestListService(api_base.FunctionalTest): for id_ in [1, 2, 3]: service = obj_utils.create_test_service( self.context, id=id_, host='CONTROLLER', - name='SERVICE_{0}'.format(id_)) + name='SERVICE_{}'.format(id_)) service_list.append(service.id) for id_ in [4, 5]: service = obj_utils.create_test_service( self.context, id=id_, host='CONTROLLER', - name='SERVICE_{0}'.format(id_)) + name='SERVICE_{}'.format(id_)) service.soft_delete() response = self.get_json('/services') self.assertEqual(3, len(response['services'])) @@ -118,7 +118,7 @@ class TestListService(api_base.FunctionalTest): obj_utils.create_test_service( self.context, id=idx, host='CONTROLLER', - name='SERVICE_{0}'.format(idx)) + name='SERVICE_{}'.format(idx)) response = self.get_json('/services/?limit=2') self.assertEqual(2, len(response['services'])) @@ -127,7 +127,7 @@ class TestListService(api_base.FunctionalTest): obj_utils.create_test_service( self.context, id=idx, host='CONTROLLER', - name='SERVICE_{0}'.format(idx)) + name='SERVICE_{}'.format(idx)) cfg.CONF.set_override('max_limit', 3, 'api') response = self.get_json('/services') self.assertEqual(3, len(response['services'])) @@ -137,7 +137,7 @@ class TestListService(api_base.FunctionalTest): for id_ in range(1, 4): service = obj_utils.create_test_service( self.context, id=id_, host='CONTROLLER', - name='SERVICE_{0}'.format(id_)) + name='SERVICE_{}'.format(id_)) service_list.append(service.name) response = self.get_json('/services/?sort_key=name') @@ -190,7 +190,7 @@ class TestServiceEnforcementWithAdminContext(TestListService, api_base.AdminRoleTest): def setUp(self): - super(TestServiceEnforcementWithAdminContext, self).setUp() + super().setUp() self.policy.set_rules({ "admin_api": "(role:admin or role:administrator)", "default": "rule:admin_api", diff --git a/watcher/tests/api/v1/test_strategies.py b/watcher/tests/api/v1/test_strategies.py index 4600ea3b6..3357905a5 100644 --- a/watcher/tests/api/v1/test_strategies.py +++ b/watcher/tests/api/v1/test_strategies.py @@ -26,7 +26,7 @@ from watcher.tests.objects import utils as obj_utils class TestListStrategy(api_base.FunctionalTest): def setUp(self): - super(TestListStrategy, self).setUp() + super().setUp() self.fake_goal = obj_utils.create_test_goal( self.context, uuid=utils.generate_uuid()) @@ -113,7 +113,7 @@ class TestListStrategy(api_base.FunctionalTest): strategy = obj_utils.create_test_strategy( self.context, id=idx, uuid=utils.generate_uuid(), - name='STRATEGY_{0}'.format(idx)) + name='STRATEGY_{}'.format(idx)) strategy_list.append(strategy.uuid) response = self.get_json('/strategies') self.assertEqual(5, len(response['strategies'])) @@ -127,12 +127,12 @@ class TestListStrategy(api_base.FunctionalTest): for id_ in [1, 2, 3]: strategy = obj_utils.create_test_strategy( self.context, id=id_, uuid=utils.generate_uuid(), - name='STRATEGY_{0}'.format(id_)) + name='STRATEGY_{}'.format(id_)) strategy_list.append(strategy.uuid) for id_ in [4, 5]: strategy = obj_utils.create_test_strategy( self.context, id=id_, uuid=utils.generate_uuid(), - name='STRATEGY_{0}'.format(id_)) + name='STRATEGY_{}'.format(id_)) strategy.soft_delete() response = self.get_json('/strategies') self.assertEqual(3, len(response['strategies'])) @@ -144,7 +144,7 @@ class TestListStrategy(api_base.FunctionalTest): obj_utils.create_test_strategy( self.context, id=idx, uuid=utils.generate_uuid(), - name='STRATEGY_{0}'.format(idx)) + name='STRATEGY_{}'.format(idx)) response = self.get_json('/strategies/?limit=2') self.assertEqual(2, len(response['strategies'])) @@ -153,7 +153,7 @@ class TestListStrategy(api_base.FunctionalTest): obj_utils.create_test_strategy( self.context, id=idx, uuid=utils.generate_uuid(), - name='STRATEGY_{0}'.format(idx)) + name='STRATEGY_{}'.format(idx)) cfg.CONF.set_override('max_limit', 3, 'api') response = self.get_json('/strategies') self.assertEqual(3, len(response['strategies'])) @@ -228,7 +228,7 @@ class TestListStrategy(api_base.FunctionalTest): strategy = obj_utils.create_test_strategy( self.context, id=idx, uuid=utils.generate_uuid(), - name='STRATEGY_{0}'.format(idx)) + name='STRATEGY_{}'.format(idx)) goals_uuid_list.append(strategy.goal.uuid) response = self.get_json('/strategies/?sort_key=goal_uuid') @@ -247,7 +247,7 @@ class TestListStrategy(api_base.FunctionalTest): class TestStrategyPolicyEnforcement(api_base.FunctionalTest): def setUp(self): - super(TestStrategyPolicyEnforcement, self).setUp() + super().setUp() self.fake_goal = obj_utils.create_test_goal( self.context, uuid=utils.generate_uuid()) @@ -293,7 +293,7 @@ class TestStrategyEnforcementWithAdminContext( TestListStrategy, api_base.AdminRoleTest): def setUp(self): - super(TestStrategyEnforcementWithAdminContext, self).setUp() + super().setUp() self.policy.set_rules({ "admin_api": "(role:admin or role:administrator)", "default": "rule:admin_api", diff --git a/watcher/tests/api/v1/test_types.py b/watcher/tests/api/v1/test_types.py index 59bf9d0db..782dbafe6 100644 --- a/watcher/tests/api/v1/test_types.py +++ b/watcher/tests/api/v1/test_types.py @@ -114,7 +114,7 @@ class MyRoot(wsme.WSRoot): class TestJsonPatchType(base.TestCase): def setUp(self): - super(TestJsonPatchType, self).setUp() + super().setUp() self.app = webtest.TestApp(MyRoot(['restjson']).wsgiapp()) def _patch_json(self, params, expect_errors=False): @@ -216,7 +216,7 @@ class MyAllowedRoot(wsme.WSRoot): class TestAllowedJsonPatchType(base.TestCase): def setUp(self): - super(TestAllowedJsonPatchType, self).setUp() + super().setUp() self.app = webtest.TestApp(MyAllowedRoot(['restjson']).wsgiapp()) def _patch_json(self, params, expect_errors=False): diff --git a/watcher/tests/api/v1/test_webhooks.py b/watcher/tests/api/v1/test_webhooks.py index bd20000ea..437599578 100644 --- a/watcher/tests/api/v1/test_webhooks.py +++ b/watcher/tests/api/v1/test_webhooks.py @@ -23,7 +23,7 @@ from watcher.tests.objects import utils as obj_utils class TestPost(api_base.FunctionalTest): def setUp(self): - super(TestPost, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context) obj_utils.create_test_strategy(self.context) obj_utils.create_test_audit_template(self.context) diff --git a/watcher/tests/applier/action_plan/test_default_action_handler.py b/watcher/tests/applier/action_plan/test_default_action_handler.py index 354cdf0c8..698ba8a64 100644 --- a/watcher/tests/applier/action_plan/test_default_action_handler.py +++ b/watcher/tests/applier/action_plan/test_default_action_handler.py @@ -34,7 +34,7 @@ class TestDefaultActionPlanHandler(base.DbTestCase): pass def setUp(self): - super(TestDefaultActionPlanHandler, self).setUp() + super().setUp() p_action_plan_notifications = mock.patch.object( notifications, 'action_plan', autospec=True) diff --git a/watcher/tests/applier/actions/loading/test_default_actions_loader.py b/watcher/tests/applier/actions/loading/test_default_actions_loader.py index 3115e32b4..b7015c675 100644 --- a/watcher/tests/applier/actions/loading/test_default_actions_loader.py +++ b/watcher/tests/applier/actions/loading/test_default_actions_loader.py @@ -20,7 +20,7 @@ from watcher.tests import base class TestDefaultActionLoader(base.TestCase): def setUp(self): - super(TestDefaultActionLoader, self).setUp() + super().setUp() self.loader = default.DefaultActionLoader() def test_endpoints(self): diff --git a/watcher/tests/applier/actions/test_change_node_power_state.py b/watcher/tests/applier/actions/test_change_node_power_state.py index 8444551c5..c216d7bc6 100644 --- a/watcher/tests/applier/actions/test_change_node_power_state.py +++ b/watcher/tests/applier/actions/test_change_node_power_state.py @@ -30,7 +30,7 @@ COMPUTE_NODE = "compute-1" class TestChangeNodePowerState(base.TestCase): def setUp(self): - super(TestChangeNodePowerState, self).setUp() + super().setUp() p_m_factory = mock.patch.object(m_helper_factory, 'get_helper') m_factory = p_m_factory.start() diff --git a/watcher/tests/applier/actions/test_change_nova_service_state.py b/watcher/tests/applier/actions/test_change_nova_service_state.py index 192f871a8..46d9479ac 100644 --- a/watcher/tests/applier/actions/test_change_nova_service_state.py +++ b/watcher/tests/applier/actions/test_change_nova_service_state.py @@ -28,7 +28,7 @@ from watcher.tests import base class TestChangeNovaServiceState(base.TestCase): def setUp(self): - super(TestChangeNovaServiceState, self).setUp() + super().setUp() self.m_osc_cls = mock.Mock() self.m_helper_cls = mock.Mock() diff --git a/watcher/tests/applier/actions/test_migration.py b/watcher/tests/applier/actions/test_migration.py index b13eb9e5e..9546e408c 100644 --- a/watcher/tests/applier/actions/test_migration.py +++ b/watcher/tests/applier/actions/test_migration.py @@ -30,7 +30,7 @@ class TestMigration(base.TestCase): INSTANCE_UUID = "45a37aeb-95ab-4ddb-a305-7d9f62c2f5ba" def setUp(self): - super(TestMigration, self).setUp() + super().setUp() self.m_osc_cls = mock.Mock() self.m_helper_cls = mock.Mock() diff --git a/watcher/tests/applier/actions/test_resize.py b/watcher/tests/applier/actions/test_resize.py index 5cd23801f..51360abb8 100644 --- a/watcher/tests/applier/actions/test_resize.py +++ b/watcher/tests/applier/actions/test_resize.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -28,7 +27,7 @@ class TestResize(base.TestCase): INSTANCE_UUID = "94ae2f92-b7fd-4da7-9e97-f13504ae98c4" def setUp(self): - super(TestResize, self).setUp() + super().setUp() self.r_osc_cls = mock.Mock() self.r_helper_cls = mock.Mock() diff --git a/watcher/tests/applier/actions/test_sleep.py b/watcher/tests/applier/actions/test_sleep.py index 76d1b63c1..5458cac61 100644 --- a/watcher/tests/applier/actions/test_sleep.py +++ b/watcher/tests/applier/actions/test_sleep.py @@ -23,7 +23,7 @@ from watcher.tests import base class TestSleep(base.TestCase): def setUp(self): - super(TestSleep, self).setUp() + super().setUp() self.s = sleep.Sleep(mock.Mock()) def test_parameters_duration(self): diff --git a/watcher/tests/applier/actions/test_stop.py b/watcher/tests/applier/actions/test_stop.py index fdfd59666..c607a8779 100644 --- a/watcher/tests/applier/actions/test_stop.py +++ b/watcher/tests/applier/actions/test_stop.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -29,7 +28,7 @@ class TestStop(base.TestCase): INSTANCE_UUID = "45a37aeb-95ab-4ddb-a305-7d9f62c2f5ba" def setUp(self): - super(TestStop, self).setUp() + super().setUp() self.m_helper = self.useFixture( fixtures.MockPatch( diff --git a/watcher/tests/applier/actions/test_volume_migration.py b/watcher/tests/applier/actions/test_volume_migration.py index d97957cf4..39d95a6b5 100644 --- a/watcher/tests/applier/actions/test_volume_migration.py +++ b/watcher/tests/applier/actions/test_volume_migration.py @@ -31,7 +31,7 @@ class TestMigration(base.TestCase): INSTANCE_UUID = "45a37aec-85ab-4dda-a303-7d9f62c2f5bb" def setUp(self): - super(TestMigration, self).setUp() + super().setUp() self.m_osc_cls = mock.Mock() self.m_osc = mock.Mock(spec=clients.OpenStackClients) diff --git a/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py b/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py index f73face1c..885db1d92 100644 --- a/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py +++ b/watcher/tests/applier/messaging/test_trigger_action_plan_endpoint.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -27,7 +26,7 @@ from watcher.tests import base class TestTriggerActionPlan(base.TestCase): def __init__(self, *args, **kwds): - super(TestTriggerActionPlan, self).__init__(*args, **kwds) + super().__init__(*args, **kwds) self.applier = mock.MagicMock() self.endpoint = trigger.TriggerActionPlan(self.applier) diff --git a/watcher/tests/applier/test_applier_manager.py b/watcher/tests/applier/test_applier_manager.py index cc38ad788..f55ff85a3 100644 --- a/watcher/tests/applier/test_applier_manager.py +++ b/watcher/tests/applier/test_applier_manager.py @@ -26,7 +26,7 @@ from watcher.tests import base class TestApplierManager(base.TestCase): def setUp(self): - super(TestApplierManager, self).setUp() + super().setUp() p_heartbeat = mock.patch.object( service.ServiceHeartbeat, "send_beat") self.m_heartbeat = p_heartbeat.start() diff --git a/watcher/tests/applier/test_rpcapi.py b/watcher/tests/applier/test_rpcapi.py index cd9f48406..e9ec6febf 100644 --- a/watcher/tests/applier/test_rpcapi.py +++ b/watcher/tests/applier/test_rpcapi.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS diff --git a/watcher/tests/applier/test_sync.py b/watcher/tests/applier/test_sync.py index 4ca41b7ec..a6f641c0c 100644 --- a/watcher/tests/applier/test_sync.py +++ b/watcher/tests/applier/test_sync.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2018 SBCloud # # Authors: Alexander Chadin @@ -33,7 +32,7 @@ from watcher.tests.objects import utils as obj_utils class TestCancelOngoingActionPlans(db_base.DbTestCase): def setUp(self): - super(TestCancelOngoingActionPlans, self).setUp() + super().setUp() p_audit_notifications = mock.patch.object( notifications, 'audit', autospec=True) self.m_audit_notifications = p_audit_notifications.start() diff --git a/watcher/tests/applier/workflow_engine/loading/test_default_engine_loader.py b/watcher/tests/applier/workflow_engine/loading/test_default_engine_loader.py index 0c014a15f..024b4e475 100644 --- a/watcher/tests/applier/workflow_engine/loading/test_default_engine_loader.py +++ b/watcher/tests/applier/workflow_engine/loading/test_default_engine_loader.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +20,7 @@ from watcher.tests import base class TestDefaultActionLoader(base.TestCase): def setUp(self): - super(TestDefaultActionLoader, self).setUp() + super().setUp() self.loader = default.DefaultWorkFlowEngineLoader() def test_endpoints(self): diff --git a/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py b/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py index 43e2a3c07..9bc129a8c 100644 --- a/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py +++ b/watcher/tests/applier/workflow_engine/test_default_workflow_engine.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -57,7 +56,7 @@ class FakeAction(abase.BaseAction, metaclass=abc.ABCMeta): class TestDefaultWorkFlowEngine(base.DbTestCase): def setUp(self): - super(TestDefaultWorkFlowEngine, self).setUp() + super().setUp() self.engine = tflow.DefaultWorkFlowEngine( config=mock.Mock(), context=self.context, @@ -205,24 +204,24 @@ class TestDefaultWorkFlowEngine(base.DbTestCase): expected_nodes = [ {'uuid': 'bc7eee5c-4fbe-4def-9744-b539be55aa19', - 'input_parameters': {u'message': u'test'}, - 'action_plan_id': 0, 'state': u'PENDING', 'parents': [], - 'action_type': u'nop', 'id': 1}, + 'input_parameters': {'message': 'test'}, + 'action_plan_id': 0, 'state': 'PENDING', 'parents': [], + 'action_type': 'nop', 'id': 1}, {'uuid': '0565bd5c-aa00-46e5-8d81-2cb5cc1ffa23', - 'input_parameters': {u'message': u'second test'}, - 'action_plan_id': 0, 'state': u'PENDING', 'parents': [], - 'action_type': u'nop', 'id': 2}, + 'input_parameters': {'message': 'second test'}, + 'action_plan_id': 0, 'state': 'PENDING', 'parents': [], + 'action_type': 'nop', 'id': 2}, {'uuid': 'be436531-0da3-4dad-a9c0-ea1d2aff6496', - 'input_parameters': {u'duration': 0.0}, - 'action_plan_id': 0, 'state': u'PENDING', - 'parents': [u'bc7eee5c-4fbe-4def-9744-b539be55aa19', - u'0565bd5c-aa00-46e5-8d81-2cb5cc1ffa23'], - 'action_type': u'sleep', 'id': 3}, + 'input_parameters': {'duration': 0.0}, + 'action_plan_id': 0, 'state': 'PENDING', + 'parents': ['bc7eee5c-4fbe-4def-9744-b539be55aa19', + '0565bd5c-aa00-46e5-8d81-2cb5cc1ffa23'], + 'action_type': 'sleep', 'id': 3}, {'uuid': '9eb51e14-936d-4d12-a500-6ba0f5e0bb1c', - 'input_parameters': {u'duration': 0.0}, - 'action_plan_id': 0, 'state': u'PENDING', - 'parents': [u'be436531-0da3-4dad-a9c0-ea1d2aff6496'], - 'action_type': u'sleep', 'id': 4}] + 'input_parameters': {'duration': 0.0}, + 'action_plan_id': 0, 'state': 'PENDING', + 'parents': ['be436531-0da3-4dad-a9c0-ea1d2aff6496'], + 'action_type': 'sleep', 'id': 4}] expected_edges = [ ('action_type:nop uuid:0565bd5c-aa00-46e5-8d81-2cb5cc1ffa23', diff --git a/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py b/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py index 7242f988b..e4cf9e8ef 100644 --- a/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py +++ b/watcher/tests/applier/workflow_engine/test_taskflow_action_container.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -31,7 +30,7 @@ from watcher.tests.objects import utils as obj_utils class TestTaskFlowActionContainer(base.DbTestCase): def setUp(self): - super(TestTaskFlowActionContainer, self).setUp() + super().setUp() self.engine = tflow.DefaultWorkFlowEngine( config=mock.Mock(), context=self.context, @@ -224,8 +223,8 @@ class TestTaskFlowActionContainer(base.DbTestCase): cfg.CONF.set_override("rollback_when_actionplan_failed", False, group="watcher_applier") - action_name = "action_type:{0} uuid:{1}".format(action.action_type, - action.uuid) + action_name = "action_type:{} uuid:{}".format(action.action_type, + action.uuid) expected_log = ('Failed actionplan rollback option is turned off, ' 'and the following action will be skipped: %s') action_container.revert() @@ -249,8 +248,8 @@ class TestTaskFlowActionContainer(base.DbTestCase): cfg.CONF.set_override("rollback_when_actionplan_failed", True, group="watcher_applier") - action_name = "action_type:{0} uuid:{1}".format(action.action_type, - action.uuid) + action_name = "action_type:{} uuid:{}".format(action.action_type, + action.uuid) expected_log = 'Revert action: %s' action_container.revert() mock_log.warning.assert_called_once_with(expected_log, action_name) diff --git a/watcher/tests/base.py b/watcher/tests/base.py index f30217394..25c38a199 100644 --- a/watcher/tests/base.py +++ b/watcher/tests/base.py @@ -49,7 +49,7 @@ class BaseTestCase(testscenarios.WithScenarios, base.BaseTestCase): # Ensure BaseTestCase's ConfigureLogging fixture is disabled since # we're using our own (StandardLogging). with fixtures.EnvironmentVariable('OS_LOG_CAPTURE', '0'): - super(BaseTestCase, self).setUp() + super().setUp() self.stdlog = self.useFixture(watcher_fixtures.StandardLogging()) self.addCleanup(cfg.CONF.reset) @@ -58,7 +58,7 @@ class TestCase(BaseTestCase): """Test case base class for all unit tests.""" def setUp(self): - super(TestCase, self).setUp() + super().setUp() self.useFixture(conf_fixture.ConfReloadFixture()) self.policy = self.useFixture(policy_fixture.PolicyFixture()) self.messaging_conf = self.useFixture(conffixture.ConfFixture(CONF)) diff --git a/watcher/tests/cmd/test_api.py b/watcher/tests/cmd/test_api.py index 7e2b50fae..4f4c8d47a 100644 --- a/watcher/tests/cmd/test_api.py +++ b/watcher/tests/cmd/test_api.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +29,7 @@ from watcher.tests import base class TestApi(base.BaseTestCase): def setUp(self): - super(TestApi, self).setUp() + super().setUp() self.conf = cfg.CONF self._parse_cli_opts = self.conf._parse_cli_opts @@ -42,7 +41,7 @@ class TestApi(base.BaseTestCase): self.conf._parse_cli_opts = _fake_parse_method def tearDown(self): - super(TestApi, self).tearDown() + super().tearDown() self.conf._parse_cli_opts = self._parse_cli_opts @mock.patch.object(wsgi, "Server", mock.Mock()) diff --git a/watcher/tests/cmd/test_applier.py b/watcher/tests/cmd/test_applier.py index e382d7ce4..7a21e39ae 100644 --- a/watcher/tests/cmd/test_applier.py +++ b/watcher/tests/cmd/test_applier.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +27,7 @@ from watcher.tests import base class TestApplier(base.BaseTestCase): def setUp(self): - super(TestApplier, self).setUp() + super().setUp() self.conf = cfg.CONF self._parse_cli_opts = self.conf._parse_cli_opts @@ -44,7 +43,7 @@ class TestApplier(base.BaseTestCase): self.addCleanup(p_heartbeat.stop) def tearDown(self): - super(TestApplier, self).tearDown() + super().tearDown() self.conf._parse_cli_opts = self._parse_cli_opts @mock.patch.object(sync.Syncer, "sync", mock.Mock()) diff --git a/watcher/tests/cmd/test_db_manage.py b/watcher/tests/cmd/test_db_manage.py index 6ff030e5a..8fe8ba8ad 100644 --- a/watcher/tests/cmd/test_db_manage.py +++ b/watcher/tests/cmd/test_db_manage.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/cmd/test_decision_engine.py b/watcher/tests/cmd/test_decision_engine.py index 5e5c946d8..0d904bf92 100644 --- a/watcher/tests/cmd/test_decision_engine.py +++ b/watcher/tests/cmd/test_decision_engine.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +30,7 @@ from watcher.tests.fixtures import watcher as watcher_fixtures class TestDecisionEngine(base.BaseTestCase): def setUp(self): - super(TestDecisionEngine, self).setUp() + super().setUp() self.conf = cfg.CONF self._parse_cli_opts = self.conf._parse_cli_opts @@ -53,7 +52,7 @@ class TestDecisionEngine(base.BaseTestCase): self.fake_keystone = self.useFixture(watcher_fixtures.KeystoneClient()) def tearDown(self): - super(TestDecisionEngine, self).tearDown() + super().tearDown() self.conf._parse_cli_opts = self._parse_cli_opts @mock.patch.object(sync.Syncer, "sync", mock.Mock()) diff --git a/watcher/tests/cmd/test_status.py b/watcher/tests/cmd/test_status.py index 633e85502..c54b22693 100644 --- a/watcher/tests/cmd/test_status.py +++ b/watcher/tests/cmd/test_status.py @@ -24,7 +24,7 @@ CONF = conf.CONF class TestUpgradeChecks(base.TestCase): def setUp(self): - super(TestUpgradeChecks, self).setUp() + super().setUp() self.cmd = status.Checks() def test_minimum_nova_api_version_ok(self): diff --git a/watcher/tests/common/loader/test_loader.py b/watcher/tests/common/loader/test_loader.py index 9ad97836d..da30a9669 100644 --- a/watcher/tests/common/loader/test_loader.py +++ b/watcher/tests/common/loader/test_loader.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,7 +44,7 @@ class FakeLoadableWithOpts(loadable.Loadable): class TestLoader(base.TestCase): def setUp(self): - super(TestLoader, self).setUp() + super().setUp() def _fake_parse(self, *args, **kw): return cfg.ConfigOpts._parse_cli_opts(cfg.CONF, []) diff --git a/watcher/tests/common/test_ironic_helper.py b/watcher/tests/common/test_ironic_helper.py index 7aab69b78..8668fe91b 100644 --- a/watcher/tests/common/test_ironic_helper.py +++ b/watcher/tests/common/test_ironic_helper.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE Corporation # # Authors:Yumeng Bao @@ -29,7 +28,7 @@ from watcher.tests import base class TestIronicHelper(base.TestCase): def setUp(self): - super(TestIronicHelper, self).setUp() + super().setUp() osc = clients.OpenStackClients() p_ironic = mock.patch.object(osc, 'ironic') diff --git a/watcher/tests/common/test_keystone_helper.py b/watcher/tests/common/test_keystone_helper.py index 0db62df43..73762aa9b 100644 --- a/watcher/tests/common/test_keystone_helper.py +++ b/watcher/tests/common/test_keystone_helper.py @@ -24,7 +24,7 @@ from watcher.tests.fixtures import watcher as watcher_fixtures class TestKeystoneHelper(test.TestCase): def setUp(self): - super(TestKeystoneHelper, self).setUp() + super().setUp() self.fake_keystone = self.useFixture(watcher_fixtures.KeystoneClient()) self.keystone_svs = self.fake_keystone.m_keystone.return_value.services diff --git a/watcher/tests/common/test_nova_helper.py b/watcher/tests/common/test_nova_helper.py index 8e4664313..87c82e5fa 100644 --- a/watcher/tests/common/test_nova_helper.py +++ b/watcher/tests/common/test_nova_helper.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -42,7 +41,7 @@ CONF = conf.CONF class TestNovaHelper(base.TestCase): def setUp(self): - super(TestNovaHelper, self).setUp() + super().setUp() self.instance_uuid = "fb5311b7-37f3-457e-9cde-6494a3c59bfe" self.source_node = "ldev-indeedsrv005" self.destination_node = "ldev-indeedsrv006" diff --git a/watcher/tests/common/test_placement_helper.py b/watcher/tests/common/test_placement_helper.py index 5b7a18e2b..f04fc06fa 100644 --- a/watcher/tests/common/test_placement_helper.py +++ b/watcher/tests/common/test_placement_helper.py @@ -29,7 +29,7 @@ CONF = cfg.CONF @mock.patch('keystoneauth1.session.Session.request') class TestPlacementHelper(base.TestCase): def setUp(self): - super(TestPlacementHelper, self).setUp() + super().setUp() _AUTH_CONF_GROUP = 'watcher_clients_auth' ka_loading.register_auth_conf_options(CONF, _AUTH_CONF_GROUP) ka_loading.register_session_conf_options(CONF, _AUTH_CONF_GROUP) diff --git a/watcher/tests/common/test_service.py b/watcher/tests/common/test_service.py index 8d8af59a1..ef3839107 100644 --- a/watcher/tests/common/test_service.py +++ b/watcher/tests/common/test_service.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,13 +26,13 @@ from watcher.tests import base CONF = cfg.CONF -class DummyEndpoint(object): +class DummyEndpoint: def __init__(self, messaging): self._messaging = messaging -class DummyManager(object): +class DummyManager: API_VERSION = '1.0' @@ -77,7 +76,7 @@ class TestServiceHeartbeat(base.TestCase): class TestService(base.TestCase): def setUp(self): - super(TestService, self).setUp() + super().setUp() @mock.patch.object(om.rpc.server, "RPCServer") def _test_start(self, m_handler): diff --git a/watcher/tests/conf/test_list_opts.py b/watcher/tests/conf/test_list_opts.py index 178ba7536..216c858b5 100644 --- a/watcher/tests/conf/test_list_opts.py +++ b/watcher/tests/conf/test_list_opts.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # Copyright (c) 2016 Intel Corp # @@ -28,7 +27,7 @@ from watcher.tests.decision_engine import fake_strategies class TestListOpts(base.TestCase): def setUp(self): - super(TestListOpts, self).setUp() + super().setUp() # These option groups will be registered using strings instead of # OptGroup objects this should be avoided if possible. self.none_objects = ['DEFAULT', 'watcher_clients_auth', @@ -56,7 +55,7 @@ class TestListOpts(base.TestCase): # OptGroup object for some exceptions this is not possible but # new groups should use OptGroup raise Exception( - "Invalid option group: {0} should be of type OptGroup not " + "Invalid option group: {} should be of type OptGroup not " "string.".format(section_name)) self.assertIn(section_name, expected_sections) diff --git a/watcher/tests/conf_fixture.py b/watcher/tests/conf_fixture.py index 952617cd9..908644480 100644 --- a/watcher/tests/conf_fixture.py +++ b/watcher/tests/conf_fixture.py @@ -24,7 +24,7 @@ class ConfFixture(conf_fixture.Config): """Fixture to manage conf settings.""" def setUp(self): - super(ConfFixture, self).setUp() + super().setUp() self.conf.set_default('connection', "sqlite://", group='database') self.conf.set_default('sqlite_synchronous', False, group='database') @@ -45,6 +45,6 @@ class ConfReloadFixture(ConfFixture): self.conf._parse_cli_opts = self._original_parse_cli_opts def setUp(self): - super(ConfReloadFixture, self).setUp() + super().setUp() self.conf._parse_cli_opts = self._fake_parser self.addCleanup(self._restore_parser) diff --git a/watcher/tests/db/base.py b/watcher/tests/db/base.py index 196fc75c0..41b57d189 100644 --- a/watcher/tests/db/base.py +++ b/watcher/tests/db/base.py @@ -56,7 +56,7 @@ class Database(fixtures.Fixture): db_migrate.stamp('head') def setUp(self): - super(Database, self).setUp() + super().setUp() with self.engine.connect() as conn: conn.connection.executescript(self._DB) self.addCleanup(self.engine.dispose) @@ -75,7 +75,7 @@ class DbTestCase(base.TestCase): # To use in-memory SQLite DB cfg.CONF.set_override("connection", "sqlite://", group="database") - super(DbTestCase, self).setUp() + super().setUp() self.dbapi = dbapi.get_instance() diff --git a/watcher/tests/db/test_action.py b/watcher/tests/db/test_action.py index cffc74910..d0b0793ad 100644 --- a/watcher/tests/db/test_action.py +++ b/watcher/tests/db/test_action.py @@ -31,7 +31,7 @@ class TestDbActionFilters(base.DbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(TestDbActionFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() diff --git a/watcher/tests/db/test_action_description.py b/watcher/tests/db/test_action_description.py index 4a6a9a5e7..56f412e93 100644 --- a/watcher/tests/db/test_action_description.py +++ b/watcher/tests/db/test_action_description.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +30,7 @@ class TestDbActionDescriptionFilters(base.DbTestCase): FAKE_TODAY = '2017-02-24T09:52:05.219414' def setUp(self): - super(TestDbActionDescriptionFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() @@ -93,9 +92,9 @@ class TestDbActionDescriptionFilters(base.DbTestCase): self.context, filters={'deleted': False}) self.assertEqual( - set([self.action_desc2['action_type'], - self.action_desc3['action_type']]), - set([r.action_type for r in res])) + {self.action_desc2['action_type'], + self.action_desc3['action_type']}, + {r.action_type for r in res}) def test_get_action_desc_list_filter_deleted_at_eq(self): self._soft_delete_action_descs() @@ -112,8 +111,8 @@ class TestDbActionDescriptionFilters(base.DbTestCase): self.context, filters={'deleted_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.action_desc2['id'], self.action_desc3['id']]), - set([r.id for r in res])) + {self.action_desc2['id'], self.action_desc3['id']}, + {r.id for r in res}) def test_get_action_desc_list_filter_deleted_at_lte(self): self._soft_delete_action_descs() @@ -122,8 +121,8 @@ class TestDbActionDescriptionFilters(base.DbTestCase): self.context, filters={'deleted_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.action_desc2['id'], self.action_desc3['id']]), - set([r.id for r in res])) + {self.action_desc2['id'], self.action_desc3['id']}, + {r.id for r in res}) def test_get_action_desc_list_filter_deleted_at_gt(self): self._soft_delete_action_descs() @@ -140,8 +139,8 @@ class TestDbActionDescriptionFilters(base.DbTestCase): self.context, filters={'deleted_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.action_desc1['id'], self.action_desc2['id']]), - set([r.id for r in res])) + {self.action_desc1['id'], self.action_desc2['id']}, + {r.id for r in res}) # created_at # @@ -156,16 +155,16 @@ class TestDbActionDescriptionFilters(base.DbTestCase): self.context, filters={'created_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.action_desc2['id'], self.action_desc3['id']]), - set([r.id for r in res])) + {self.action_desc2['id'], self.action_desc3['id']}, + {r.id for r in res}) def test_get_action_desc_list_filter_created_at_lte(self): res = self.dbapi.get_action_description_list( self.context, filters={'created_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.action_desc2['id'], self.action_desc3['id']]), - set([r.id for r in res])) + {self.action_desc2['id'], self.action_desc3['id']}, + {r.id for r in res}) def test_get_action_desc_list_filter_created_at_gt(self): res = self.dbapi.get_action_description_list( @@ -178,8 +177,8 @@ class TestDbActionDescriptionFilters(base.DbTestCase): self.context, filters={'created_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.action_desc1['id'], self.action_desc2['id']]), - set([r.id for r in res])) + {self.action_desc1['id'], self.action_desc2['id']}, + {r.id for r in res}) # updated_at # @@ -198,8 +197,8 @@ class TestDbActionDescriptionFilters(base.DbTestCase): self.context, filters={'updated_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.action_desc2['id'], self.action_desc3['id']]), - set([r.id for r in res])) + {self.action_desc2['id'], self.action_desc3['id']}, + {r.id for r in res}) def test_get_action_desc_list_filter_updated_at_lte(self): self._update_action_descs() @@ -208,8 +207,8 @@ class TestDbActionDescriptionFilters(base.DbTestCase): self.context, filters={'updated_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.action_desc2['id'], self.action_desc3['id']]), - set([r.id for r in res])) + {self.action_desc2['id'], self.action_desc3['id']}, + {r.id for r in res}) def test_get_action_desc_list_filter_updated_at_gt(self): self._update_action_descs() @@ -226,8 +225,8 @@ class TestDbActionDescriptionFilters(base.DbTestCase): self.context, filters={'updated_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.action_desc1['id'], self.action_desc2['id']]), - set([r.id for r in res])) + {self.action_desc1['id'], self.action_desc2['id']}, + {r.id for r in res}) class DbActionDescriptionTestCase(base.DbTestCase): @@ -238,7 +237,7 @@ class DbActionDescriptionTestCase(base.DbTestCase): action_desc = utils.create_test_action_desc( id=i, action_type="action_%s" % i, - description="description_{0}".format(i)) + description="description_{}".format(i)) ids.append(action_desc['id']) action_descs = self.dbapi.get_action_description_list(self.context) action_desc_ids = [s.id for s in action_descs] diff --git a/watcher/tests/db/test_action_plan.py b/watcher/tests/db/test_action_plan.py index ff9d4ef77..db926dfaa 100644 --- a/watcher/tests/db/test_action_plan.py +++ b/watcher/tests/db/test_action_plan.py @@ -31,7 +31,7 @@ class TestDbActionPlanFilters(base.DbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(TestDbActionPlanFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() diff --git a/watcher/tests/db/test_audit.py b/watcher/tests/db/test_audit.py index bb10436f1..7417a0874 100644 --- a/watcher/tests/db/test_audit.py +++ b/watcher/tests/db/test_audit.py @@ -31,7 +31,7 @@ class TestDbAuditFilters(base.DbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(TestDbAuditFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() @@ -271,7 +271,7 @@ class DbAuditTestCase(base.DbTestCase): uuids = [] for id_ in range(1, 4): audit = utils.create_test_audit(uuid=w_utils.generate_uuid(), - name='My Audit {0}'.format(id_)) + name='My Audit {}'.format(id_)) uuids.append(str(audit['uuid'])) audits = self.dbapi.get_audit_list(self.context) audit_uuids = [a.uuid for a in audits] @@ -290,7 +290,7 @@ class DbAuditTestCase(base.DbTestCase): for i in range(1, 4): audit = utils.create_test_audit( id=i, uuid=w_utils.generate_uuid(), - name='My Audit {0}'.format(i), + name='My Audit {}'.format(i), goal_id=goal.id, strategy_id=strategy.id) uuids.append(str(audit['uuid'])) audits = self.dbapi.get_audit_list(self.context, eager=True) @@ -307,21 +307,21 @@ class DbAuditTestCase(base.DbTestCase): id=1, audit_type=objects.audit.AuditType.ONESHOT.value, uuid=w_utils.generate_uuid(), - name='My Audit {0}'.format(1), + name='My Audit {}'.format(1), state=objects.audit.State.ONGOING, goal_id=goal['id']) audit2 = utils.create_test_audit( id=2, audit_type=objects.audit.AuditType.CONTINUOUS.value, uuid=w_utils.generate_uuid(), - name='My Audit {0}'.format(2), + name='My Audit {}'.format(2), state=objects.audit.State.PENDING, goal_id=goal['id']) audit3 = utils.create_test_audit( id=3, audit_type=objects.audit.AuditType.CONTINUOUS.value, uuid=w_utils.generate_uuid(), - name='My Audit {0}'.format(3), + name='My Audit {}'.format(3), state=objects.audit.State.ONGOING, goal_id=goal['id']) diff --git a/watcher/tests/db/test_audit_template.py b/watcher/tests/db/test_audit_template.py index 2df21d6d4..d88843c46 100644 --- a/watcher/tests/db/test_audit_template.py +++ b/watcher/tests/db/test_audit_template.py @@ -30,7 +30,7 @@ class TestDbAuditTemplateFilters(base.DbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(TestDbAuditTemplateFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() @@ -233,7 +233,7 @@ class DbAuditTemplateTestCase(base.DbTestCase): audit_template = utils.create_test_audit_template( id=i, uuid=w_utils.generate_uuid(), - name='My Audit Template {0}'.format(i)) + name='My Audit Template {}'.format(i)) uuids.append(str(audit_template['uuid'])) audit_templates = self.dbapi.get_audit_template_list(self.context) audit_template_uuids = [at.uuid for at in audit_templates] @@ -252,7 +252,7 @@ class DbAuditTemplateTestCase(base.DbTestCase): for i in range(1, 4): audit_template = utils.create_test_audit_template( id=i, uuid=w_utils.generate_uuid(), - name='My Audit Template {0}'.format(i), + name='My Audit Template {}'.format(i), goal_id=goal.id, strategy_id=strategy.id) uuids.append(str(audit_template['uuid'])) audit_templates = self.dbapi.get_audit_template_list( diff --git a/watcher/tests/db/test_efficacy_indicator.py b/watcher/tests/db/test_efficacy_indicator.py index aa39fd437..30e73b49c 100644 --- a/watcher/tests/db/test_efficacy_indicator.py +++ b/watcher/tests/db/test_efficacy_indicator.py @@ -31,7 +31,7 @@ class TestDbEfficacyIndicatorFilters(base.DbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(TestDbEfficacyIndicatorFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() @@ -418,7 +418,7 @@ class MySQLDbEfficacyIndicatorTestCase(base.MySQLDbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(MySQLDbEfficacyIndicatorTestCase, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() diff --git a/watcher/tests/db/test_goal.py b/watcher/tests/db/test_goal.py index 3e995be06..078006a43 100644 --- a/watcher/tests/db/test_goal.py +++ b/watcher/tests/db/test_goal.py @@ -30,7 +30,7 @@ class TestDbGoalFilters(base.DbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(TestDbGoalFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() @@ -84,8 +84,8 @@ class TestDbGoalFilters(base.DbTestCase): self.context, filters={'deleted': False}) self.assertEqual( - set([self.goal2.uuid, self.goal3.uuid]), - set([r.uuid for r in res])) + {self.goal2.uuid, self.goal3.uuid}, + {r.uuid for r in res}) def test_get_goal_list_filter_deleted_at_eq(self): self._soft_delete_goals() @@ -102,8 +102,8 @@ class TestDbGoalFilters(base.DbTestCase): self.context, filters={'deleted_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.goal2.uuid, self.goal3.uuid]), - set([r.uuid for r in res])) + {self.goal2.uuid, self.goal3.uuid}, + {r.uuid for r in res}) def test_get_goal_list_filter_deleted_at_lte(self): self._soft_delete_goals() @@ -112,8 +112,8 @@ class TestDbGoalFilters(base.DbTestCase): self.context, filters={'deleted_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.goal2.uuid, self.goal3.uuid]), - set([r.uuid for r in res])) + {self.goal2.uuid, self.goal3.uuid}, + {r.uuid for r in res}) def test_get_goal_list_filter_deleted_at_gt(self): self._soft_delete_goals() @@ -130,8 +130,8 @@ class TestDbGoalFilters(base.DbTestCase): self.context, filters={'deleted_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.goal1.uuid, self.goal2.uuid]), - set([r.uuid for r in res])) + {self.goal1.uuid, self.goal2.uuid}, + {r.uuid for r in res}) # created_at # @@ -146,16 +146,16 @@ class TestDbGoalFilters(base.DbTestCase): self.context, filters={'created_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.goal2.uuid, self.goal3.uuid]), - set([r.uuid for r in res])) + {self.goal2.uuid, self.goal3.uuid}, + {r.uuid for r in res}) def test_get_goal_list_filter_created_at_lte(self): res = self.dbapi.get_goal_list( self.context, filters={'created_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.goal2.uuid, self.goal3.uuid]), - set([r.uuid for r in res])) + {self.goal2.uuid, self.goal3.uuid}, + {r.uuid for r in res}) def test_get_goal_list_filter_created_at_gt(self): res = self.dbapi.get_goal_list( @@ -168,8 +168,8 @@ class TestDbGoalFilters(base.DbTestCase): self.context, filters={'created_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.goal1.uuid, self.goal2.uuid]), - set([r.uuid for r in res])) + {self.goal1.uuid, self.goal2.uuid}, + {r.uuid for r in res}) # updated_at # @@ -188,8 +188,8 @@ class TestDbGoalFilters(base.DbTestCase): self.context, filters={'updated_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.goal2.uuid, self.goal3.uuid]), - set([r.uuid for r in res])) + {self.goal2.uuid, self.goal3.uuid}, + {r.uuid for r in res}) def test_get_goal_list_filter_updated_at_lte(self): self._update_goals() @@ -198,8 +198,8 @@ class TestDbGoalFilters(base.DbTestCase): self.context, filters={'updated_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.goal2.uuid, self.goal3.uuid]), - set([r.uuid for r in res])) + {self.goal2.uuid, self.goal3.uuid}, + {r.uuid for r in res}) def test_get_goal_list_filter_updated_at_gt(self): self._update_goals() @@ -216,8 +216,8 @@ class TestDbGoalFilters(base.DbTestCase): self.context, filters={'updated_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.goal1.uuid, self.goal2.uuid]), - set([r.uuid for r in res])) + {self.goal1.uuid, self.goal2.uuid}, + {r.uuid for r in res}) class DbGoalTestCase(base.DbTestCase): diff --git a/watcher/tests/db/test_migrations.py b/watcher/tests/db/test_migrations.py index 1637e68d7..4ce051180 100644 --- a/watcher/tests/db/test_migrations.py +++ b/watcher/tests/db/test_migrations.py @@ -56,7 +56,7 @@ class MySQLDbMigrationsTestCase(test_fixtures.OpportunisticDBTestMixin, self.engine = enginefacade.writer.get_engine() self.dbapi = dbapi.get_instance() self.alembic_config = migration._alembic_config() - self.revisions_tested = set(["15f7375ca737", "7150a7d8f228"]) + self.revisions_tested = {"15f7375ca737", "7150a7d8f228"} def _apply_migration(self, connection, revision): if revision not in self.revisions_tested: diff --git a/watcher/tests/db/test_purge.py b/watcher/tests/db/test_purge.py index 5d7698fe5..f9a75fdbc 100644 --- a/watcher/tests/db/test_purge.py +++ b/watcher/tests/db/test_purge.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +30,7 @@ from watcher.tests.objects import utils as obj_utils class TestPurgeCommand(base.DbTestCase): def setUp(self): - super(TestPurgeCommand, self).setUp() + super().setUp() self.cmd = purge.PurgeCommand() token_info = { 'token': { @@ -335,8 +334,8 @@ class TestPurgeCommand(base.DbTestCase): self.assertEqual(len(objects_map.action_plans), 3) self.assertEqual(len(objects_map.actions), 3) self.assertEqual( - set([self.action1.id, action4.id, action5.id]), - set([entry.id for entry in objects_map.actions])) + {self.action1.id, action4.id, action5.id}, + {entry.id for entry in objects_map.actions}) @mock.patch.object(dbapi.Connection, "destroy_action") @mock.patch.object(dbapi.Connection, "destroy_action_plan") diff --git a/watcher/tests/db/test_scoring_engine.py b/watcher/tests/db/test_scoring_engine.py index 8e8b414ba..ad759119e 100644 --- a/watcher/tests/db/test_scoring_engine.py +++ b/watcher/tests/db/test_scoring_engine.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +31,7 @@ class TestDbScoringEngineFilters(base.DbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(TestDbScoringEngineFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() @@ -89,8 +88,8 @@ class TestDbScoringEngineFilters(base.DbTestCase): self.context, filters={'deleted': False}) self.assertEqual( - set([self.scoring_engine2['id'], self.scoring_engine3['id']]), - set([r.id for r in res])) + {self.scoring_engine2['id'], self.scoring_engine3['id']}, + {r.id for r in res}) def test_get_scoring_engine_list_filter_deleted_at_eq(self): self._soft_delete_scoring_engines() @@ -107,8 +106,8 @@ class TestDbScoringEngineFilters(base.DbTestCase): self.context, filters={'deleted_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.scoring_engine2['id'], self.scoring_engine3['id']]), - set([r.id for r in res])) + {self.scoring_engine2['id'], self.scoring_engine3['id']}, + {r.id for r in res}) def test_get_scoring_engine_list_filter_deleted_at_lte(self): self._soft_delete_scoring_engines() @@ -117,8 +116,8 @@ class TestDbScoringEngineFilters(base.DbTestCase): self.context, filters={'deleted_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.scoring_engine2['id'], self.scoring_engine3['id']]), - set([r.id for r in res])) + {self.scoring_engine2['id'], self.scoring_engine3['id']}, + {r.id for r in res}) def test_get_scoring_engine_list_filter_deleted_at_gt(self): self._soft_delete_scoring_engines() @@ -135,8 +134,8 @@ class TestDbScoringEngineFilters(base.DbTestCase): self.context, filters={'deleted_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.scoring_engine1['id'], self.scoring_engine2['id']]), - set([r.id for r in res])) + {self.scoring_engine1['id'], self.scoring_engine2['id']}, + {r.id for r in res}) # created_at # @@ -151,16 +150,16 @@ class TestDbScoringEngineFilters(base.DbTestCase): self.context, filters={'created_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.scoring_engine2['id'], self.scoring_engine3['id']]), - set([r.id for r in res])) + {self.scoring_engine2['id'], self.scoring_engine3['id']}, + {r.id for r in res}) def test_get_scoring_engine_list_filter_created_at_lte(self): res = self.dbapi.get_scoring_engine_list( self.context, filters={'created_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.scoring_engine2['id'], self.scoring_engine3['id']]), - set([r.id for r in res])) + {self.scoring_engine2['id'], self.scoring_engine3['id']}, + {r.id for r in res}) def test_get_scoring_engine_list_filter_created_at_gt(self): res = self.dbapi.get_scoring_engine_list( @@ -173,8 +172,8 @@ class TestDbScoringEngineFilters(base.DbTestCase): self.context, filters={'created_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.scoring_engine1['id'], self.scoring_engine2['id']]), - set([r.id for r in res])) + {self.scoring_engine1['id'], self.scoring_engine2['id']}, + {r.id for r in res}) # updated_at # @@ -193,8 +192,8 @@ class TestDbScoringEngineFilters(base.DbTestCase): self.context, filters={'updated_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.scoring_engine2['id'], self.scoring_engine3['id']]), - set([r.id for r in res])) + {self.scoring_engine2['id'], self.scoring_engine3['id']}, + {r.id for r in res}) def test_get_scoring_engine_list_filter_updated_at_lte(self): self._update_scoring_engines() @@ -203,8 +202,8 @@ class TestDbScoringEngineFilters(base.DbTestCase): self.context, filters={'updated_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.scoring_engine2['id'], self.scoring_engine3['id']]), - set([r.id for r in res])) + {self.scoring_engine2['id'], self.scoring_engine3['id']}, + {r.id for r in res}) def test_get_scoring_engine_list_filter_updated_at_gt(self): self._update_scoring_engines() @@ -221,8 +220,8 @@ class TestDbScoringEngineFilters(base.DbTestCase): self.context, filters={'updated_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.scoring_engine1['id'], self.scoring_engine2['id']]), - set([r.id for r in res])) + {self.scoring_engine1['id'], self.scoring_engine2['id']}, + {r.id for r in res}) class DbScoringEngineTestCase(base.DbTestCase): @@ -234,7 +233,7 @@ class DbScoringEngineTestCase(base.DbTestCase): id=i, uuid=w_utils.generate_uuid(), name="SE_ID_%s" % i, - description='My ScoringEngine {0}'.format(i), + description='My ScoringEngine {}'.format(i), metainfo='a{0}=b{0}'.format(i)) names.append(str(scoring_engine['name'])) scoring_engines = self.dbapi.get_scoring_engine_list(self.context) diff --git a/watcher/tests/db/test_service.py b/watcher/tests/db/test_service.py index 9f8d9200e..68a2e5f03 100644 --- a/watcher/tests/db/test_service.py +++ b/watcher/tests/db/test_service.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -33,7 +32,7 @@ class TestDbServiceFilters(base.DbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(TestDbServiceFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() @@ -91,8 +90,8 @@ class TestDbServiceFilters(base.DbTestCase): self.context, filters={'deleted': False}) self.assertEqual( - set([self.service2['name'], self.service3['name']]), - set([r.name for r in res])) + {self.service2['name'], self.service3['name']}, + {r.name for r in res}) def test_get_service_list_filter_deleted_at_eq(self): self._soft_delete_services() @@ -109,8 +108,8 @@ class TestDbServiceFilters(base.DbTestCase): self.context, filters={'deleted_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.service2['id'], self.service3['id']]), - set([r.id for r in res])) + {self.service2['id'], self.service3['id']}, + {r.id for r in res}) def test_get_service_list_filter_deleted_at_lte(self): self._soft_delete_services() @@ -119,8 +118,8 @@ class TestDbServiceFilters(base.DbTestCase): self.context, filters={'deleted_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.service2['id'], self.service3['id']]), - set([r.id for r in res])) + {self.service2['id'], self.service3['id']}, + {r.id for r in res}) def test_get_service_list_filter_deleted_at_gt(self): self._soft_delete_services() @@ -137,8 +136,8 @@ class TestDbServiceFilters(base.DbTestCase): self.context, filters={'deleted_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.service1['id'], self.service2['id']]), - set([r.id for r in res])) + {self.service1['id'], self.service2['id']}, + {r.id for r in res}) # created_at # @@ -153,16 +152,16 @@ class TestDbServiceFilters(base.DbTestCase): self.context, filters={'created_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.service2['id'], self.service3['id']]), - set([r.id for r in res])) + {self.service2['id'], self.service3['id']}, + {r.id for r in res}) def test_get_service_list_filter_created_at_lte(self): res = self.dbapi.get_service_list( self.context, filters={'created_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.service2['id'], self.service3['id']]), - set([r.id for r in res])) + {self.service2['id'], self.service3['id']}, + {r.id for r in res}) def test_get_service_list_filter_created_at_gt(self): res = self.dbapi.get_service_list( @@ -175,8 +174,8 @@ class TestDbServiceFilters(base.DbTestCase): self.context, filters={'created_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.service1['id'], self.service2['id']]), - set([r.id for r in res])) + {self.service1['id'], self.service2['id']}, + {r.id for r in res}) # updated_at # @@ -195,8 +194,8 @@ class TestDbServiceFilters(base.DbTestCase): self.context, filters={'updated_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.service2['id'], self.service3['id']]), - set([r.id for r in res])) + {self.service2['id'], self.service3['id']}, + {r.id for r in res}) def test_get_service_list_filter_updated_at_lte(self): self._update_services() @@ -205,8 +204,8 @@ class TestDbServiceFilters(base.DbTestCase): self.context, filters={'updated_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.service2['id'], self.service3['id']]), - set([r.id for r in res])) + {self.service2['id'], self.service3['id']}, + {r.id for r in res}) def test_get_service_list_filter_updated_at_gt(self): self._update_services() @@ -223,8 +222,8 @@ class TestDbServiceFilters(base.DbTestCase): self.context, filters={'updated_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.service1['id'], self.service2['id']]), - set([r.id for r in res])) + {self.service1['id'], self.service2['id']}, + {r.id for r in res}) class DbServiceTestCase(base.DbTestCase): @@ -235,7 +234,7 @@ class DbServiceTestCase(base.DbTestCase): service = utils.create_test_service( id=i, name="SERVICE_ID_%s" % i, - host="controller_{0}".format(i)) + host="controller_{}".format(i)) ids.append(service['id']) services = self.dbapi.get_service_list(self.context) service_ids = [s.id for s in services] diff --git a/watcher/tests/db/test_strategy.py b/watcher/tests/db/test_strategy.py index 8cab238d9..90329e7cf 100644 --- a/watcher/tests/db/test_strategy.py +++ b/watcher/tests/db/test_strategy.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -32,7 +31,7 @@ class TestDbStrategyFilters(base.DbTestCase): FAKE_TODAY = '2016-02-24T09:52:05.219414' def setUp(self): - super(TestDbStrategyFilters, self).setUp() + super().setUp() self.context.show_deleted = True self._data_setup() @@ -100,8 +99,8 @@ class TestDbStrategyFilters(base.DbTestCase): self.context, filters={'deleted': False}) self.assertEqual( - set([self.strategy2['uuid'], self.strategy3['uuid']]), - set([r.uuid for r in res])) + {self.strategy2['uuid'], self.strategy3['uuid']}, + {r.uuid for r in res}) def test_get_strategy_list_filter_deleted_at_eq(self): self._soft_delete_strategys() @@ -118,8 +117,8 @@ class TestDbStrategyFilters(base.DbTestCase): self.context, filters={'deleted_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.strategy2['uuid'], self.strategy3['uuid']]), - set([r.uuid for r in res])) + {self.strategy2['uuid'], self.strategy3['uuid']}, + {r.uuid for r in res}) def test_get_strategy_list_filter_deleted_at_lte(self): self._soft_delete_strategys() @@ -128,8 +127,8 @@ class TestDbStrategyFilters(base.DbTestCase): self.context, filters={'deleted_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.strategy2['uuid'], self.strategy3['uuid']]), - set([r.uuid for r in res])) + {self.strategy2['uuid'], self.strategy3['uuid']}, + {r.uuid for r in res}) def test_get_strategy_list_filter_deleted_at_gt(self): self._soft_delete_strategys() @@ -146,8 +145,8 @@ class TestDbStrategyFilters(base.DbTestCase): self.context, filters={'deleted_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.strategy1['uuid'], self.strategy2['uuid']]), - set([r.uuid for r in res])) + {self.strategy1['uuid'], self.strategy2['uuid']}, + {r.uuid for r in res}) # created_at # @@ -162,16 +161,16 @@ class TestDbStrategyFilters(base.DbTestCase): self.context, filters={'created_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.strategy2['uuid'], self.strategy3['uuid']]), - set([r.uuid for r in res])) + {self.strategy2['uuid'], self.strategy3['uuid']}, + {r.uuid for r in res}) def test_get_strategy_list_filter_created_at_lte(self): res = self.dbapi.get_strategy_list( self.context, filters={'created_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.strategy2['uuid'], self.strategy3['uuid']]), - set([r.uuid for r in res])) + {self.strategy2['uuid'], self.strategy3['uuid']}, + {r.uuid for r in res}) def test_get_strategy_list_filter_created_at_gt(self): res = self.dbapi.get_strategy_list( @@ -184,8 +183,8 @@ class TestDbStrategyFilters(base.DbTestCase): self.context, filters={'created_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.strategy1['uuid'], self.strategy2['uuid']]), - set([r.uuid for r in res])) + {self.strategy1['uuid'], self.strategy2['uuid']}, + {r.uuid for r in res}) # updated_at # @@ -204,8 +203,8 @@ class TestDbStrategyFilters(base.DbTestCase): self.context, filters={'updated_at__lt': self.FAKE_TODAY}) self.assertEqual( - set([self.strategy2['uuid'], self.strategy3['uuid']]), - set([r.uuid for r in res])) + {self.strategy2['uuid'], self.strategy3['uuid']}, + {r.uuid for r in res}) def test_get_strategy_list_filter_updated_at_lte(self): self._update_strategies() @@ -214,8 +213,8 @@ class TestDbStrategyFilters(base.DbTestCase): self.context, filters={'updated_at__lte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.strategy2['uuid'], self.strategy3['uuid']]), - set([r.uuid for r in res])) + {self.strategy2['uuid'], self.strategy3['uuid']}, + {r.uuid for r in res}) def test_get_strategy_list_filter_updated_at_gt(self): self._update_strategies() @@ -232,8 +231,8 @@ class TestDbStrategyFilters(base.DbTestCase): self.context, filters={'updated_at__gte': self.FAKE_OLD_DATE}) self.assertEqual( - set([self.strategy1['uuid'], self.strategy2['uuid']]), - set([r.uuid for r in res])) + {self.strategy1['uuid'], self.strategy2['uuid']}, + {r.uuid for r in res}) class DbStrategyTestCase(base.DbTestCase): @@ -245,7 +244,7 @@ class DbStrategyTestCase(base.DbTestCase): id=i, uuid=w_utils.generate_uuid(), name="STRATEGY_ID_%s" % i, - display_name='My Strategy {0}'.format(i)) + display_name='My Strategy {}'.format(i)) uuids.append(str(strategy['uuid'])) strategies = self.dbapi.get_strategy_list(self.context) strategy_uuids = [s.uuid for s in strategies] @@ -262,7 +261,7 @@ class DbStrategyTestCase(base.DbTestCase): id=i, uuid=w_utils.generate_uuid(), name="STRATEGY_ID_%s" % i, - display_name='My Strategy {0}'.format(i), + display_name='My Strategy {}'.format(i), goal_id=goal.id) uuids.append(str(strategy['uuid'])) strategys = self.dbapi.get_strategy_list(self.context, eager=True) diff --git a/watcher/tests/decision_engine/audit/test_audit_handlers.py b/watcher/tests/decision_engine/audit/test_audit_handlers.py index 79f06976e..4a409937a 100644 --- a/watcher/tests/decision_engine/audit/test_audit_handlers.py +++ b/watcher/tests/decision_engine/audit/test_audit_handlers.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -42,7 +41,7 @@ from watcher.tests.objects import utils as obj_utils class TestOneShotAuditHandler(base.DbTestCase): def setUp(self): - super(TestOneShotAuditHandler, self).setUp() + super().setUp() p_audit_notifications = mock.patch.object( notifications, 'audit', autospec=True) self.m_audit_notifications = p_audit_notifications.start() @@ -168,7 +167,7 @@ class TestOneShotAuditHandler(base.DbTestCase): class TestAutoTriggerActionPlan(base.DbTestCase): def setUp(self): - super(TestAutoTriggerActionPlan, self).setUp() + super().setUp() self.goal = obj_utils.create_test_goal( self.context, id=1, name=dummy_strategy.DummyStrategy.get_name()) self.strategy = obj_utils.create_test_strategy( @@ -239,7 +238,7 @@ class TestAutoTriggerActionPlan(base.DbTestCase): class TestContinuousAuditHandler(base.DbTestCase): def setUp(self): - super(TestContinuousAuditHandler, self).setUp() + super().setUp() p_audit_notifications = mock.patch.object( notifications, 'audit', autospec=True) self.m_audit_notifications = p_audit_notifications.start() @@ -253,7 +252,7 @@ class TestContinuousAuditHandler(base.DbTestCase): obj_utils.create_test_audit( self.context, id=id_, - name='My Audit {0}'.format(id_), + name='My Audit {}'.format(id_), uuid=uuidutils.generate_uuid(), audit_template_id=audit_template.id, goal_id=self.goal.id, diff --git a/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py b/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py index 0d9a75324..576a776a9 100644 --- a/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py +++ b/watcher/tests/decision_engine/cluster/test_cinder_cdmc.py @@ -23,7 +23,7 @@ from watcher.tests import conf_fixture class TestCinderClusterDataModelCollector(base.TestCase): def setUp(self): - super(TestCinderClusterDataModelCollector, self).setUp() + super().setUp() self.useFixture(conf_fixture.ConfReloadFixture()) @mock.patch('keystoneclient.v3.client.Client', mock.Mock()) diff --git a/watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py b/watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py index c3df1b183..05c334c40 100644 --- a/watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py +++ b/watcher/tests/decision_engine/cluster/test_cluster_data_model_collector.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/cluster/test_nova_cdmc.py b/watcher/tests/decision_engine/cluster/test_nova_cdmc.py index cb76d0197..829705578 100644 --- a/watcher/tests/decision_engine/cluster/test_nova_cdmc.py +++ b/watcher/tests/decision_engine/cluster/test_nova_cdmc.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -32,7 +31,7 @@ from watcher.tests import conf_fixture class TestNovaClusterDataModelCollector(base.TestCase): def setUp(self): - super(TestNovaClusterDataModelCollector, self).setUp() + super().setUp() self.useFixture(conf_fixture.ConfReloadFixture()) @mock.patch('keystoneclient.v3.client.Client', mock.Mock()) @@ -360,7 +359,7 @@ class TestNovaModelBuilder(base.TestCase): result = set() t_nova_cluster._collect_aggregates(m_scope, result) - self.assertEqual(set(['hostone', 'hosttwo']), result) + self.assertEqual({'hostone', 'hosttwo'}, result) @mock.patch.object(nova_helper, 'NovaHelper') def test_collect_aggregates_none(self, m_nova): @@ -387,7 +386,7 @@ class TestNovaModelBuilder(base.TestCase): result = set() t_nova_cluster._collect_zones(m_scope, result) - self.assertEqual(set(['hostone']), result) + self.assertEqual({'hostone'}, result) @mock.patch.object(nova_helper, 'NovaHelper') def test_collect_zones_none(self, m_nova): diff --git a/watcher/tests/decision_engine/datasources/grafana_translators/test_base.py b/watcher/tests/decision_engine/datasources/grafana_translators/test_base.py index 5393402ba..484107b14 100644 --- a/watcher/tests/decision_engine/datasources/grafana_translators/test_base.py +++ b/watcher/tests/decision_engine/datasources/grafana_translators/test_base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken @@ -39,7 +38,7 @@ class TestGrafanaTranslatorBase(base.BaseTestCase): """ def setUp(self): - super(TestGrafanaTranslatorBase, self).setUp() + super().setUp() """Basic valid reference data""" self.reference_data = { @@ -64,7 +63,7 @@ class TestBaseGrafanaTranslator(TestGrafanaTranslatorBase): """ def setUp(self): - super(TestBaseGrafanaTranslator, self).setUp() + super().setUp() def test_validate_data(self): """Initialize InfluxDBGrafanaTranslator and check data validation""" diff --git a/watcher/tests/decision_engine/datasources/grafana_translators/test_influxdb.py b/watcher/tests/decision_engine/datasources/grafana_translators/test_influxdb.py index 204387804..7ed0e7c51 100644 --- a/watcher/tests/decision_engine/datasources/grafana_translators/test_influxdb.py +++ b/watcher/tests/decision_engine/datasources/grafana_translators/test_influxdb.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken @@ -40,7 +39,7 @@ class TestInfluxDBGrafanaTranslator(test_base.TestGrafanaTranslatorBase): """ def setUp(self): - super(TestInfluxDBGrafanaTranslator, self).setUp() + super().setUp() self.p_conf = mock.patch.object( influxdb, 'CONF', diff --git a/watcher/tests/decision_engine/datasources/test_aetos_helper.py b/watcher/tests/decision_engine/datasources/test_aetos_helper.py index 35d30b16a..936e212ad 100644 --- a/watcher/tests/decision_engine/datasources/test_aetos_helper.py +++ b/watcher/tests/decision_engine/datasources/test_aetos_helper.py @@ -23,7 +23,7 @@ from watcher.tests import base class TestAetosHelper(base.BaseTestCase): def setUp(self): - super(TestAetosHelper, self).setUp() + super().setUp() with mock.patch.object( aetos_helper.AetosHelper, '_setup_prometheus_client' ): diff --git a/watcher/tests/decision_engine/datasources/test_base.py b/watcher/tests/decision_engine/datasources/test_base.py index 6449134dd..579024919 100644 --- a/watcher/tests/decision_engine/datasources/test_base.py +++ b/watcher/tests/decision_engine/datasources/test_base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken diff --git a/watcher/tests/decision_engine/datasources/test_gnocchi_helper.py b/watcher/tests/decision_engine/datasources/test_gnocchi_helper.py index 04364e74c..f0b00f516 100644 --- a/watcher/tests/decision_engine/datasources/test_gnocchi_helper.py +++ b/watcher/tests/decision_engine/datasources/test_gnocchi_helper.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +29,7 @@ CONF = cfg.CONF class TestGnocchiHelper(base.BaseTestCase): def setUp(self): - super(TestGnocchiHelper, self).setUp() + super().setUp() self.osc_mock = mock.Mock() self.helper = gnocchi_helper.GnocchiHelper(osc=self.osc_mock) stat_agg_patcher = mock.patch.object( @@ -207,7 +206,7 @@ class TestGnocchiHelper(base.BaseTestCase): def test_gnocchi_list_metrics(self, mock_gnocchi): gnocchi = mock.MagicMock() metrics = [{"name": "metric1"}, {"name": "metric2"}] - expected_metrics = set(["metric1", "metric2"]) + expected_metrics = {"metric1", "metric2"} gnocchi.metric.list.return_value = metrics mock_gnocchi.return_value = gnocchi helper = gnocchi_helper.GnocchiHelper() diff --git a/watcher/tests/decision_engine/datasources/test_grafana_helper.py b/watcher/tests/decision_engine/datasources/test_grafana_helper.py index 565896c23..737170ac6 100644 --- a/watcher/tests/decision_engine/datasources/test_grafana_helper.py +++ b/watcher/tests/decision_engine/datasources/test_grafana_helper.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken @@ -43,7 +42,7 @@ class TestGrafana(base.BaseTestCase): """ def setUp(self): - super(TestGrafana, self).setUp() + super().setUp() self.p_conf = mock.patch.object( grafana, 'CONF', diff --git a/watcher/tests/decision_engine/datasources/test_manager.py b/watcher/tests/decision_engine/datasources/test_manager.py index cfdf5e219..7bf5221de 100644 --- a/watcher/tests/decision_engine/datasources/test_manager.py +++ b/watcher/tests/decision_engine/datasources/test_manager.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/datasources/test_monasca_helper.py b/watcher/tests/decision_engine/datasources/test_monasca_helper.py index 0745f6c39..5da229576 100644 --- a/watcher/tests/decision_engine/datasources/test_monasca_helper.py +++ b/watcher/tests/decision_engine/datasources/test_monasca_helper.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,7 +38,7 @@ CONF = cfg.CONF class TestMonascaHelper(base.BaseTestCase): def setUp(self): - super(TestMonascaHelper, self).setUp() + super().setUp() self.osc_mock = mock.Mock() self.helper = monasca_helper.MonascaHelper(osc=self.osc_mock) stat_agg_patcher = mock.patch.object( diff --git a/watcher/tests/decision_engine/datasources/test_prometheus_base.py b/watcher/tests/decision_engine/datasources/test_prometheus_base.py index e9224b723..292a55eac 100644 --- a/watcher/tests/decision_engine/datasources/test_prometheus_base.py +++ b/watcher/tests/decision_engine/datasources/test_prometheus_base.py @@ -29,7 +29,7 @@ class TestPrometheusBase(base.BaseTestCase): """ def setUp(self): - super(TestPrometheusBase, self).setUp() + super().setUp() with ( mock.patch.object( @@ -297,10 +297,10 @@ class TestPrometheusBase(base.BaseTestCase): @mock.patch.object(prometheus_client.PrometheusAPIClient, '_get') def test_prometheus_list_metrics(self, mock_prometheus_get): - expected_metrics = set( - ['go_gc_duration_seconds', 'go_gc_duration_seconds_count', - 'go_gc_duration_seconds_sum', 'go_goroutines',] - ) + expected_metrics = { + 'go_gc_duration_seconds', 'go_gc_duration_seconds_count', + 'go_gc_duration_seconds_sum', 'go_goroutines' + } mock_prometheus_get.return_value = { 'status': 'success', 'data': [ 'go_gc_duration_seconds', 'go_gc_duration_seconds_count', diff --git a/watcher/tests/decision_engine/datasources/test_prometheus_helper.py b/watcher/tests/decision_engine/datasources/test_prometheus_helper.py index 3bac66871..ed2fea607 100644 --- a/watcher/tests/decision_engine/datasources/test_prometheus_helper.py +++ b/watcher/tests/decision_engine/datasources/test_prometheus_helper.py @@ -24,7 +24,7 @@ from watcher.tests import base class TestPrometheusHelper(base.BaseTestCase): def setUp(self): - super(TestPrometheusHelper, self).setUp() + super().setUp() cfg.CONF.prometheus_client.host = "foobarbaz" cfg.CONF.prometheus_client.port = "1234" diff --git a/watcher/tests/decision_engine/fake_goals.py b/watcher/tests/decision_engine/fake_goals.py index 19d51095d..d6291a5da 100644 --- a/watcher/tests/decision_engine/fake_goals.py +++ b/watcher/tests/decision_engine/fake_goals.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,7 +44,7 @@ class FakeGoal(base_goal.Goal): class DummyIndicator(indicators.IndicatorSpecification): def __init__(self): - super(DummyIndicator, self).__init__( + super().__init__( name="dummy", description="Dummy indicator", unit="%", diff --git a/watcher/tests/decision_engine/fake_strategies.py b/watcher/tests/decision_engine/fake_strategies.py index 002290bcf..87725f2e2 100644 --- a/watcher/tests/decision_engine/fake_strategies.py +++ b/watcher/tests/decision_engine/fake_strategies.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/loading/test_collector_loader.py b/watcher/tests/decision_engine/loading/test_collector_loader.py index 403ebad92..423294afe 100644 --- a/watcher/tests/decision_engine/loading/test_collector_loader.py +++ b/watcher/tests/decision_engine/loading/test_collector_loader.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,7 +28,7 @@ from watcher.tests.decision_engine.model import faker_cluster_state class TestClusterDataModelCollectorLoader(base.TestCase): def setUp(self): - super(TestClusterDataModelCollectorLoader, self).setUp() + super().setUp() self.useFixture(conf_fixture.ConfReloadFixture()) self.collector_loader = ( default_loading.ClusterDataModelCollectorLoader()) @@ -73,7 +72,7 @@ class TestLoadClusterDataModelCollectors(base.TestCase): in collector_loader.list_available().items()] def setUp(self): - super(TestLoadClusterDataModelCollectors, self).setUp() + super().setUp() self.useFixture(conf_fixture.ConfReloadFixture()) @mock.patch.object(clients, 'OpenStackClients', mock.Mock()) diff --git a/watcher/tests/decision_engine/loading/test_default_planner_loader.py b/watcher/tests/decision_engine/loading/test_default_planner_loader.py index 0354da919..4ed58680e 100644 --- a/watcher/tests/decision_engine/loading/test_default_planner_loader.py +++ b/watcher/tests/decision_engine/loading/test_default_planner_loader.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,7 +20,7 @@ from watcher.tests import base class TestDefaultPlannerLoader(base.TestCase): def setUp(self): - super(TestDefaultPlannerLoader, self).setUp() + super().setUp() self.loader = default.DefaultPlannerLoader() def test_endpoints(self): diff --git a/watcher/tests/decision_engine/loading/test_default_strategy_loader.py b/watcher/tests/decision_engine/loading/test_default_strategy_loader.py index e544303b3..4cd3675fc 100644 --- a/watcher/tests/decision_engine/loading/test_default_strategy_loader.py +++ b/watcher/tests/decision_engine/loading/test_default_strategy_loader.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +25,7 @@ from watcher.tests import base class TestDefaultStrategyLoader(base.TestCase): def setUp(self): - super(TestDefaultStrategyLoader, self).setUp() + super().setUp() self.strategy_loader = default_loading.DefaultStrategyLoader() def test_load_strategy_with_empty_model(self): diff --git a/watcher/tests/decision_engine/loading/test_goal_loader.py b/watcher/tests/decision_engine/loading/test_goal_loader.py index d188aeaac..16eb0cfcf 100644 --- a/watcher/tests/decision_engine/loading/test_goal_loader.py +++ b/watcher/tests/decision_engine/loading/test_goal_loader.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +25,7 @@ from watcher.tests import base class TestDefaultGoalLoader(base.TestCase): def setUp(self): - super(TestDefaultGoalLoader, self).setUp() + super().setUp() self.goal_loader = default_loading.DefaultGoalLoader() def test_load_goal_with_empty_model(self): diff --git a/watcher/tests/decision_engine/messaging/test_audit_endpoint.py b/watcher/tests/decision_engine/messaging/test_audit_endpoint.py index 756b451f2..74b970e9a 100644 --- a/watcher/tests/decision_engine/messaging/test_audit_endpoint.py +++ b/watcher/tests/decision_engine/messaging/test_audit_endpoint.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +26,7 @@ from watcher.tests.objects import utils as obj_utils class TestAuditEndpoint(base.DbTestCase): def setUp(self): - super(TestAuditEndpoint, self).setUp() + super().setUp() self.goal = obj_utils.create_test_goal(self.context) self.audit_template = obj_utils.create_test_audit_template( self.context) diff --git a/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py b/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py index 9c63b5bff..3e31d4798 100644 --- a/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py +++ b/watcher/tests/decision_engine/messaging/test_data_model_endpoint.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2019 ZTE Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/model/faker_cluster_and_metrics.py b/watcher/tests/decision_engine/model/faker_cluster_and_metrics.py index 3ea1a12d1..cd42c0d75 100644 --- a/watcher/tests/decision_engine/model/faker_cluster_and_metrics.py +++ b/watcher/tests/decision_engine/model/faker_cluster_and_metrics.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Authors: Vojtech CIMA # Bruno GRAZIOLI @@ -30,7 +29,7 @@ class FakerModelCollector(base.BaseClusterDataModelCollector): def __init__(self, config=None, osc=None, audit_scope=None): if config is None: config = mock.Mock() - super(FakerModelCollector, self).__init__(config) + super().__init__(config) @property def notification_endpoints(self): @@ -80,7 +79,7 @@ class FakerModelCollector(base.BaseClusterDataModelCollector): return self.load_model('scenario_4_with_metrics.xml') -class FakeGnocchiMetrics(object): +class FakeGnocchiMetrics: def __init__(self, model): self.model = model diff --git a/watcher/tests/decision_engine/model/faker_cluster_state.py b/watcher/tests/decision_engine/model/faker_cluster_state.py index 26e1e3cb8..4f9703aa4 100644 --- a/watcher/tests/decision_engine/model/faker_cluster_state.py +++ b/watcher/tests/decision_engine/model/faker_cluster_state.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -39,7 +38,7 @@ class FakerModelCollector(base.BaseClusterDataModelCollector): def __init__(self, config=None, osc=None, audit_scope=None): if config is None: config = mock.Mock(period=777) - super(FakerModelCollector, self).__init__(config) + super().__init__(config) @property def notification_endpoints(self): @@ -75,8 +74,8 @@ class FakerModelCollector(base.BaseClusterDataModelCollector): instance_count = (node_count * node_instance_count) for id_ in range(0, node_count): - node_uuid = "Node_{0}".format(id_) - hostname = "hostname_{0}".format(id_) + node_uuid = "Node_{}".format(id_) + hostname = "hostname_{}".format(id_) node_attributes = { "id": id_, "uuid": node_uuid, @@ -96,7 +95,7 @@ class FakerModelCollector(base.BaseClusterDataModelCollector): model.add_node(node) for i in range(0, instance_count): - instance_uuid = "INSTANCE_{0}".format(i) + instance_uuid = "INSTANCE_{}".format(i) if instance_uuid == "INSTANCE_1": project_id = "26F03131-32CB-4697-9D61-9123F87A8147" elif instance_uuid == "INSTANCE_2": @@ -186,7 +185,7 @@ class FakerStorageModelCollector(base.BaseClusterDataModelCollector): def __init__(self, config=None, osc=None, audit_scope=None): if config is None: config = mock.Mock(period=777) - super(FakerStorageModelCollector, self).__init__(config) + super().__init__(config) @property def notification_endpoints(self): @@ -222,8 +221,8 @@ class FakerStorageModelCollector(base.BaseClusterDataModelCollector): for i in range(0, node_count): host = "host_{0}@backend_{0}".format(i) - zone = "zone_{0}".format(i) - volume_type = ["type_{0}".format(i)] + zone = "zone_{}".format(i) + volume_type = ["type_{}".format(i)] node_attributes = { "host": host, "zone": zone, @@ -275,7 +274,7 @@ class FakerStorageModelCollector(base.BaseClusterDataModelCollector): for k in range(volume_count): uuid = volume_uuid_mapping[k] - name = "name_{0}".format(k) + name = "name_{}".format(k) volume_attributes = { "size": 40, "status": "in-use", @@ -320,7 +319,7 @@ class FakerBaremetalModelCollector(base.BaseClusterDataModelCollector): def __init__(self, config=None, osc=None): if config is None: config = mock.Mock(period=777) - super(FakerBaremetalModelCollector, self).__init__(config) + super().__init__(config) @property def notification_endpoints(self): diff --git a/watcher/tests/decision_engine/model/gnocchi_metrics.py b/watcher/tests/decision_engine/model/gnocchi_metrics.py index 1ad7141f4..9e3d580f4 100644 --- a/watcher/tests/decision_engine/model/gnocchi_metrics.py +++ b/watcher/tests/decision_engine/model/gnocchi_metrics.py @@ -14,7 +14,7 @@ import oslo_utils -class FakeGnocchiMetrics(object): +class FakeGnocchiMetrics: NAME = 'gnocchi' def __init__(self): diff --git a/watcher/tests/decision_engine/model/monasca_metrics.py b/watcher/tests/decision_engine/model/monasca_metrics.py index b2362eed6..b96e4c9b2 100644 --- a/watcher/tests/decision_engine/model/monasca_metrics.py +++ b/watcher/tests/decision_engine/model/monasca_metrics.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -17,7 +16,7 @@ # limitations under the License. -class FakeMonascaMetrics(object): +class FakeMonascaMetrics: def __init__(self): self.emptytype = "" diff --git a/watcher/tests/decision_engine/model/notification/fake_managers.py b/watcher/tests/decision_engine/model/notification/fake_managers.py index ec3ebd384..693b3b376 100644 --- a/watcher/tests/decision_engine/model/notification/fake_managers.py +++ b/watcher/tests/decision_engine/model/notification/fake_managers.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py b/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py index 22c73429f..57fb583d7 100644 --- a/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py +++ b/watcher/tests/decision_engine/model/notification/test_cinder_notifications.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2017 NEC Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -50,7 +49,7 @@ class TestReceiveCinderNotifications(NotificationTestCase): FAKE_METADATA = {'message_id': None, 'timestamp': None} def setUp(self): - super(TestReceiveCinderNotifications, self).setUp() + super().setUp() p_from_dict = mock.patch.object(context.RequestContext, 'from_dict') m_from_dict = p_from_dict.start() @@ -169,7 +168,7 @@ class TestCinderNotifications(NotificationTestCase): FAKE_METADATA = {'message_id': None, 'timestamp': None} def setUp(self): - super(TestCinderNotifications, self).setUp() + super().setUp() # fake cluster self.fake_cdmc = faker_cluster_state.FakerStorageModelCollector() diff --git a/watcher/tests/decision_engine/model/notification/test_notifications.py b/watcher/tests/decision_engine/model/notification/test_notifications.py index 2be861b92..71dd342f5 100644 --- a/watcher/tests/decision_engine/model/notification/test_notifications.py +++ b/watcher/tests/decision_engine/model/notification/test_notifications.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -65,7 +64,7 @@ class NotificationTestCase(base_test.TestCase): class TestReceiveNotifications(NotificationTestCase): def setUp(self): - super(TestReceiveNotifications, self).setUp() + super().setUp() p_from_dict = mock.patch.object(context.RequestContext, 'from_dict') m_from_dict = p_from_dict.start() diff --git a/watcher/tests/decision_engine/model/notification/test_nova_notifications.py b/watcher/tests/decision_engine/model/notification/test_nova_notifications.py index 1d94f8fb2..b18da1d70 100644 --- a/watcher/tests/decision_engine/model/notification/test_nova_notifications.py +++ b/watcher/tests/decision_engine/model/notification/test_nova_notifications.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -82,7 +81,7 @@ class TestReceiveNovaNotifications(NotificationTestCase): } def setUp(self): - super(TestReceiveNovaNotifications, self).setUp() + super().setUp() p_from_dict = mock.patch.object(context.RequestContext, 'from_dict') m_from_dict = p_from_dict.start() @@ -117,7 +116,7 @@ class TestNovaNotifications(NotificationTestCase): FAKE_METADATA = {'message_id': None, 'timestamp': None} def setUp(self): - super(TestNovaNotifications, self).setUp() + super().setUp() # fake cluster self.fake_cdmc = faker_cluster_state.FakerModelCollector() diff --git a/watcher/tests/decision_engine/model/test_element.py b/watcher/tests/decision_engine/model/test_element.py index d7a060902..417dd0fae 100644 --- a/watcher/tests/decision_engine/model/test_element.py +++ b/watcher/tests/decision_engine/model/test_element.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/tests/decision_engine/model/test_model.py b/watcher/tests/decision_engine/model/test_model.py index a6c651668..501a5e97d 100644 --- a/watcher/tests/decision_engine/model/test_model.py +++ b/watcher/tests/decision_engine/model/test_model.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -98,12 +97,12 @@ class TestModel(base.TestCase): def test_get_node_by_instance_uuid(self): model = model_root.ModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) node = element.ComputeNode(id=1) node.uuid = uuid_ model.add_node(node) self.assertEqual(node, model.get_node_by_uuid(uuid_)) - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) instance = element.Instance(id=1) instance.uuid = uuid_ model.add_instance(instance) @@ -113,7 +112,7 @@ class TestModel(base.TestCase): def test_add_node(self): model = model_root.ModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) node = element.ComputeNode(id=1) node.uuid = uuid_ model.add_node(node) @@ -121,7 +120,7 @@ class TestModel(base.TestCase): def test_delete_node(self): model = model_root.ModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) node = element.ComputeNode(id=1) node.uuid = uuid_ model.add_node(node) @@ -133,7 +132,7 @@ class TestModel(base.TestCase): def test_get_all_compute_nodes(self): model = model_root.ModelRoot() for id_ in range(10): - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) node = element.ComputeNode(id_) node.uuid = uuid_ model.add_node(node) @@ -144,7 +143,7 @@ class TestModel(base.TestCase): def test_set_get_state_nodes(self): model = model_root.ModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) node = element.ComputeNode(id=1) node.uuid = uuid_ model.add_node(node) @@ -157,7 +156,7 @@ class TestModel(base.TestCase): def test_get_node_by_name(self): model = model_root.ModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) name = 'test_node' node = element.ComputeNode() node.uuid = uuid_ @@ -170,7 +169,7 @@ class TestModel(base.TestCase): def test_node_from_name_raise(self): model = model_root.ModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) name = 'test_node' node = element.ComputeNode() node.uuid = uuid_ @@ -183,23 +182,23 @@ class TestModel(base.TestCase): def test_node_from_uuid_raise(self): model = model_root.ModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) node = element.ComputeNode(id=1) node.uuid = uuid_ model.add_node(node) - uuid2 = "{0}".format(uuidutils.generate_uuid()) + uuid2 = "{}".format(uuidutils.generate_uuid()) self.assertRaises(exception.ComputeNodeNotFound, model.get_node_by_uuid, uuid2) def test_remove_node_raise(self): model = model_root.ModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) node = element.ComputeNode(id=1) node.uuid = uuid_ model.add_node(node) - uuid2 = "{0}".format(uuidutils.generate_uuid()) + uuid2 = "{}".format(uuidutils.generate_uuid()) node2 = element.ComputeNode(id=2) node2.uuid = uuid2 @@ -208,7 +207,7 @@ class TestModel(base.TestCase): def test_assert_node_raise(self): model = model_root.ModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) node = element.ComputeNode(id=1) node.uuid = uuid_ model.add_node(node) @@ -311,7 +310,7 @@ class TestStorageModel(base.TestCase): def test_assert_volume_raise(self): model = model_root.StorageModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) volume = element.Volume(uuid=uuid_) model.add_volume(volume) self.assertRaises(exception.IllegalArgumentException, @@ -368,14 +367,14 @@ class TestStorageModel(base.TestCase): def test_add_volume(self): model = model_root.StorageModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) volume = element.Volume(uuid=uuid_) model.add_volume(volume) self.assertEqual(volume, model.get_volume_by_uuid(uuid_)) def test_remove_volume(self): model = model_root.StorageModelRoot() - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) volume = element.Volume(uuid=uuid_) model.add_volume(volume) self.assertEqual(volume, model.get_volume_by_uuid(uuid_)) @@ -389,7 +388,7 @@ class TestStorageModel(base.TestCase): pool = element.Pool(name=pool_name) model.add_pool(pool) self.assertEqual(pool, model.get_pool_by_pool_name(pool_name)) - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) volume = element.Volume(uuid=uuid_) model.add_volume(volume) self.assertEqual(volume, model.get_volume_by_uuid(uuid_)) @@ -401,7 +400,7 @@ class TestStorageModel(base.TestCase): def test_get_all_storage_nodes(self): model = model_root.StorageModelRoot() for i in range(10): - hostname = "host_{0}".format(i) + hostname = "host_{}".format(i) node = element.StorageNode(host=hostname) model.add_node(node) all_nodes = model.get_all_storage_nodes() @@ -412,7 +411,7 @@ class TestStorageModel(base.TestCase): def test_get_all_volumes(self): model = model_root.StorageModelRoot() for id_ in range(10): - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) volume = element.Volume(uuid=uuid_) model.add_volume(volume) all_volumes = model.get_all_volumes() @@ -439,7 +438,7 @@ class TestStorageModel(base.TestCase): pool = element.Pool(name=pool_name) model.add_pool(pool) self.assertEqual(pool, model.get_pool_by_pool_name(pool_name)) - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) volume = element.Volume(uuid=uuid_) model.add_volume(volume) self.assertEqual(volume, model.get_volume_by_uuid(uuid_)) @@ -452,7 +451,7 @@ class TestStorageModel(base.TestCase): pool = element.Pool(name=pool_name) model.add_pool(pool) self.assertEqual(pool, model.get_pool_by_pool_name(pool_name)) - uuid_ = "{0}".format(uuidutils.generate_uuid()) + uuid_ = "{}".format(uuidutils.generate_uuid()) volume = element.Volume(uuid=uuid_) model.add_volume(volume) self.assertEqual(volume, model.get_volume_by_uuid(uuid_)) diff --git a/watcher/tests/decision_engine/planner/test_node_resource_consolidation.py b/watcher/tests/decision_engine/planner/test_node_resource_consolidation.py index e0066c306..0dc9c7740 100644 --- a/watcher/tests/decision_engine/planner/test_node_resource_consolidation.py +++ b/watcher/tests/decision_engine/planner/test_node_resource_consolidation.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 ZTE Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +30,7 @@ from watcher.tests.objects import utils as obj_utils class TestActionScheduling(base.DbTestCase): def setUp(self): - super(TestActionScheduling, self).setUp() + super().setUp() self.goal = db_utils.create_test_goal(name="server_consolidation") self.strategy = db_utils.create_test_strategy( name="node_resource_consolidation") @@ -204,7 +203,7 @@ class TestActionScheduling(base.DbTestCase): class TestDefaultPlanner(base.DbTestCase): def setUp(self): - super(TestDefaultPlanner, self).setUp() + super().setUp() self.planner = pbase.NodeResourceConsolidationPlanner(mock.Mock()) self.goal = obj_utils.create_test_goal(self.context) diff --git a/watcher/tests/decision_engine/planner/test_planner_manager.py b/watcher/tests/decision_engine/planner/test_planner_manager.py index b7cc5e8d7..40dc482aa 100644 --- a/watcher/tests/decision_engine/planner/test_planner_manager.py +++ b/watcher/tests/decision_engine/planner/test_planner_manager.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/planner/test_weight_planner.py b/watcher/tests/decision_engine/planner/test_weight_planner.py index 867042ccf..d3ee4f1de 100644 --- a/watcher/tests/decision_engine/planner/test_weight_planner.py +++ b/watcher/tests/decision_engine/planner/test_weight_planner.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +29,7 @@ from watcher.tests.decision_engine.model import gnocchi_metrics as fake from watcher.tests.objects import utils as obj_utils -class SolutionFaker(object): +class SolutionFaker: @staticmethod def build(): metrics = fake.FakerMetricsCollector() @@ -42,7 +41,7 @@ class SolutionFaker(object): return sercon.execute() -class SolutionFakerSingleHyp(object): +class SolutionFakerSingleHyp: @staticmethod def build(): metrics = fake.FakerMetricsCollector() @@ -59,7 +58,7 @@ class SolutionFakerSingleHyp(object): class TestActionScheduling(base.DbTestCase): def setUp(self): - super(TestActionScheduling, self).setUp() + super().setUp() self.goal = db_utils.create_test_goal(name="dummy") self.strategy = db_utils.create_test_strategy(name="dummy") self.audit = db_utils.create_test_audit( @@ -897,7 +896,7 @@ class TestActionScheduling(base.DbTestCase): class TestWeightPlanner(base.DbTestCase): def setUp(self): - super(TestWeightPlanner, self).setUp() + super().setUp() self.planner = pbase.WeightPlanner(mock.Mock()) self.planner.config.weights = { 'nop': 0, diff --git a/watcher/tests/decision_engine/planner/test_workload_stabilization_planner.py b/watcher/tests/decision_engine/planner/test_workload_stabilization_planner.py index ee7fcd748..6926792c2 100644 --- a/watcher/tests/decision_engine/planner/test_workload_stabilization_planner.py +++ b/watcher/tests/decision_engine/planner/test_workload_stabilization_planner.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +30,7 @@ from watcher.tests.decision_engine.model import gnocchi_metrics as fake from watcher.tests.objects import utils as obj_utils -class SolutionFaker(object): +class SolutionFaker: @staticmethod def build(): metrics = fake.FakerMetricsCollector() @@ -43,7 +42,7 @@ class SolutionFaker(object): return sercon.execute() -class SolutionFakerSingleHyp(object): +class SolutionFakerSingleHyp: @staticmethod def build(): metrics = fake.FakerMetricsCollector() @@ -60,7 +59,7 @@ class SolutionFakerSingleHyp(object): class TestActionScheduling(base.DbTestCase): def setUp(self): - super(TestActionScheduling, self).setUp() + super().setUp() self.goal = db_utils.create_test_goal(name="dummy") self.strategy = db_utils.create_test_strategy(name="dummy") self.audit = db_utils.create_test_audit( @@ -290,7 +289,7 @@ class TestActionScheduling(base.DbTestCase): class TestDefaultPlanner(base.DbTestCase): def setUp(self): - super(TestDefaultPlanner, self).setUp() + super().setUp() self.planner = pbase.WorkloadStabilizationPlanner(mock.Mock()) self.planner.config.weights = { 'nop': 0, @@ -341,7 +340,7 @@ class TestActionValidator(base.DbTestCase): INSTANCE_UUID = "94ae2f92-b7fd-4da7-9e97-f13504ae98c4" def setUp(self): - super(TestActionValidator, self).setUp() + super().setUp() self.r_osc_cls = mock.Mock() self.r_helper_cls = mock.Mock() self.r_helper = mock.Mock(spec=nova_helper.NovaHelper) diff --git a/watcher/tests/decision_engine/scope/fake_scopes.py b/watcher/tests/decision_engine/scope/fake_scopes.py index 638d17c1d..a5f88ec4e 100644 --- a/watcher/tests/decision_engine/scope/fake_scopes.py +++ b/watcher/tests/decision_engine/scope/fake_scopes.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/scope/test_baremetal.py b/watcher/tests/decision_engine/scope/test_baremetal.py index 5898c0ed6..a41ec5297 100644 --- a/watcher/tests/decision_engine/scope/test_baremetal.py +++ b/watcher/tests/decision_engine/scope/test_baremetal.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2018 SBCloud # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +25,7 @@ from watcher.tests.decision_engine.scope import fake_scopes class TestBaremetalScope(base.TestCase): def setUp(self): - super(TestBaremetalScope, self).setUp() + super().setUp() self.fake_cluster = faker_cluster_state.FakerBaremetalModelCollector() self.audit_scope = fake_scopes.baremetal_scope diff --git a/watcher/tests/decision_engine/scope/test_compute.py b/watcher/tests/decision_engine/scope/test_compute.py index 01faba806..285e4c7f0 100644 --- a/watcher/tests/decision_engine/scope/test_compute.py +++ b/watcher/tests/decision_engine/scope/test_compute.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +29,7 @@ from watcher.tests.decision_engine.scope import fake_scopes class TestComputeScope(base.TestCase): def setUp(self): - super(TestComputeScope, self).setUp() + super().setUp() self.fake_cluster = faker_cluster_state.FakerModelCollector() @mock.patch.object(nova_helper.NovaHelper, 'get_service_list') @@ -38,15 +37,15 @@ class TestComputeScope(base.TestCase): cluster = self.fake_cluster.generate_scenario_1() audit_scope = fake_scopes.fake_scope_1 mock_zone_list.return_value = [ - mock.Mock(zone='AZ{0}'.format(i), - host={'hostname_{0}'.format(i): {}}) + mock.Mock(zone='AZ{}'.format(i), + host={'hostname_{}'.format(i): {}}) for i in range(4)] model = compute.ComputeScope(audit_scope, mock.Mock(), osc=mock.Mock()).get_scoped_model(cluster) # NOTE(adisky):INSTANCE_6 is not excluded from model it will be tagged # as 'exclude' TRUE, blueprint compute-cdm-include-all-instances - expected_edges = [('INSTANCE_2', 'Node_1'), (u'INSTANCE_6', u'Node_3')] + expected_edges = [('INSTANCE_2', 'Node_1'), ('INSTANCE_6', 'Node_3')] self.assertEqual(sorted(expected_edges), sorted(model.edges())) @mock.patch.object(nova_helper.NovaHelper, 'get_service_list') @@ -75,7 +74,7 @@ class TestComputeScope(base.TestCase): def test_collect_aggregates(self, mock_aggregate): allowed_nodes = [] mock_aggregate.return_value = [ - mock.Mock(id=i, hosts=['Node_{0}'.format(i)]) for i in range(2)] + mock.Mock(id=i, hosts=['Node_{}'.format(i)]) for i in range(2)] compute.ComputeScope([{'host_aggregates': [{'id': 1}, {'id': 2}]}], mock.Mock(), osc=mock.Mock())._collect_aggregates( [{'id': 1}, {'id': 2}], allowed_nodes) @@ -85,7 +84,7 @@ class TestComputeScope(base.TestCase): def test_aggregates_wildcard_is_used(self, mock_aggregate): allowed_nodes = [] mock_aggregate.return_value = [ - mock.Mock(id=i, hosts=['Node_{0}'.format(i)]) for i in range(2)] + mock.Mock(id=i, hosts=['Node_{}'.format(i)]) for i in range(2)] compute.ComputeScope([{'host_aggregates': [{'id': '*'}]}], mock.Mock(), osc=mock.Mock())._collect_aggregates( [{'id': '*'}], allowed_nodes) @@ -106,7 +105,7 @@ class TestComputeScope(base.TestCase): @mock.patch.object(nova_helper.NovaHelper, 'get_aggregate_list') def test_aggregates_with_names_and_ids(self, mock_aggregate): allowed_nodes = [] - mock_collection = [mock.Mock(id=i, hosts=['Node_{0}'.format(i)]) + mock_collection = [mock.Mock(id=i, hosts=['Node_{}'.format(i)]) for i in range(2)] mock_collection[0].name = 'HA_0' mock_collection[1].name = 'HA_1' @@ -123,9 +122,9 @@ class TestComputeScope(base.TestCase): def test_collect_zones(self, mock_zone_list): allowed_nodes = [] mock_zone_list.return_value = [ - mock.Mock(zone="AZ{0}".format(i + 1), - host={'Node_{0}'.format(2 * i): 1, - 'Node_{0}'.format(2 * i + 1): 2}) + mock.Mock(zone="AZ{}".format(i + 1), + host={'Node_{}'.format(2 * i): 1, + 'Node_{}'.format(2 * i + 1): 2}) for i in range(2)] compute.ComputeScope([{'availability_zones': [{'name': "AZ1"}]}], mock.Mock(), osc=mock.Mock())._collect_zones( @@ -136,9 +135,9 @@ class TestComputeScope(base.TestCase): def test_zones_wildcard_is_used(self, mock_zone_list): allowed_nodes = [] mock_zone_list.return_value = [ - mock.Mock(zone="AZ{0}".format(i + 1), - host={'Node_{0}'.format(2 * i): 1, - 'Node_{0}'.format(2 * i + 1): 2}) + mock.Mock(zone="AZ{}".format(i + 1), + host={'Node_{}'.format(2 * i): 1, + 'Node_{}'.format(2 * i + 1): 2}) for i in range(2)] compute.ComputeScope([{'availability_zones': [{'name': "*"}]}], mock.Mock(), osc=mock.Mock())._collect_zones( @@ -150,9 +149,9 @@ class TestComputeScope(base.TestCase): def test_zones_wildcard_with_other_ids(self, mock_zone_list): allowed_nodes = [] mock_zone_list.return_value = [ - mock.Mock(zone="AZ{0}".format(i + 1), - host={'Node_{0}'.format(2 * i): 1, - 'Node_{0}'.format(2 * i + 1): 2}) + mock.Mock(zone="AZ{}".format(i + 1), + host={'Node_{}'.format(2 * i): 1, + 'Node_{}'.format(2 * i + 1): 2}) for i in range(2)] scope_handler = compute.ComputeScope( [{'availability_zones': [{'name': "*"}, {'name': 'AZ1'}]}], @@ -170,7 +169,7 @@ class TestComputeScope(base.TestCase): @mock.patch.object(nova_helper.NovaHelper, 'get_aggregate_list') def test_exclude_resource(self, mock_aggregate): - mock_collection = [mock.Mock(id=i, hosts=['Node_{0}'.format(i)]) + mock_collection = [mock.Mock(id=i, hosts=['Node_{}'.format(i)]) for i in range(2)] mock_collection[0].name = 'HA_0' mock_collection[1].name = 'HA_1' @@ -275,7 +274,7 @@ class TestComputeScope(base.TestCase): cluster = self.fake_cluster.generate_scenario_1() audit_scope = fake_scopes.fake_scope_3 mock_list.return_value = [mock.Mock(id=i, - name="HA_{0}".format(i)) + name="HA_{}".format(i)) for i in range(2)] model = compute.ComputeScope(audit_scope, mock.Mock(), osc=mock.Mock()).get_scoped_model(cluster) @@ -289,13 +288,13 @@ class TestComputeScope(base.TestCase): audit_scope.extend(fake_scopes.fake_scope_1) audit_scope.extend(fake_scopes.fake_scope_2) mock_zone_list.return_value = [ - mock.Mock(zone='AZ{0}'.format(i), - host={'hostname_{0}'.format(i): {}}) + mock.Mock(zone='AZ{}'.format(i), + host={'hostname_{}'.format(i): {}}) for i in range(4)] model = compute.ComputeScope(audit_scope, mock.Mock(), osc=mock.Mock()).get_scoped_model(cluster) # NOTE(adisky):INSTANCE_6 is not excluded from model it will be tagged # as 'exclude' TRUE, blueprint compute-cdm-include-all-instances - expected_edges = [('INSTANCE_2', 'Node_1'), (u'INSTANCE_6', u'Node_3')] + expected_edges = [('INSTANCE_2', 'Node_1'), ('INSTANCE_6', 'Node_3')] self.assertEqual(sorted(expected_edges), sorted(model.edges())) diff --git a/watcher/tests/decision_engine/scope/test_storage.py b/watcher/tests/decision_engine/scope/test_storage.py index da7920adb..22ea0d654 100644 --- a/watcher/tests/decision_engine/scope/test_storage.py +++ b/watcher/tests/decision_engine/scope/test_storage.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2018 NEC Corportion # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,7 +27,7 @@ from watcher.tests.decision_engine.scope import fake_scopes class TestStorageScope(base.TestCase): def setUp(self): - super(TestStorageScope, self).setUp() + super().setUp() self.fake_cluster = faker_cluster_state.FakerStorageModelCollector() @mock.patch.object(cinder_helper.CinderHelper, 'get_storage_node_list') @@ -36,8 +35,8 @@ class TestStorageScope(base.TestCase): cluster = self.fake_cluster.generate_scenario_1() audit_scope = fake_scopes.fake_scope_2 mock_zone_list.return_value = [ - mock.Mock(zone='zone_{0}'.format(i), - host='host_{0}@backend_{1}'.format(i, i)) + mock.Mock(zone='zone_{}'.format(i), + host='host_{}@backend_{}'.format(i, i)) for i in range(2)] model = storage.StorageScope(audit_scope, mock.Mock(), osc=mock.Mock()).get_scoped_model(cluster) @@ -58,8 +57,8 @@ class TestStorageScope(base.TestCase): allowed_nodes = [] az_scope = [{'name': 'zone_1'}] mock_zone_list.return_value = [ - mock.Mock(zone='zone_{0}'.format(i), - host='host_{0}@backend_{1}'.format(i, i)) + mock.Mock(zone='zone_{}'.format(i), + host='host_{}@backend_{}'.format(i, i)) for i in range(2)] storage.StorageScope([{'availability _zones': az_scope}], mock.Mock(), osc=mock.Mock())._collect_zones( @@ -90,8 +89,8 @@ class TestStorageScope(base.TestCase): def test_collect_vtype(self, mock_vt_list, mock_zone_list): allowed_nodes = [] mock_zone_list.return_value = [ - mock.Mock(zone='zone_{0}'.format(i), - host='host_{0}@backend_{1}'.format(i, i)) + mock.Mock(zone='zone_{}'.format(i), + host='host_{}@backend_{}'.format(i, i)) for i in range(2)] def side_effect(arg): @@ -204,8 +203,8 @@ class TestStorageScope(base.TestCase): audit_scope.extend(fake_scopes.fake_scope_2) audit_scope.extend(fake_scopes.fake_scope_1) mock_zone_list.return_value = [ - mock.Mock(zone='zone_{0}'.format(i), - host='host_{0}@backend_{1}'.format(i, i)) + mock.Mock(zone='zone_{}'.format(i), + host='host_{}@backend_{}'.format(i, i)) for i in range(2)] model = storage.StorageScope(audit_scope, mock.Mock(), osc=mock.Mock()).get_scoped_model(cluster) diff --git a/watcher/tests/decision_engine/scoring/test_dummy_scorer.py b/watcher/tests/decision_engine/scoring/test_dummy_scorer.py index c761e170b..34fcfd321 100644 --- a/watcher/tests/decision_engine/scoring/test_dummy_scorer.py +++ b/watcher/tests/decision_engine/scoring/test_dummy_scorer.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel # # Authors: Tomasz Kaczynski diff --git a/watcher/tests/decision_engine/scoring/test_dummy_scoring_container.py b/watcher/tests/decision_engine/scoring/test_dummy_scoring_container.py index b106ae4d6..20dca3fcb 100644 --- a/watcher/tests/decision_engine/scoring/test_dummy_scoring_container.py +++ b/watcher/tests/decision_engine/scoring/test_dummy_scoring_container.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel # # Authors: Tomasz Kaczynski diff --git a/watcher/tests/decision_engine/scoring/test_scoring_factory.py b/watcher/tests/decision_engine/scoring/test_scoring_factory.py index 78d9ef857..0b6977928 100644 --- a/watcher/tests/decision_engine/scoring/test_scoring_factory.py +++ b/watcher/tests/decision_engine/scoring/test_scoring_factory.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel # # Authors: Tomasz Kaczynski diff --git a/watcher/tests/decision_engine/solution/test_default_solution.py b/watcher/tests/decision_engine/solution/test_default_solution.py index fd526dbe0..d302fd7b8 100644 --- a/watcher/tests/decision_engine/solution/test_default_solution.py +++ b/watcher/tests/decision_engine/solution/test_default_solution.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/strategy/context/test_strategy_context.py b/watcher/tests/decision_engine/strategy/context/test_strategy_context.py index 89ac57830..374976590 100644 --- a/watcher/tests/decision_engine/strategy/context/test_strategy_context.py +++ b/watcher/tests/decision_engine/strategy/context/test_strategy_context.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,7 +29,7 @@ from watcher.tests.objects import utils as obj_utils class TestStrategyContext(base.DbTestCase): def setUp(self): - super(TestStrategyContext, self).setUp() + super().setUp() obj_utils.create_test_goal(self.context, id=1, name="DUMMY") audit_template = obj_utils.create_test_audit_template( self.context, uuid=utils.generate_uuid()) @@ -68,7 +67,7 @@ class TestStrategyContext(base.DbTestCase): audit = obj_utils.create_test_audit( self.context, - id=2, name='My Audit {0}'.format(2), + id=2, name='My Audit {}'.format(2), goal_id=goal.id, strategy_id=strategy.id, uuid=utils.generate_uuid(), @@ -96,7 +95,7 @@ class TestStrategyContext(base.DbTestCase): audit = obj_utils.create_test_audit( self.context, - id=2, name='My Audit {0}'.format(2), + id=2, name='My Audit {}'.format(2), strategy_id=strategy.id, uuid=utils.generate_uuid(), ) diff --git a/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py b/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py index 711db0db3..a3bb49a22 100644 --- a/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py +++ b/watcher/tests/decision_engine/strategy/selector/test_strategy_selector.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/strategy/strategies/test_actuator.py b/watcher/tests/decision_engine/strategy/strategies/test_actuator.py index 6734436ad..cd2e759e0 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_actuator.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_actuator.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -25,7 +24,7 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \ class TestActuator(TestBaseStrategy): def setUp(self): - super(TestActuator, self).setUp() + super().setUp() self.strategy = strategies.Actuator(config=mock.Mock()) def test_actuator_strategy(self): diff --git a/watcher/tests/decision_engine/strategy/strategies/test_base.py b/watcher/tests/decision_engine/strategy/strategies/test_base.py index bc250265b..c5ed14ccb 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_base.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_base.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +34,7 @@ except Exception: class TestBaseStrategy(base.TestCase): def setUp(self): - super(TestBaseStrategy, self).setUp() + super().setUp() # fake cluster self.fake_c_cluster = faker_cluster_state.FakerModelCollector() @@ -61,7 +60,7 @@ class TestBaseStrategy(base.TestCase): class TestBaseStrategyDatasource(TestBaseStrategy): def setUp(self): - super(TestBaseStrategyDatasource, self).setUp() + super().setUp() self.strategy = strategies.DummyStrategy( config=mock.Mock(datasources=None)) @@ -135,7 +134,7 @@ class TestBaseStrategyDatasource(TestBaseStrategy): class TestBaseStrategyException(TestBaseStrategy): def setUp(self): - super(TestBaseStrategyException, self).setUp() + super().setUp() def test_exception_model(self): self.m_c_model.return_value = None diff --git a/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py b/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py index b99a11b07..f70fb48f7 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_basic_consolidation.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Authors: Jean-Emile DARTOIS @@ -42,7 +41,7 @@ class TestBasicConsolidation(TestBaseStrategy): ] def setUp(self): - super(TestBasicConsolidation, self).setUp() + super().setUp() # fake metrics self.fake_metrics = self.fake_datasource_cls() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_dummy_strategy.py b/watcher/tests/decision_engine/strategy/strategies/test_dummy_strategy.py index 549a03202..998e3d7ae 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_dummy_strategy.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_dummy_strategy.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +25,7 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \ class TestDummyStrategy(TestBaseStrategy): def setUp(self): - super(TestDummyStrategy, self).setUp() + super().setUp() self.strategy = strategies.DummyStrategy(config=mock.Mock()) def test_dummy_strategy(self): diff --git a/watcher/tests/decision_engine/strategy/strategies/test_dummy_with_scorer.py b/watcher/tests/decision_engine/strategy/strategies/test_dummy_with_scorer.py index 0886207b9..ed8d70d00 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_dummy_with_scorer.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_dummy_with_scorer.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,7 +25,7 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \ class TestDummyWithScorer(TestBaseStrategy): def setUp(self): - super(TestDummyWithScorer, self).setUp() + super().setUp() self.strategy = strategies.DummyWithScorer(config=mock.Mock()) def test_dummy_with_scorer(self): diff --git a/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py b/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py index f00950868..1b3748701 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_host_maintenance.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 chinac.com # # Authors: suzhengwei @@ -29,7 +28,7 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \ class TestHostMaintenance(TestBaseStrategy): def setUp(self): - super(TestHostMaintenance, self).setUp() + super().setUp() self.strategy = strategies.HostMaintenance(config=mock.Mock()) def test_get_instance_state_str(self): diff --git a/watcher/tests/decision_engine/strategy/strategies/test_node_resource_consolidation.py b/watcher/tests/decision_engine/strategy/strategies/test_node_resource_consolidation.py index aebaba9b3..436cf2d7e 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_node_resource_consolidation.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_node_resource_consolidation.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 ZTE Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,7 +28,7 @@ from watcher.tests.objects import utils as obj_utils class TestNodeResourceConsolidation(TestBaseStrategy): def setUp(self): - super(TestNodeResourceConsolidation, self).setUp() + super().setUp() self.strategy = strategies.NodeResourceConsolidation( config=mock.Mock()) self.model = self.fake_c_cluster.generate_scenario_10() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_noisy_neighbor.py b/watcher/tests/decision_engine/strategy/strategies/test_noisy_neighbor.py index cb769f04b..b05e91b30 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_noisy_neighbor.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_noisy_neighbor.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Intel Corp # # Authors: Prudhvi Rao Shedimbi @@ -36,7 +35,7 @@ class TestNoisyNeighbor(TestBaseStrategy): ] def setUp(self): - super(TestNoisyNeighbor, self).setUp() + super().setUp() # fake metrics self.f_metrics = self.fake_datasource_cls() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py b/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py index bd266bf7b..33a65da2b 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_outlet_temp_control.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 Intel Corp # # Authors: Zhenzan Zhou @@ -36,7 +35,7 @@ class TestOutletTempControl(TestBaseStrategy): ] def setUp(self): - super(TestOutletTempControl, self).setUp() + super().setUp() # fake metrics self.fake_metrics = self.fake_datasource_cls() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py b/watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py index aaba37431..7939e0ffa 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_saving_energy.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,7 +28,7 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \ class TestSavingEnergy(TestBaseStrategy): def setUp(self): - super(TestSavingEnergy, self).setUp() + super().setUp() self.fake_nodes = [fake_metal_helper.get_mock_metal_node(), fake_metal_helper.get_mock_metal_node()] diff --git a/watcher/tests/decision_engine/strategy/strategies/test_storage_capacity_balance.py b/watcher/tests/decision_engine/strategy/strategies/test_storage_capacity_balance.py index 8c354ccdc..21a6228d1 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_storage_capacity_balance.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_storage_capacity_balance.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 ZTE # # Authors: Canwei Li @@ -32,7 +31,7 @@ from watcher.tests.decision_engine.strategy.strategies.test_base \ class TestStorageCapacityBalance(TestBaseStrategy): def setUp(self): - super(TestStorageCapacityBalance, self).setUp() + super().setUp() def test_fake_pool(name, free, total, allocated): fake_pool = mock.MagicMock() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_strategy_endpoint.py b/watcher/tests/decision_engine/strategy/strategies/test_strategy_endpoint.py index 26a7d920f..ada8bc36e 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_strategy_endpoint.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_strategy_endpoint.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2018 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/strategy/strategies/test_uniform_airflow.py b/watcher/tests/decision_engine/strategy/strategies/test_uniform_airflow.py index fef5a75c6..caffeb382 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_uniform_airflow.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_uniform_airflow.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Junjie-Huang @@ -36,7 +35,7 @@ class TestUniformAirflow(TestBaseStrategy): ] def setUp(self): - super(TestUniformAirflow, self).setUp() + super().setUp() # fake metrics self.fake_metrics = self.fake_datasource_cls() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py b/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py index 706c058c7..fb9ef4d07 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_vm_workload_consolidation.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # # Authors: Vojtech CIMA # Bruno GRAZIOLI @@ -38,7 +37,7 @@ class TestVMWorkloadConsolidation(TestBaseStrategy): ] def setUp(self): - super(TestVMWorkloadConsolidation, self).setUp() + super().setUp() # fake cluster self.fake_c_cluster = faker_cluster_and_metrics.FakerModelCollector() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_workload_balance.py b/watcher/tests/decision_engine/strategy/strategies/test_workload_balance.py index 3f197b54b..0549522ac 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_workload_balance.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_workload_balance.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Intel Corp # # Authors: Junjie-Huang @@ -37,7 +36,7 @@ class TestWorkloadBalance(TestBaseStrategy): ] def setUp(self): - super(TestWorkloadBalance, self).setUp() + super().setUp() # fake metrics self.fake_metrics = self.fake_datasource_cls() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_workload_stabilization.py b/watcher/tests/decision_engine/strategy/strategies/test_workload_stabilization.py index 90721c19a..0296b4b81 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_workload_stabilization.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_workload_stabilization.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 Servionica LLC # # Authors: Alexander Chadin @@ -36,7 +35,7 @@ class TestWorkloadStabilization(TestBaseStrategy): ] def setUp(self): - super(TestWorkloadStabilization, self).setUp() + super().setUp() # fake metrics self.fake_metrics = self.fake_datasource_cls() diff --git a/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py b/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py index 35e9db2fd..2b9f538e4 100644 --- a/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py +++ b/watcher/tests/decision_engine/strategy/strategies/test_zone_migration.py @@ -29,7 +29,7 @@ volume_uuid_mapping = faker_cluster_state.volume_uuid_mapping class TestZoneMigration(TestBaseStrategy): def setUp(self): - super(TestZoneMigration, self).setUp() + super().setUp() # fake storage cluster self.fake_s_cluster = faker_cluster_state.FakerStorageModelCollector() diff --git a/watcher/tests/decision_engine/test_gmr.py b/watcher/tests/decision_engine/test_gmr.py index 3ffbc28ba..08d872210 100644 --- a/watcher/tests/decision_engine/test_gmr.py +++ b/watcher/tests/decision_engine/test_gmr.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE diff --git a/watcher/tests/decision_engine/test_rpcapi.py b/watcher/tests/decision_engine/test_rpcapi.py index 53c7cf5a6..544f6ce35 100644 --- a/watcher/tests/decision_engine/test_rpcapi.py +++ b/watcher/tests/decision_engine/test_rpcapi.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2015 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/watcher/tests/decision_engine/test_scheduling.py b/watcher/tests/decision_engine/test_scheduling.py index ea6abb842..9003fbe3c 100644 --- a/watcher/tests/decision_engine/test_scheduling.py +++ b/watcher/tests/decision_engine/test_scheduling.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Authors: Vincent FRANCOISE @@ -39,7 +38,7 @@ from watcher.tests.objects import utils as obj_utils class TestCancelOngoingAudits(db_base.DbTestCase): def setUp(self): - super(TestCancelOngoingAudits, self).setUp() + super().setUp() p_audit_notifications = mock.patch.object( notifications, 'audit', autospec=True) self.m_audit_notifications = p_audit_notifications.start() @@ -82,7 +81,7 @@ class TestCancelOngoingAudits(db_base.DbTestCase): class TestDecisionEngineSchedulingService(base.TestCase): def setUp(self): - super(TestDecisionEngineSchedulingService, self).setUp() + super().setUp() self.fake_keystone = self.useFixture(watcher_fixtures.KeystoneClient()) @mock.patch.object( diff --git a/watcher/tests/decision_engine/test_sync.py b/watcher/tests/decision_engine/test_sync.py index 14da958f4..9fcd0c831 100644 --- a/watcher/tests/decision_engine/test_sync.py +++ b/watcher/tests/decision_engine/test_sync.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2016 b<>com # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +30,7 @@ from watcher.tests.decision_engine import fake_strategies class TestSyncer(base.DbTestCase): def setUp(self): - super(TestSyncer, self).setUp() + super().setUp() self.ctx = context.make_context() # This mock simulates the strategies discovery done in discover() @@ -424,10 +423,10 @@ class TestSyncer(base.DbTestCase): self.assertEqual( {"dummy_1", "dummy_2"}, - set([g.name for g in after_goals])) + {g.name for g in after_goals}) self.assertEqual( {"strategy_1", "strategy_2", "strategy_3", "strategy_4"}, - set([s.name for s in after_strategies])) + {s.name for s in after_strategies}) created_goals, modified_goals, unmodified_goals = ( self._find_created_modified_unmodified_ids( @@ -467,28 +466,28 @@ class TestSyncer(base.DbTestCase): self.assertEqual(2, strategy2.goal_id) self.assertNotEqual( - set([strategy2.id, strategy3.id, strategy4.id]), + {strategy2.id, strategy3.id, strategy4.id}, set(modified_strategies)) - self.assertEqual(set([strategy1.id]), set(unmodified_strategies)) + self.assertEqual({strategy1.id}, set(unmodified_strategies)) self.assertEqual( - set([audit_template2.id, audit_template3.id, audit_template4.id]), + {audit_template2.id, audit_template3.id, audit_template4.id}, set(modified_audit_templates)) - self.assertEqual(set([audit_template1.id]), + self.assertEqual({audit_template1.id}, set(unmodified_audit_templates)) self.assertEqual( - set([audit2.id, audit3.id, audit4.id]), + {audit2.id, audit3.id, audit4.id}, set(modified_audits)) - self.assertEqual(set([audit1.id]), set(unmodified_audits)) + self.assertEqual({audit1.id}, set(unmodified_audits)) self.assertEqual( - set([action_plan2.id, action_plan3.id, action_plan4.id]), + {action_plan2.id, action_plan3.id, action_plan4.id}, set(modified_action_plans)) self.assertTrue( all(ap.state == objects.action_plan.State.CANCELLED for ap in modified_action_plans.values())) - self.assertEqual(set([action_plan1.id]), set(unmodified_action_plans)) + self.assertEqual({action_plan1.id}, set(unmodified_action_plans)) def test_end2end_sync_goals_with_removed_goal_and_strategy(self): # ### Setup ### # @@ -614,10 +613,10 @@ class TestSyncer(base.DbTestCase): self.assertEqual(2, len(after_action_plans)) self.assertEqual( {"dummy_1"}, - set([g.name for g in after_goals])) + {g.name for g in after_goals}) self.assertEqual( {"strategy_1"}, - set([s.name for s in after_strategies])) + {s.name for s in after_strategies}) created_goals, modified_goals, unmodified_goals = ( self._find_created_modified_unmodified_ids( @@ -646,19 +645,19 @@ class TestSyncer(base.DbTestCase): self.assertEqual(0, len(created_audits)) self.assertEqual(0, len(created_action_plans)) - self.assertEqual(set([audit_template2.id]), + self.assertEqual({audit_template2.id}, set(modified_audit_templates)) - self.assertEqual(set([audit_template1.id]), + self.assertEqual({audit_template1.id}, set(unmodified_audit_templates)) - self.assertEqual(set([audit2.id]), set(modified_audits)) - self.assertEqual(set([audit1.id]), set(unmodified_audits)) + self.assertEqual({audit2.id}, set(modified_audits)) + self.assertEqual({audit1.id}, set(unmodified_audits)) - self.assertEqual(set([action_plan2.id]), set(modified_action_plans)) + self.assertEqual({action_plan2.id}, set(modified_action_plans)) self.assertTrue( all(ap.state == objects.action_plan.State.CANCELLED for ap in modified_action_plans.values())) - self.assertEqual(set([action_plan1.id]), set(unmodified_action_plans)) + self.assertEqual({action_plan1.id}, set(unmodified_action_plans)) def test_sync_strategies_with_removed_goal(self): # ### Setup ### # @@ -708,7 +707,7 @@ class TestSyncer(base.DbTestCase): self.assertEqual(4, len(after_strategies)) self.assertEqual( {"dummy_1", "dummy_2"}, - set([g.name for g in after_goals])) + {g.name for g in after_goals}) self.assertEqual( {"strategy_1", "strategy_2", "strategy_3", "strategy_4"}, - set([s.name for s in after_strategies])) + {s.name for s in after_strategies}) diff --git a/watcher/tests/fakes.py b/watcher/tests/fakes.py index e9f125699..f5b4b341c 100644 --- a/watcher/tests/fakes.py +++ b/watcher/tests/fakes.py @@ -13,14 +13,14 @@ import requests from unittest import mock -fakeAuthTokenHeaders = {'X-User-Id': u'773a902f022949619b5c2f32cd89d419', - 'X-Roles': u'admin, ResellerAdmin, _member_', - 'X-Project-Id': u'5588aebbcdc24e17a061595f80574376', +fakeAuthTokenHeaders = {'X-User-Id': '773a902f022949619b5c2f32cd89d419', + 'X-Roles': 'admin, ResellerAdmin, _member_', + 'X-Project-Id': '5588aebbcdc24e17a061595f80574376', 'X-Project-Name': 'test', 'X-User-Name': 'test', - 'X-Auth-Token': u'5588aebbcdc24e17a061595f80574376', - 'X-Forwarded-For': u'10.10.10.10, 11.11.11.11', - 'X-Service-Catalog': u'{test: 12345}', + 'X-Auth-Token': '5588aebbcdc24e17a061595f80574376', + 'X-Forwarded-For': '10.10.10.10, 11.11.11.11', + 'X-Service-Catalog': '{test: 12345}', 'X-Identity-Status': 'Confirmed', 'X-User-Domain-Name': 'domain', 'X-Project-Domain-Id': 'project_domain_id', @@ -31,7 +31,7 @@ fakeAuthTokenHeaders = {'X-User-Id': u'773a902f022949619b5c2f32cd89d419', class FakePecanRequest(mock.Mock): def __init__(self, **kwargs): - super(FakePecanRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.host_url = 'http://test_url:8080/test' self.context = {} self.body = '' @@ -48,17 +48,17 @@ class FakePecanRequest(mock.Mock): class FakePecanResponse(mock.Mock): def __init__(self, **kwargs): - super(FakePecanResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = None -class FakeApp(object): +class FakeApp: pass class FakeService(mock.Mock): def __init__(self, **kwargs): - super(FakeService, self).__init__(**kwargs) + super().__init__(**kwargs) self.__tablename__ = 'service' self.__resource__ = 'services' self.user_id = 'fake user id' @@ -86,7 +86,7 @@ class FakeService(mock.Mock): class FakeAuthProtocol(mock.Mock): def __init__(self, **kwargs): - super(FakeAuthProtocol, self).__init__(**kwargs) + super().__init__(**kwargs) self.app = FakeApp() self.config = '' @@ -105,7 +105,7 @@ class FakeResponse(requests.Response): behave as expected. :param headers: Dict of HTTP header values to set. """ - super(FakeResponse, self).__init__() + super().__init__() self.status_code = status_code if content: self._content = content diff --git a/watcher/tests/fixtures/watcher.py b/watcher/tests/fixtures/watcher.py index 8176792cc..97ab65a19 100644 --- a/watcher/tests/fixtures/watcher.py +++ b/watcher/tests/fixtures/watcher.py @@ -72,7 +72,7 @@ class StandardLogging(fixtures.Fixture): """ def setUp(self): - super(StandardLogging, self).setUp() + super().setUp() # set root logger to debug root = std_logging.getLogger() @@ -129,7 +129,7 @@ class KeystoneClient(fixtures.Fixture): """ def setUp(self): - super(KeystoneClient, self).setUp() + super().setUp() mock_osc = mock.patch.object( OpenStackClients, "keystone", return_value=mock.MagicMock(spec=ks_client.Client)) diff --git a/watcher/tests/notifications/test_action_notification.py b/watcher/tests/notifications/test_action_notification.py index df7f69f9c..41e746f91 100644 --- a/watcher/tests/notifications/test_action_notification.py +++ b/watcher/tests/notifications/test_action_notification.py @@ -29,7 +29,7 @@ from watcher.tests.objects import utils class TestActionNotification(base.DbTestCase): def setUp(self): - super(TestActionNotification, self).setUp() + super().setUp() p_get_notifier = mock.patch.object(rpc, 'get_notifier') m_get_notifier = p_get_notifier.start() self.addCleanup(p_get_notifier.stop) @@ -327,8 +327,8 @@ class TestActionNotification(base.DbTestCase): 'created_at': '2016-10-18T09:52:05Z', 'fault': { 'watcher_object.data': { - 'exception': u'WatcherException', - 'exception_message': u'TEST', + 'exception': 'WatcherException', + 'exception_message': 'TEST', 'function_name': ( 'test_send_action_execution_with_error'), 'module_name': ( @@ -461,8 +461,8 @@ class TestActionNotification(base.DbTestCase): 'created_at': '2016-10-18T09:52:05Z', 'fault': { 'watcher_object.data': { - 'exception': u'WatcherException', - 'exception_message': u'TEST', + 'exception': 'WatcherException', + 'exception_message': 'TEST', 'function_name': ( 'test_send_action_cancel_with_error'), 'module_name': ( diff --git a/watcher/tests/notifications/test_action_plan_notification.py b/watcher/tests/notifications/test_action_plan_notification.py index 5c57eb6d8..8b452ef51 100644 --- a/watcher/tests/notifications/test_action_plan_notification.py +++ b/watcher/tests/notifications/test_action_plan_notification.py @@ -29,7 +29,7 @@ from watcher.tests.objects import utils class TestActionPlanNotification(base.DbTestCase): def setUp(self): - super(TestActionPlanNotification, self).setUp() + super().setUp() p_get_notifier = mock.patch.object(rpc, 'get_notifier') m_get_notifier = p_get_notifier.start() self.addCleanup(p_get_notifier.stop) diff --git a/watcher/tests/notifications/test_audit_notification.py b/watcher/tests/notifications/test_audit_notification.py index bb7fdab3a..4f36270c7 100644 --- a/watcher/tests/notifications/test_audit_notification.py +++ b/watcher/tests/notifications/test_audit_notification.py @@ -29,7 +29,7 @@ from watcher.tests.objects import utils class TestAuditNotification(base.DbTestCase): def setUp(self): - super(TestAuditNotification, self).setUp() + super().setUp() p_get_notifier = mock.patch.object(rpc, 'get_notifier') m_get_notifier = p_get_notifier.start() self.addCleanup(p_get_notifier.stop) diff --git a/watcher/tests/notifications/test_notification.py b/watcher/tests/notifications/test_notification.py index 9b8a93a6f..47281d49c 100644 --- a/watcher/tests/notifications/test_notification.py +++ b/watcher/tests/notifications/test_notification.py @@ -53,8 +53,7 @@ class TestNotificationBase(testbase.TestCase): } def populate_schema(self, source_field): - super(TestNotificationBase.TestNotificationPayload, - self).populate_schema(source_field=source_field) + super().populate_schema(source_field=source_field) @base.WatcherObjectRegistry.register_if(False) class TestNotificationPayloadEmptySchema( @@ -92,7 +91,7 @@ class TestNotificationBase(testbase.TestCase): 'watcher_object.namespace': 'watcher'} def setUp(self): - super(TestNotificationBase, self).setUp() + super().setUp() self.my_obj = self.TestObject(field_1='test1', field_2=42, @@ -302,7 +301,7 @@ expected_notification_fingerprints = { class TestNotificationObjectVersions(testbase.TestCase): def setUp(self): - super(TestNotificationObjectVersions, self).setUp() + super().setUp() base.WatcherObjectRegistry.register_notification_objects() def test_versions(self): diff --git a/watcher/tests/notifications/test_service_notifications.py b/watcher/tests/notifications/test_service_notifications.py index 201d8d04a..b7babcf2c 100644 --- a/watcher/tests/notifications/test_service_notifications.py +++ b/watcher/tests/notifications/test_service_notifications.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2017 Servionica # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,7 +30,7 @@ from watcher.tests.objects import utils class TestActionPlanNotification(base.DbTestCase): def setUp(self): - super(TestActionPlanNotification, self).setUp() + super().setUp() p_get_notifier = mock.patch.object(rpc, 'get_notifier') m_get_notifier = p_get_notifier.start() self.addCleanup(p_get_notifier.stop) diff --git a/watcher/tests/objects/test_action.py b/watcher/tests/objects/test_action.py index 3db8f5aca..f9f2b5ed9 100644 --- a/watcher/tests/objects/test_action.py +++ b/watcher/tests/objects/test_action.py @@ -48,7 +48,7 @@ class TestActionObject(base.DbTestCase): ] def setUp(self): - super(TestActionObject, self).setUp() + super().setUp() p_action_notifications = mock.patch.object( notifications, 'action_plan', autospec=True) @@ -167,7 +167,7 @@ class TestActionObject(base.DbTestCase): class TestCreateDeleteActionObject(base.DbTestCase): def setUp(self): - super(TestCreateDeleteActionObject, self).setUp() + super().setUp() self.fake_strategy = utils.create_test_strategy(name="DUMMY") self.fake_audit = utils.create_test_audit() self.fake_action_plan = utils.create_test_action_plan() diff --git a/watcher/tests/objects/test_action_description.py b/watcher/tests/objects/test_action_description.py index f8dda32ea..d2fa4f479 100644 --- a/watcher/tests/objects/test_action_description.py +++ b/watcher/tests/objects/test_action_description.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright 2017 ZTE # All Rights Reserved. # @@ -28,7 +27,7 @@ from watcher.tests.db import utils class TestActionDescriptionObject(base.DbTestCase): def setUp(self): - super(TestActionDescriptionObject, self).setUp() + super().setUp() self.fake_action_desc = utils.get_test_action_desc( created_at=timeutils.utcnow()) diff --git a/watcher/tests/objects/test_action_plan.py b/watcher/tests/objects/test_action_plan.py index d116103d1..d151ac6c9 100644 --- a/watcher/tests/objects/test_action_plan.py +++ b/watcher/tests/objects/test_action_plan.py @@ -59,7 +59,7 @@ class TestActionPlanObject(base.DbTestCase): ] def setUp(self): - super(TestActionPlanObject, self).setUp() + super().setUp() p_action_plan_notifications = mock.patch.object( notifications, 'action_plan', autospec=True) @@ -186,7 +186,7 @@ class TestActionPlanObject(base.DbTestCase): class TestCreateDeleteActionPlanObject(base.DbTestCase): def setUp(self): - super(TestCreateDeleteActionPlanObject, self).setUp() + super().setUp() p_action_plan_notifications = mock.patch.object( notifications, 'action_plan', autospec=True) @@ -300,7 +300,7 @@ class TestCreateDeleteActionPlanObject(base.DbTestCase): class TestStateManager(base.DbTestCase): def setUp(self): - super(TestStateManager, self).setUp() + super().setUp() self.state_manager = objects.action_plan.StateManager() def test_check_expired(self): diff --git a/watcher/tests/objects/test_audit.py b/watcher/tests/objects/test_audit.py index 10e461f06..2e3df00f9 100644 --- a/watcher/tests/objects/test_audit.py +++ b/watcher/tests/objects/test_audit.py @@ -55,7 +55,7 @@ class TestAuditObject(base.DbTestCase): ] def setUp(self): - super(TestAuditObject, self).setUp() + super().setUp() p_audit_notifications = mock.patch.object( notifications, 'audit', autospec=True) @@ -174,7 +174,7 @@ class TestAuditObject(base.DbTestCase): class TestCreateDeleteAuditObject(base.DbTestCase): def setUp(self): - super(TestCreateDeleteAuditObject, self).setUp() + super().setUp() p_audit_notifications = mock.patch.object( notifications, 'audit', autospec=True) self.m_audit_notifications = p_audit_notifications.start() @@ -242,7 +242,7 @@ class TestCreateDeleteAuditObject(base.DbTestCase): class TestAuditObjectSendNotifications(base.DbTestCase): def setUp(self): - super(TestAuditObjectSendNotifications, self).setUp() + super().setUp() goal_id = 1 self.fake_goal = utils.create_test_goal(id=goal_id, name="DUMMY") self.fake_strategy = utils.create_test_strategy( diff --git a/watcher/tests/objects/test_audit_template.py b/watcher/tests/objects/test_audit_template.py index 36298b047..853e795c4 100644 --- a/watcher/tests/objects/test_audit_template.py +++ b/watcher/tests/objects/test_audit_template.py @@ -52,7 +52,7 @@ class TestAuditTemplateObject(base.DbTestCase): ] def setUp(self): - super(TestAuditTemplateObject, self).setUp() + super().setUp() self.fake_goal = utils.create_test_goal(**self.goal_data) def eager_load_audit_template_assert(self, audit_template, goal): @@ -163,7 +163,7 @@ class TestAuditTemplateObject(base.DbTestCase): class TestCreateDeleteAuditTemplateObject(base.DbTestCase): def setUp(self): - super(TestCreateDeleteAuditTemplateObject, self).setUp() + super().setUp() self.fake_audit_template = utils.get_test_audit_template( created_at=timeutils.utcnow()) diff --git a/watcher/tests/objects/test_efficacy_indicator.py b/watcher/tests/objects/test_efficacy_indicator.py index 3d019fd99..7d18bae5e 100644 --- a/watcher/tests/objects/test_efficacy_indicator.py +++ b/watcher/tests/objects/test_efficacy_indicator.py @@ -24,7 +24,7 @@ from watcher.tests.db import utils class TestEfficacyIndicatorObject(base.DbTestCase): def setUp(self): - super(TestEfficacyIndicatorObject, self).setUp() + super().setUp() self.fake_efficacy_indicator = utils.get_test_efficacy_indicator() def test_get_by_id(self): diff --git a/watcher/tests/objects/test_goal.py b/watcher/tests/objects/test_goal.py index 8757dbd21..cba187024 100644 --- a/watcher/tests/objects/test_goal.py +++ b/watcher/tests/objects/test_goal.py @@ -27,7 +27,7 @@ from watcher.tests.db import utils class TestGoalObject(base.DbTestCase): def setUp(self): - super(TestGoalObject, self).setUp() + super().setUp() self.fake_goal = utils.get_test_goal( created_at=timeutils.utcnow()) diff --git a/watcher/tests/objects/test_objects.py b/watcher/tests/objects/test_objects.py index c5230a9e7..e38566a33 100644 --- a/watcher/tests/objects/test_objects.py +++ b/watcher/tests/objects/test_objects.py @@ -77,7 +77,7 @@ class MyObj(base.WatcherPersistentObject, base.WatcherObject, self.foo = 42 -class MyObj2(object): +class MyObj2: @classmethod def obj_name(cls): return 'MyObj' @@ -94,7 +94,7 @@ class WatcherTestSubclassedObject(MyObj): class _LocalTest(test_base.TestCase): def setUp(self): - super(_LocalTest, self).setUp() + super().setUp() # Just in case base.WatcherObject.indirection_api = None @@ -109,7 +109,7 @@ def things_temporarily_local(): base.WatcherObject.indirection_api = _api -class _TestObject(object): +class _TestObject: def test_hydration_type_error(self): primitive = {'watcher_object.name': 'MyObj', 'watcher_object.namespace': 'watcher', @@ -195,11 +195,11 @@ class _TestObject(object): def test_changes_in_primitive(self): obj = MyObj(self.context) obj.foo = 123 - self.assertEqual(set(['foo']), obj.obj_what_changed()) + self.assertEqual({'foo'}, obj.obj_what_changed()) primitive = obj.obj_to_primitive() self.assertIn('watcher_object.changes', primitive) obj2 = MyObj.obj_from_primitive(primitive) - self.assertEqual(set(['foo']), obj2.obj_what_changed()) + self.assertEqual({'foo'}, obj2.obj_what_changed()) obj2.obj_reset_changes() self.assertEqual(set(), obj2.obj_what_changed()) @@ -223,34 +223,34 @@ class _TestObject(object): def test_changed_1(self): obj = MyObj.query(self.context) obj.foo = 123 - self.assertEqual(set(['foo']), obj.obj_what_changed()) + self.assertEqual({'foo'}, obj.obj_what_changed()) obj.update_test(self.context) - self.assertEqual(set(['foo', 'bar']), obj.obj_what_changed()) + self.assertEqual({'foo', 'bar'}, obj.obj_what_changed()) self.assertEqual(123, obj.foo) def test_changed_2(self): obj = MyObj.query(self.context) obj.foo = 123 - self.assertEqual(set(['foo']), obj.obj_what_changed()) + self.assertEqual({'foo'}, obj.obj_what_changed()) obj.save() - self.assertEqual(set([]), obj.obj_what_changed()) + self.assertEqual(set(), obj.obj_what_changed()) self.assertEqual(123, obj.foo) def test_changed_3(self): obj = MyObj.query(self.context) obj.foo = 123 - self.assertEqual(set(['foo']), obj.obj_what_changed()) + self.assertEqual({'foo'}, obj.obj_what_changed()) obj.refresh() - self.assertEqual(set([]), obj.obj_what_changed()) + self.assertEqual(set(), obj.obj_what_changed()) self.assertEqual(321, obj.foo) self.assertEqual('refreshed', obj.bar) def test_changed_4(self): obj = MyObj.query(self.context) obj.bar = 'something' - self.assertEqual(set(['bar']), obj.obj_what_changed()) + self.assertEqual({'bar'}, obj.obj_what_changed()) obj.modify_save_modify(self.context) - self.assertEqual(set(['foo']), obj.obj_what_changed()) + self.assertEqual({'foo'}, obj.obj_what_changed()) self.assertEqual(42, obj.foo) self.assertEqual('meow', obj.bar) @@ -356,8 +356,8 @@ class _TestObject(object): return 'this is bar' obj = TestObj(self.context) - self.assertEqual(set(['created_at', 'updated_at', 'deleted_at', - 'foo', 'bar']), + self.assertEqual({'created_at', 'updated_at', 'deleted_at', + 'foo', 'bar'}, set(obj.obj_fields)) def test_refresh_object(self): @@ -381,7 +381,7 @@ class _TestObject(object): obj = MyObj(self.context, foo=123, bar='abc') self.assertEqual(123, obj.foo) self.assertEqual('abc', obj.bar) - self.assertEqual(set(['foo', 'bar']), obj.obj_what_changed()) + self.assertEqual({'foo', 'bar'}, obj.obj_what_changed()) def test_assign_value_without_DictCompat(self): class TestObj(base.WatcherObject): @@ -534,7 +534,7 @@ class TestRegistry(test_base.TestCase): reg = base.WatcherObjectRegistry() reg.registration_hook(MyObj, 0) - class MyNewerObj(object): + class MyNewerObj: VERSION = '1.123' @classmethod @@ -551,7 +551,7 @@ class TestRegistry(test_base.TestCase): reg = base.WatcherObjectRegistry() reg.registration_hook(MyObj, 0) - class MyOlderObj(object): + class MyOlderObj: VERSION = '1.1' @classmethod diff --git a/watcher/tests/objects/test_scoring_engine.py b/watcher/tests/objects/test_scoring_engine.py index 6b5f08bf7..c974b0be4 100644 --- a/watcher/tests/objects/test_scoring_engine.py +++ b/watcher/tests/objects/test_scoring_engine.py @@ -27,7 +27,7 @@ from watcher.tests.db import utils class TestScoringEngineObject(base.DbTestCase): def setUp(self): - super(TestScoringEngineObject, self).setUp() + super().setUp() self.fake_scoring_engine = utils.get_test_scoring_engine( created_at=timeutils.utcnow()) diff --git a/watcher/tests/objects/test_service.py b/watcher/tests/objects/test_service.py index 2c672e2dc..9e753de3b 100644 --- a/watcher/tests/objects/test_service.py +++ b/watcher/tests/objects/test_service.py @@ -27,7 +27,7 @@ from watcher.tests.db import utils class TestServiceObject(base.DbTestCase): def setUp(self): - super(TestServiceObject, self).setUp() + super().setUp() self.fake_service = utils.get_test_service( created_at=timeutils.utcnow()) diff --git a/watcher/tests/objects/test_strategy.py b/watcher/tests/objects/test_strategy.py index c2a9f1bec..f0df12f2b 100644 --- a/watcher/tests/objects/test_strategy.py +++ b/watcher/tests/objects/test_strategy.py @@ -40,7 +40,7 @@ class TestStrategyObject(base.DbTestCase): ] def setUp(self): - super(TestStrategyObject, self).setUp() + super().setUp() self.fake_goal = utils.create_test_goal(id=self.goal_id) def eager_load_strategy_assert(self, strategy): @@ -130,7 +130,7 @@ class TestStrategyObject(base.DbTestCase): class TestCreateDeleteStrategyObject(base.DbTestCase): def setUp(self): - super(TestCreateDeleteStrategyObject, self).setUp() + super().setUp() self.fake_goal = utils.create_test_goal() self.fake_strategy = utils.get_test_strategy(goal_id=self.fake_goal.id) diff --git a/watcher/tests/test_threading.py b/watcher/tests/test_threading.py index 11507d217..6a993b8d0 100644 --- a/watcher/tests/test_threading.py +++ b/watcher/tests/test_threading.py @@ -1,4 +1,3 @@ -# -*- encoding: utf-8 -*- # Copyright (c) 2019 European Organization for Nuclear Research (CERN) # # Authors: Corne Lukken @@ -26,7 +25,7 @@ from watcher.tests import base class TestDecisionEngineThreadPool(base.TestCase): def setUp(self): - super(TestDecisionEngineThreadPool, self).setUp() + super().setUp() self.m_function = mock.Mock() self.m_function.return_value = None