diff --git a/murano/common/config.py b/murano/common/config.py index 0cde80a6..c734d81d 100644 --- a/murano/common/config.py +++ b/murano/common/config.py @@ -355,7 +355,7 @@ def load_paste_app(app_name=None): return app except (LookupError, ImportError) as e: msg = _("Unable to load %(app_name)s from " - "configuration file %(conf_file)s." - "\nGot: %(e)r") % locals() + "configuration file %(conf_file)s. \nGot: %(e)r", + {'conf_file': conf_file, 'app_name': app_name, 'e': e}) logger.error(msg) raise RuntimeError(msg) diff --git a/murano/db/models.py b/murano/db/models.py index e176b2ac..f117e261 100644 --- a/murano/db/models.py +++ b/murano/db/models.py @@ -180,7 +180,7 @@ package_to_tag = sa.Table('package_to_tag', sa.Column('tag_id', sa.String(36), sa.ForeignKey('tag.id', - ondelete="CASCADE"))) + ondelete="CASCADE"))) class Instance(Base): diff --git a/murano/db/services/core_services.py b/murano/db/services/core_services.py index 94041237..e3f02074 100644 --- a/murano/db/services/core_services.py +++ b/murano/db/services/core_services.py @@ -50,7 +50,7 @@ class CoreServices(object): if env_description is None: return None - if not 'services' in env_description: + if 'services' not in env_description: return [] result = utils.TraverseHelper.get(path, env_description) @@ -71,7 +71,7 @@ class CoreServices(object): env_description = get_description(environment_id, session_id) if env_description is None: raise exc.HTTPMethodNotAllowed - if not 'services' in env_description: + if 'services' not in env_description: env_description['services'] = [] if path == '/services': diff --git a/murano/policy/model_policy_enforcer.py b/murano/policy/model_policy_enforcer.py index 4c49c93b..d37a113f 100644 --- a/murano/policy/model_policy_enforcer.py +++ b/murano/policy/model_policy_enforcer.py @@ -77,7 +77,7 @@ class ModelPolicyEnforcer(object): False, {'query': 'predeploy_errors(eid, oid, msg)', 'action_policy': 'action', - 'sequence': rules_str}) + 'sequence': rules_str}) if validation_result["result"]: diff --git a/murano/tests/unit/api/base.py b/murano/tests/unit/api/base.py index ac4793e7..5083ec39 100644 --- a/murano/tests/unit/api/base.py +++ b/murano/tests/unit/api/base.py @@ -52,14 +52,14 @@ class FakeLogMixin: fixtures.FakeLogger(level=logging.DEBUG)) base_list = set([nlog.split('.')[0] for nlog in logging.Logger.manager.loggerDict]) - for base in base_list: - if base in TEST_DEFAULT_LOGLEVELS: + for base_name in base_list: + if base_name in TEST_DEFAULT_LOGLEVELS: self.useFixture(fixtures.FakeLogger( - level=TEST_DEFAULT_LOGLEVELS[base], - name=base)) - elif base != 'murano': + level=TEST_DEFAULT_LOGLEVELS[base_name], + name=base_name)) + elif base_name != 'murano': self.useFixture(fixtures.FakeLogger( - name=base)) + name=base_name)) class MuranoApiTestCase(base.MuranoWithDBTestCase, FakeLogMixin): diff --git a/murano/tests/unit/api/v1/test_actions.py b/murano/tests/unit/api/v1/test_actions.py index 2d97c37e..0e38a4d1 100644 --- a/murano/tests/unit/api/v1/test_actions.py +++ b/murano/tests/unit/api/v1/test_actions.py @@ -63,16 +63,27 @@ class TestActionsApi(tb.ControllerTest, tb.MuranoApiTestCase): test_utils.save_models(e) rpc_task = { - 'tenant_id': self.tenant, - 'model': {'Objects': {'applications': [], '?': - { - '_actions': {'actionsID_action': { - 'name': 'Testaction', 'enabled': True}}, - 'id': '12345'}}, 'Attributes': {}}, 'action': { + 'args': '{}', 'method': 'Testaction', - 'object_id': '12345', - 'args': '{}'}, + 'object_id': '12345' + }, + 'tenant_id': self.tenant, + 'model': { + 'Attributes': {}, + 'Objects': { + 'applications': [], + '?': { + '_actions': { + 'actionsID_action': { + 'enabled': True, + 'name': 'Testaction' + } + }, + 'id': '12345' + } + } + }, 'token': None, 'id': '12345' } diff --git a/murano/tests/unit/policy/test_congress_rules.py b/murano/tests/unit/policy/test_congress_rules.py index f92ad7cd..479260fa 100644 --- a/murano/tests/unit/policy/test_congress_rules.py +++ b/murano/tests/unit/policy/test_congress_rules.py @@ -23,7 +23,7 @@ import murano.policy.congress_rules as congress class MockClassLoader(object): def __init__(self, rules): - """Create rules like this: ['child->parent', 'child->parent2']""" + """Create rules like this: ['child->parent', 'child->parent2'].""" self._rules_dict = {} for rule in rules: @@ -34,7 +34,7 @@ class MockClassLoader(object): self._rules_dict[split[0]] = [split[1]] def get_class(self, name): - if not name in self._rules_dict: + if name not in self._rules_dict: return None parents = [] for parent_name in self._rules_dict[name]: @@ -214,7 +214,7 @@ class TestCongressRules(unittest.TestCase): with open(expected_rules_file) as f: for line in f: line = line.rstrip('\n') - if not line in rules_str: + if line not in rules_str: s += 'Expected rule not found:\n\t' + line + '\n' if len(s) > 0: diff --git a/murano/tests/unit/test_log.py b/murano/tests/unit/test_log.py index 7e2236fb..3b38635c 100644 --- a/murano/tests/unit/test_log.py +++ b/murano/tests/unit/test_log.py @@ -38,7 +38,7 @@ class SysLogHandlersTestCase(base.MuranoTestCase): self.logger.binary_name = 'Foo_application' def test_rfc_format(self): - """Ensure syslog msg contains APP-NAME for RFC wrapped handler""" + """Ensure syslog msg contains APP-NAME for RFC wrapped handler.""" logrecord = logging.LogRecord('name', 'WARN', '/tmp', 1, 'Message', None, None) expected = logging.LogRecord('name', 'WARN', '/tmp', 1, @@ -47,7 +47,7 @@ class SysLogHandlersTestCase(base.MuranoTestCase): expected.getMessage()) def test_standard_format(self): - """Ensure syslog msg isn't modified for standard handler""" + """Ensure syslog msg isn't modified for standard handler.""" logrecord = logging.LogRecord('name', 'WARN', '/tmp', 1, 'Message', None, None) expected = logrecord diff --git a/tox.ini b/tox.ini index 7a0763f1..19da3b36 100644 --- a/tox.ini +++ b/tox.ini @@ -38,24 +38,19 @@ commands = flake8 commands = oslo-config-generator --config-file etc/oslo-config-generator/murano.conf [flake8] -# E122 Continuation line missing indentation or outdented -# E128 Continuation line under-indented for visual indent -# E265 Block comment should start with '# ' -# E713 Test for membership should be 'not in' -# F402 Shadowed by local variable -# H233 Python 3.x incompatible use of print operator -# H305 Imports not grouped correctly -# H307 Like imports should be grouped together -# H402 One line docstring needs punctuation. +# H233 Python 3.x incompatible use of print operator +# E265 block comment should start with '# ' +# H305 imports not grouped correctly +# H307 like imports should be grouped together # H405 Multi line docstring summary not separated with an empty line -# H501 Do not use locals() for string formatting # H702 Argument to _ must be just a string -# H902 Use the 'not in' operator for collection membership evaluation -# H904 Wrap long lines in parentheses instead of a backslash -ignore =E122,E128,E265,E713,F402,H233,H305,H307,H402,H405,H501,H702,H902,H904 +# H904 Wrap long lines in parentheses instead of a backslash + +ignore = H233,H305,H307,E265,H405,H702,H904 show-source = true builtins = _ exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,tools [hacking] -import_exceptions = murano.openstack.common.gettextutils +import_exceptions = murano.openstack.common.gettextutils, + oslo.db.sqlalchemy.test_base