Merge "Bump to hacking 1.1.0"

This commit is contained in:
Zuul 2019-07-05 03:04:05 +00:00 committed by Gerrit Code Review
commit 7435a2e7bd
19 changed files with 60 additions and 51 deletions

View File

@ -85,7 +85,6 @@ packaging==17.1
Paste==2.0.2
PasteDeploy==1.5.0
pbr==2.0.0
pep8==1.5.7
pika-pool==0.1.3
pika==0.10.0
ply==3.11
@ -93,6 +92,7 @@ prettytable==0.7.2
psutil==3.2.2
psycopg2==2.7.0
pycadf==2.7.0
pycodestyle==2.0.0
pycparser==2.18
pyflakes==0.8.1
Pygments==2.2.0

View File

@ -137,21 +137,21 @@ class Controller(object):
"""WSGI controller for application catalog resource in Murano v1 API."""
def _validate_limit(self, value):
if value is None:
return
try:
value = int(value)
except ValueError:
msg = _("Limit param must be an integer")
LOG.error(msg)
raise exc.HTTPBadRequest(explanation=msg)
if value is None:
return
try:
value = int(value)
except ValueError:
msg = _("Limit param must be an integer")
LOG.error(msg)
raise exc.HTTPBadRequest(explanation=msg)
if value <= 0:
msg = _("Limit param must be positive")
LOG.error(msg)
raise exc.HTTPBadRequest(explanation=msg)
if value <= 0:
msg = _("Limit param must be positive")
LOG.error(msg)
raise exc.HTTPBadRequest(explanation=msg)
return value
return value
def update(self, req, body, package_id):
"""List of allowed changes

View File

@ -139,9 +139,9 @@ class Controller(object):
LOG.exception(msg)
raise exc.HTTPBadRequest(msg)
except Exception:
msg = _('EnvTemplate body is incorrect')
LOG.exception(msg)
raise exc.HTTPBadRequest(msg)
msg = _('EnvTemplate body is incorrect')
LOG.exception(msg)
raise exc.HTTPBadRequest(msg)
template = env_temps.EnvTemplateServices.update(env_template_id, body)
return template.to_dict()

View File

@ -228,7 +228,7 @@ class MuranoTestRunner(object):
num_tests = 0
for pkg_class, test_cases in run_set.items():
for m in test_cases:
max_length = max(max_length, len(pkg_class)+len(m)+1)
max_length = max(max_length, len(pkg_class) + len(m) + 1)
num_tests += len(test_cases)
max_length += 3
@ -300,7 +300,7 @@ class MuranoTestRunner(object):
'{3} failed'.format(run_count,
timeutils.delta_seconds(
started, completed),
run_count-error_count,
run_count - error_count,
error_count))
return exit_code

View File

@ -293,10 +293,10 @@ for group in ('heat', 'mistral', 'neutron', 'glance', 'glare',
CONF,
group=group,
deprecated_opts={
'cafile': [cfg.DeprecatedOpt('cacert', group),
cfg.DeprecatedOpt('ca_file', group)],
'cafile': [cfg.DeprecatedOpt('cacert', group),
cfg.DeprecatedOpt('ca_file', group)],
'certfile': [cfg.DeprecatedOpt('cert_file', group)],
'keyfile': [cfg.DeprecatedOpt('key_file', group)]
'keyfile': [cfg.DeprecatedOpt('key_file', group)]
})

View File

@ -110,7 +110,7 @@ class MqClient(object):
data = jsonutils.dumps(message.body)
headers = None
if signing_func:
headers = {'signature': signing_func(data)}
headers = {'signature': signing_func(data)}
producer.publish(
exchange=str(exchange),

View File

@ -255,7 +255,7 @@ class CoreServices(object):
if service["?"]["id"]:
if service["?"]["id"] == id:
break
count+1
count + 1
utils.TraverseHelper.update("services/{0}".format(count),
data, temp_description)

View File

@ -54,7 +54,8 @@ class EnvTemplateServices(object):
@staticmethod
def create(env_template_params, tenant_id):
"""Creates environment-template with specified params, in particular - name.
"""Creates environment-template with specified params,
in particular - name.
:param env_template_params: Dict, e.g. {'name': 'temp-name'}
:param tenant_id: Tenant Id
@ -183,7 +184,8 @@ class EnvTemplateServices(object):
@staticmethod
def clone(env_template_id, tenant_id, env_template_name, is_public):
"""Clones environment-template with specified params, in particular - name.
"""Clones environment-template with specified params,
in particular - name.
:param env_template_params: Dict, e.g. {'name': 'temp-name'}
:param tenant_id: Tenant Id

View File

@ -103,7 +103,7 @@ def format_frame(frame, prefix=''):
def create_stack_trace(context, include_native_frames=True):
stacktrace = yaql_integration.call_func(
context, 'new', 'io.murano.StackTrace',
includeNativeFrames=include_native_frames)
return dsl.MuranoObjectInterface.create(stacktrace)
stacktrace = yaql_integration.call_func(
context, 'new', 'io.murano.StackTrace',
includeNativeFrames=include_native_frames)
return dsl.MuranoObjectInterface.create(stacktrace)

View File

@ -217,7 +217,7 @@ def type_to_type_ref(murano_type):
@specs.parameter('provider', meta.MetaProvider)
@specs.name('#property#meta')
def get_meta(context, provider):
return provider.get_meta(context)
return provider.get_meta(context)
@specs.yaql_property(dsl_types.MuranoMetaClass)
@ -251,6 +251,7 @@ def register(context):
for f in funcs:
context.register_function(f)
yaqlization.yaqlize(semantic_version.Version, whitelist=[
'major', 'minor', 'patch', 'prerelease', 'build'
])

View File

@ -48,7 +48,7 @@ def _serialize_object(root_object, designer_attributes, allow_refs,
obj = root_object
if isinstance(obj, dsl.MuranoObjectInterface):
obj = obj.object
parent = obj.owner if isinstance(obj, dsl_types.MuranoObject) else None
parent = obj.owner if isinstance(obj, dsl_types.MuranoObject) else None
while True:
obj, need_another_pass = _pass12_serialize(
obj, parent, serialized_objects, designer_attributes, executor,
@ -255,8 +255,8 @@ def collect_objects(root_object):
for t in rec(value):
yield t
elif isinstance(obj, dsl_types.MuranoObjectInterface):
for t in rec(obj.object):
yield t
for t in rec(obj.object):
yield t
elif isinstance(obj, dsl_types.MuranoObject) and obj not in visited:
visited.add(obj)
yield obj

View File

@ -71,6 +71,7 @@ def _create_engine(runtime_version):
def _finalize(obj, context):
return helpers.evaluate(obj, context)
CONVENTION = conventions.CamelCaseConvention()
ENGINE_10 = _create_engine(constants.RUNTIME_VERSION_1_0)
ENGINE_12 = _create_engine(constants.RUNTIME_VERSION_1_2)

View File

@ -35,6 +35,7 @@ def _construct_yaml_str(self, node):
# to always return unicode objects
return self.construct_scalar(node)
yaml_loader.add_constructor(u'tag:yaml.org,2002:str', _construct_yaml_str)
# Unquoted dates like 2013-05-23 in yaml files get loaded as objects of type
# datetime.data which causes problems in API layer when being processed by

View File

@ -159,13 +159,13 @@ class TestController(base.MuranoTestCase):
def test_package_to_service(self):
mock_package = mock.Mock(
spec_set=models.Package, id='foo_package_id',
description='a'*257, tags=[mock.sentinel.package_tag])
description='a' * 257, tags=[mock.sentinel.package_tag])
mock_package.configure_mock(name=mock.sentinel.package_name)
expected_service = {
'id': 'foo_package_id',
'name': mock.sentinel.package_name,
'description': 'a'*253 + ' ...',
'description': 'a' * 253 + ' ...',
'bindable': True,
'tags': [mock.sentinel.package_tag],
'plans': [{

View File

@ -751,7 +751,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
{'package_id': saved_package.id})
data = []
data.append({'op': 'replace', 'path': ['name'], 'value': 'a'*81})
data.append({'op': 'replace', 'path': ['name'], 'value': 'a' * 81})
req = self._patch(url, jsonutils.dump_as_bytes(data))
self.assertRaises(exc.HTTPBadRequest, self.controller.update,
req, data, saved_package.id)
@ -926,7 +926,7 @@ class TestCatalogApi(test_base.ControllerTest, test_base.MuranoApiTestCase):
mock_pkg_params_map.return_value = {}
mock_request = mock.MagicMock(context=mock.MagicMock(
tenant=self.tenant))
test_package_meta = {'name': 'a'*81}
test_package_meta = {'name': 'a' * 81}
with tempfile.NamedTemporaryFile(delete=True) as temp_file:
temp_file.write(b"Random test content\n")
temp_file.seek(0)

View File

@ -33,8 +33,8 @@ class TestConcurrency(test_case.DslTestCase):
def check_isolated_traces(self):
for i in range(0, len(self.traces), 3):
before = self.traces[i]
switch = self.traces[i+1]
after = self.traces[i+2]
switch = self.traces[i + 1]
after = self.traces[i + 2]
self.assertEqual('yield', switch)
self.assertEqual(before[0:6], after[0:6])
self.assertTrue(before.endswith('-before'))

View File

@ -13,7 +13,7 @@
# under the License.
import mock
import pep8
import pycodestyle
import textwrap
from murano.hacking import checks
@ -24,10 +24,11 @@ class HackingTestCase(base.MuranoTestCase):
"""Tests the hacking checks in murano.hacking.checks
This class tests the hacking checks in murano.hacking.checks by passing
strings to the check methods like the pep8/flake8 parser would. The parser
loops over each line in the file and then passes the parameters to the
check method. The parameter names in the check method dictate what type of
object is passed to the check method. The parameter types are::
strings to the check methods like the pycodestyle/flake8 parser would.
The parser loops over each line in the file and then passes the
parameters to the check method. The parameter names in the check method
dictate what type of object is passed to the check method.
The parameter types are::
logical_line: A processed line with the following modifications:
- Multi-line statements converted to a single line.
- Stripped left and right.
@ -43,24 +44,24 @@ class HackingTestCase(base.MuranoTestCase):
indent_level: indentation (with tabs expanded to multiples of 8)
previous_indent_level: indentation on previous line
previous_logical: previous logical line
filename: Path of the file being run through pep8
filename: Path of the file being run through pycodestyle
When running a test on a check method the return will be False/None if
there is no violation in the sample input. If there is an error a tuple is
returned with a position in the line, and a message. So to check the result
just assertTrue if the check is expected to fail and assertFalse if it
should pass.
"""
# We are patching pep8 so that only the check under test is actually
# We are patching pycodestyle so that only the check under test is actually
# installed.
@mock.patch('pep8._checks',
@mock.patch('pycodestyle._checks',
{'physical_line': {}, 'logical_line': {}, 'tree': {}})
def _run_check(self, code, checker, filename=None):
pep8.register_check(checker)
pycodestyle.register_check(checker)
lines = textwrap.dedent(code).strip().splitlines(True)
checker = pep8.Checker(filename=filename, lines=lines)
checker = pycodestyle.Checker(filename=filename, lines=lines)
checker.check_all()
checker.report._deferred_print.sort()
return checker.report._deferred_print

View File

@ -1,7 +1,7 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
hacking>=1.1.0,<1.2.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
fixtures>=3.0.0 # Apache-2.0/BSD
@ -14,6 +14,7 @@ testresources>=2.0.0 # Apache-2.0/BSD
testscenarios>=0.4 # Apache-2.0/BSD
unittest2>=1.1.0 # BSD
pylint==1.4.5 # GPLv2
pycodestyle>=2.0.0 # MIT License
requests>=2.14.2 # Apache-2.0
stestr>=1.0.0 # Apache-2.0
murano-pkg-check>=0.3.0 # Apache-2.0

View File

@ -102,6 +102,8 @@ whitelist_externals = rm
[flake8]
show-source = true
builtins = _
# W605 invalid escape sequence
ignore = W605,W504,W503,E123,H405
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
[hacking]