Browse Source

Update hacking for Python3

The repo is Python 3 now, so update hacking to version 3.0 which
supports Python 3.

Fix problems found.

Update local hacking checks for new flake8.

Change-Id: I7073a478d38fb46619e7a300808e9449403e704d
tags/9.0.0.0rc1
Andreas Jaeger 3 months ago
committed by Andreas Jaeger
parent
commit
c80e23edfd
13 changed files with 39 additions and 36 deletions
  1. +1
    -1
      muranodashboard/catalog/forms.py
  2. +1
    -1
      muranodashboard/catalog/views.py
  3. +1
    -0
      muranodashboard/dashboard.py
  4. +2
    -2
      muranodashboard/dynamic_ui/fields.py
  5. +2
    -1
      muranodashboard/dynamic_ui/yaql_expression.py
  6. +2
    -2
      muranodashboard/environments/api.py
  7. +17
    -17
      muranodashboard/environments/tabs.py
  8. +1
    -0
      muranodashboard/tests/functional/config/config.py
  9. +6
    -6
      muranodashboard/tests/test_tabs.py
  10. +2
    -2
      muranodashboard/tests/unit/common/test_net.py
  11. +2
    -2
      muranodashboard/tests/unit/packages/test_forms.py
  12. +1
    -1
      test-requirements.txt
  13. +1
    -1
      tox.ini

+ 1
- 1
muranodashboard/catalog/forms.py View File

@@ -37,6 +37,6 @@ class WorkflowManagementForm(object):
'Just A-Z, a-z, 0-9, dash and underline'
' are allowed',
'label': 'Application Name',
'regexpValidator': '^[-\w]+$',
'regexpValidator': r'^[-\w]+$',
'initial': fqn.split('.')[-1]
}

+ 1
- 1
muranodashboard/catalog/views.py View File

@@ -139,7 +139,7 @@ def switch(request, environment_id,

def get_next_quick_environment_name(request):
quick_env_prefix = 'quick-env-'
quick_env_re = re.compile('^' + quick_env_prefix + '([\d]+)$')
quick_env_re = re.compile(r'^' + quick_env_prefix + r'([\d]+)$')

def parse_number(env):
match = re.match(quick_env_re, env.name)


+ 1
- 0
muranodashboard/dashboard.py View File

@@ -26,6 +26,7 @@ class AppCatalog(horizon.Dashboard):
default_panel = "environments"
supports_tenants = True


try:
horizon.base.Horizon.registered('app-catalog')
except horizon.base.NotRegistered:


+ 2
- 2
muranodashboard/dynamic_ui/fields.py View File

@@ -254,8 +254,8 @@ class CharField(forms.CharField, CustomPropertiesField):


class PasswordField(CharField):
special_characters = '!@#$%^&*()_+|\/.,~?><:{}-'
password_re = re.compile('^.*(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[%s]).*$'
special_characters = '!@#$%^&*()_+|\\/.,~?><:{}-'
password_re = re.compile(r'^.*(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[%s]).*$'
% special_characters)
has_clone = False
original = True


+ 2
- 1
muranodashboard/dynamic_ui/yaql_expression.py View File

@@ -25,6 +25,7 @@ def _set_up_yaql():
}
return yaql.YaqlFactory().create(options=legacy_engine_options)


YAQL = _set_up_yaql()


@@ -46,7 +47,7 @@ class YaqlExpression(object):
def match(expr):
if not isinstance(expr, str):
return False
if re.match('^[\s\w\d.:]*$', expr):
if re.match(r'^[\s\w\d.:]*$', expr):
return False
try:
YAQL(expr)


+ 2
- 2
muranodashboard/environments/api.py View File

@@ -44,8 +44,8 @@ def get_status_messages_for_service(request, service_id, environment_id):
environment_id, deployment.id, service_id)

for report in reports:
result += utils.adjust_datestr(request, report.created) + ' - ' + \
report.text + '\n'
result += (utils.adjust_datestr(request, report.created) +
' - ' + report.text + '\n')
return result




+ 17
- 17
muranodashboard/environments/tabs.py View File

