diff --git a/lower-constraints.txt b/lower-constraints.txt index e00a6270..1900d019 100644 --- a/lower-constraints.txt +++ b/lower-constraints.txt @@ -25,9 +25,7 @@ dulwich==0.19.0 extras==1.0.0 fasteners==0.14.1 fixtures==3.0.0 -flake8==2.5.5 futurist==1.6.0 -hacking==0.12.0 horizon==17.1.0 idna==2.6 imagesize==1.0.0 @@ -64,11 +62,9 @@ oslo.utils==3.33.0 osprofiler==2.0.0 packaging==17.1 pbr==2.0.0 -pep8==1.5.7 Pint==0.8.1 prettytable==0.7.2 pycparser==2.18 -pyflakes==0.8.1 Pygments==2.2.0 pyinotify==0.9.6 pymongo==3.6.1 diff --git a/manila_ui/dashboards/admin/shares/replicas/tables.py b/manila_ui/dashboards/admin/shares/replicas/tables.py index 4ea58743..14b3dcfd 100644 --- a/manila_ui/dashboards/admin/shares/replicas/tables.py +++ b/manila_ui/dashboards/admin/shares/replicas/tables.py @@ -122,7 +122,7 @@ class DeleteReplica(tables.DeleteAction): replicas = manila.share_replica_list(request, replica.share_id) if share.replication_type is None: return False - elif (share.replication_type is 'writable' and + elif (share.replication_type == 'writable' and replica.status in DELETABLE_STATUSES and len(replicas) > 1) or ( share.replication_type in ('dr', 'readable') and diff --git a/manila_ui/dashboards/project/shares/replicas/tables.py b/manila_ui/dashboards/project/shares/replicas/tables.py index 9d958a71..7675a4dc 100644 --- a/manila_ui/dashboards/project/shares/replicas/tables.py +++ b/manila_ui/dashboards/project/shares/replicas/tables.py @@ -108,7 +108,7 @@ class DeleteReplica(tables.DeleteAction): replicas = manila.share_replica_list(request, replica.share_id) if share.replication_type is None: return False - elif (share.replication_type is 'writable' and + elif (share.replication_type == 'writable' and replica.status in DELETABLE_STATUSES and len(replicas) > 1) or ( share.replication_type in ('dr', 'readable') and diff --git a/manila_ui/dashboards/utils.py b/manila_ui/dashboards/utils.py index 567c4de8..af3c7946 100644 --- a/manila_ui/dashboards/utils.py +++ b/manila_ui/dashboards/utils.py @@ -44,7 +44,7 @@ def parse_str_meta(meta_s): for string in strings: if string.count("=") == 0: # Key for unsetting - key = string.strip('\"\'\ ') + key = string.strip(r'\"\' ') if len(key) not in range(1, 256): msg = _("Key '%s' has improper length.") % key elif " " in key: @@ -53,7 +53,7 @@ def parse_str_meta(meta_s): unset_list.append(key) else: # Key-value pair for setting - pair = [p.strip('\"\'\ ') for p in string.split("=", 1)] + pair = [p.strip(r'\"\' ') for p in string.split("=", 1)] if not all(len(p) in range(1, 256) for p in pair): msg = _("All keys and values must be in range from 1 to 255.") elif pair[0] in list(set_dict.keys()): diff --git a/manila_ui/tests/dashboards/project/shares/tests.py b/manila_ui/tests/dashboards/project/shares/tests.py index 36c36895..d4556749 100644 --- a/manila_ui/tests/dashboards/project/shares/tests.py +++ b/manila_ui/tests/dashboards/project/shares/tests.py @@ -635,34 +635,34 @@ class ShareViewTests(test.APITestCase): data.update({'is_public': is_public}) with self.settings(OPENSTACK_MANILA_FEATURES={ - 'enable_public_shares': enable_public_shares}): - form = _get_form() - result = form.handle(self.request, data) - self.assertTrue(result) - self.assertEqual( - enable_public_shares, - form.enable_public_shares) - if enable_public_shares: - self.assertIn("is_public", form.fields) - self.assertTrue(form.fields["is_public"]) - else: - self.assertNotIn("is_public", form.fields) - api_manila.share_create.assert_called_once_with( - self.request, - availability_zone=data['availability_zone'], - description=data['description'], - is_public=is_public, - metadata=utils.parse_str_meta(data['metadata'])[0], - name=data['name'], - proto=data['share_proto'], - share_group_id=None, - share_network=test_data.active_share_network.id, - share_type=data['share_type'], - size=data['size'], - snapshot_id=data['snapshot_id'], - ) - horizon_messages.success.assert_called_once_with( - self.request, mock.ANY) + 'enable_public_shares': enable_public_shares}): + form = _get_form() + result = form.handle(self.request, data) + self.assertTrue(result) + self.assertEqual( + enable_public_shares, + form.enable_public_shares) + if enable_public_shares: + self.assertIn("is_public", form.fields) + self.assertTrue(form.fields["is_public"]) + else: + self.assertNotIn("is_public", form.fields) + api_manila.share_create.assert_called_once_with( + self.request, + availability_zone=data['availability_zone'], + description=data['description'], + is_public=is_public, + metadata=utils.parse_str_meta(data['metadata'])[0], + name=data['name'], + proto=data['share_proto'], + share_group_id=None, + share_network=test_data.active_share_network.id, + share_type=data['share_type'], + size=data['size'], + snapshot_id=data['snapshot_id'], + ) + horizon_messages.success.assert_called_once_with( + self.request, mock.ANY) @ddt.data((True, True), (True, False), (False, False)) @ddt.unpack @@ -689,24 +689,24 @@ class ShareViewTests(test.APITestCase): data.update({'is_public': is_public}) with self.settings(OPENSTACK_MANILA_FEATURES={ - 'enable_public_shares': enable_public_shares}): - form = _get_form(initial) - result = form.handle(self.request, data) - self.assertTrue(result) - self.assertEqual( - enable_public_shares, - form.enable_public_shares) - if enable_public_shares: - self.assertIn("is_public", form.fields) - self.assertTrue(form.fields["is_public"]) - else: - self.assertNotIn("is_public", form.fields) - api_manila.share_update.assert_called_once_with( - self.request, - self.share, - data['name'], - data['description'], - is_public=is_public, - ) - horizon_messages.success.assert_called_once_with( - self.request, mock.ANY) + 'enable_public_shares': enable_public_shares}): + form = _get_form(initial) + result = form.handle(self.request, data) + self.assertTrue(result) + self.assertEqual( + enable_public_shares, + form.enable_public_shares) + if enable_public_shares: + self.assertIn("is_public", form.fields) + self.assertTrue(form.fields["is_public"]) + else: + self.assertNotIn("is_public", form.fields) + api_manila.share_update.assert_called_once_with( + self.request, + self.share, + data['name'], + data['description'], + is_public=is_public, + ) + horizon_messages.success.assert_called_once_with( + self.request, mock.ANY) diff --git a/manila_ui/tests/test_data/keystone_data.py b/manila_ui/tests/test_data/keystone_data.py index 67d79b0d..e32a023a 100644 --- a/manila_ui/tests/test_data/keystone_data.py +++ b/manila_ui/tests/test_data/keystone_data.py @@ -25,6 +25,7 @@ def data(TEST): "publicURL": "http://public.manila.example.com:8786/v1"}]}, ) + projects = [ type("%sProject" % v, (object, ), {'id': '%s_id' % v, 'name': '%s_name' % v}) diff --git a/test-requirements.txt b/test-requirements.txt index 4dfa1c99..a75dbf5d 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,7 +2,7 @@ # of appearance. Changing the order has an impact on the overall integration # process, which may cause wedges in the gate later. -hacking>=1.1.0,<1.2.0 # Apache-2.0 +hacking>=3.0,<3.1.0 # Apache-2.0 coverage!=4.4,>=4.0 # Apache-2.0 ddt>=1.0.1 # MIT python-subunit>=1.0.0 # Apache-2.0/BSD diff --git a/tox.ini b/tox.ini index 7d2a0f99..88a20410 100644 --- a/tox.ini +++ b/tox.ini @@ -79,7 +79,8 @@ show-source = True # F405 TEMPLATES may be undefined, or defined from star imports # (because it is not easy to avoid this in openstack_dashboard.test.settings) # H405 multi line docstring summary not separated with an empty line -ignore = E123,E125,F405,H405 +# W504 line break after binary operator +ignore = E123,E125,F405,H405,W504 enable-extensions = H203,H106 exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,.ropeproject,tools