@@ -108,26 +108,26 @@ class OverviewTab(tabs.Tab):
# after it would be possible
if hasattr(service_data,
'instance') and service_data['instance'] is not None:
instance, stack = get_instance_and_stack(
service_data['instance'], request)
if instance:
detail_info['Instance'] = instance
if stack:
detail_info['Stack'] = stack
instance, stack = get_instance_and_stack(
service_data['instance'], request)
if instance:
detail_info['Instance'] = instance
if stack:
detail_info['Stack'] = stack

if hasattr(service_data,
'instances') and service_data['instances'] is not None:
instances_for_template = []
stacks_for_template = []
for instance in service_data['instances']:
instance, stack = get_instance_and_stack(instance, request)
instances_for_template.append(instance)
if stack:
stacks_for_template.append(stack)
if instances_for_template:
detail_info['Instances'] = instances_for_template
if stacks_for_template:
detail_info['Stacks'] = stacks_for_template
instances_for_template = []
stacks_for_template = []
for instance in service_data['instances']:
instance, stack = get_instance_and_stack(instance, request)
instances_for_template.append(instance)
if stack:
stacks_for_template.append(stack)
if instances_for_template:
detail_info['Instances'] = instances_for_template
if stacks_for_template:
detail_info['Stacks'] = stacks_for_template

return {'service': detail_info}



+ 1
- 0
muranodashboard/tests/functional/config/config.py View File

@@ -48,6 +48,7 @@ def register_config(config, config_group, config_opts):
config.register_group(config_group)
config.register_opts(config_opts, config_group)


path = os.path.join(os.path.dirname(__file__), "config.conf")

if os.path.exists(path):


+ 6
- 6
muranodashboard/tests/test_tabs.py View File

@@ -37,13 +37,13 @@ class TestLicenseTab(helpers.APITestCase):
app.id = 1

group = tabs.ApplicationTabs(self.request, application=app)
l = group.get_tabs()[2]
li = group.get_tabs()[2]

# Should return the license description
l._get_license()
li._get_license()
self.assertEqual(
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
l.app.license)
li.app.license)

@mock.patch('muranodashboard.catalog.tabs.services')
def test_no_license(self, mock_services):
@@ -59,11 +59,11 @@ class TestLicenseTab(helpers.APITestCase):
app.id = 1

group = tabs.ApplicationTabs(self.request, application=app)
l = group.get_tabs()[2]
li = group.get_tabs()[2]

# Should return the license description
l._get_license()
self.assertEqual('', l.app.license)
li._get_license()
self.assertEqual('', li.app.license)


class TestRequirementsTab(helpers.APITestCase):


+ 2
- 2
muranodashboard/tests/unit/common/test_net.py View File

@@ -49,7 +49,7 @@ class TestNet(unittest.TestCase):
foo_mock_network, bar_mock_network
]

test_filter = '^foo\-[\w]+'
test_filter = r'^foo\-[\w]+'
result = net.get_available_networks(self.mock_request,
filter=test_filter,
murano_networks='include')
@@ -82,7 +82,7 @@ class TestNet(unittest.TestCase):
foo_mock_network, bar_mock_network
]

test_filter = '^[\w]+\-[\w]+'
test_filter = r'^[\w]+\-[\w]+'
result = net.get_available_networks(self.mock_request,
filter=test_filter,
murano_networks='include')


+ 2
- 2
muranodashboard/tests/unit/packages/test_forms.py View File

@@ -72,8 +72,8 @@ class TestImportPackageForm(helpers.APITestCase):
'package': mock_package
}

expected_error_msg = 'It is forbidden to upload files larger than {0} '\
'MB.'.format(consts.MAX_FILE_SIZE_MB)
expected_error_msg = 'It is forbidden to upload files larger than '\
'{0} MB.'.format(consts.MAX_FILE_SIZE_MB)
with self.assertRaisesRegex(django_forms.ValidationError,
expected_error_msg):
self.import_pkg_form.clean_package()


+ 1
- 1
test-requirements.txt 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>=3.0,<4.0.0 # Apache-2.0

coverage!=4.4,>=4.0 # Apache-2.0
oslo.config>=5.2.0 # Apache-2.0


+ 1
- 1
tox.ini View File

@@ -63,7 +63,7 @@ commands =

[flake8]
# H202: assertRaises Exception too broad
ignore = H202
ignore = H202,W504
show-source = true
builtins = _
exclude=build,.git,.tox,dist,doc,*lib/python*,*egg,tools,horizon,settings.py,*/local/*,functional_tests,node_modules


Loading…
Cancel
Save