Browse Source

Update hacking for Python3

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

Fix found problems.

Change-Id: I78ee32da2b158abda1ca4438c23c5245dd8849b2
tags/2.1.0
Andreas Jaeger 3 months ago
committed by Andreas Jaeger
parent
commit
7cf94c6527
28 changed files with 45 additions and 25 deletions
  1. +1
    -1
      manilaclient/common/httpclient.py
  2. +1
    -1
      manilaclient/exceptions.py
  3. +0
    -1
      manilaclient/osc/v2/share.py
  4. +6
    -6
      manilaclient/tests/functional/base.py
  5. +2
    -1
      manilaclient/tests/functional/client.py
  6. +1
    -1
      manilaclient/tests/functional/test_common.py
  7. +2
    -2
      manilaclient/tests/unit/common/test_httpclient.py
  8. +1
    -0
      manilaclient/tests/unit/v2/fakes.py
  9. +8
    -7
      manilaclient/tests/unit/v2/test_limits.py
  10. +1
    -0
      manilaclient/v1/__init__.py
  11. +1
    -0
      manilaclient/v1/contrib/list_extensions.py
  12. +1
    -0
      manilaclient/v1/limits.py
  13. +1
    -0
      manilaclient/v1/quota_classes.py
  14. +1
    -0
      manilaclient/v1/quotas.py
  15. +1
    -0
      manilaclient/v1/scheduler_stats.py
  16. +1
    -0
      manilaclient/v1/security_services.py
  17. +1
    -0
      manilaclient/v1/services.py
  18. +1
    -0
      manilaclient/v1/share_networks.py
  19. +1
    -0
      manilaclient/v1/share_servers.py
  20. +1
    -0
      manilaclient/v1/share_snapshots.py
  21. +1
    -0
      manilaclient/v1/share_type_access.py
  22. +1
    -0
      manilaclient/v1/share_types.py
  23. +1
    -0
      manilaclient/v1/shares.py
  24. +3
    -3
      manilaclient/v2/shares.py
  25. +1
    -0
      manilaclient/v2/shell.py
  26. +1
    -1
      test-requirements.txt
  27. +1
    -0
      tools/install_venv.py
  28. +3
    -1
      tox.ini

+ 1
- 1
manilaclient/common/httpclient.py View File

@@ -83,7 +83,7 @@ class HTTPClient(object):
"""Truncates url and returns base endpoint"""
service_endpoint = parse.urlparse(url)
service_endpoint_base_path = re.search(
'(.+?)/v([0-9]+|[0-9]+\.[0-9]+)(/.*|$)', service_endpoint.path)
r'(.+?)/v([0-9]+|[0-9]+\.[0-9]+)(/.*|$)', service_endpoint.path)
base_path = (service_endpoint_base_path.group(1)
if service_endpoint_base_path else '')
base_url = service_endpoint._replace(path=base_path)


+ 1
- 1
manilaclient/exceptions.py View File

@@ -20,7 +20,7 @@ Exception definitions.
from manilaclient.common.apiclient.exceptions import * # noqa


class NoTokenLookupException(ClientException):
class NoTokenLookupException(ClientException): # noqa: F405
"""No support for looking up endpoints.

This form of authentication does not support looking up


+ 0
- 1
manilaclient/osc/v2/share.py View File

@@ -492,7 +492,6 @@ class ListShare(command.Lister):
'project_id': project_id,
'user_id': user_id,
'offset': parsed_args.marker,
'limit': parsed_args.limit,
}

# NOTE(vkmc) We implemented sorting and filtering in manilaclient


+ 6
- 6
manilaclient/tests/functional/base.py View File

@@ -104,17 +104,17 @@ class BaseTestCase(base.ClientTestBase):
deletion_params = res.get("deletion_params")
with handle_cleanup_exceptions():
# TODO(vponomaryov): add support for other resources
if res["type"] is "share_type":
if res["type"] == "share_type":
client.delete_share_type(
res_id, microversion=res["microversion"])
client.wait_for_share_type_deletion(
res_id, microversion=res["microversion"])
elif res["type"] is "share_network":
elif res["type"] == "share_network":
client.delete_share_network(
res_id, microversion=res["microversion"])
client.wait_for_share_network_deletion(
res_id, microversion=res["microversion"])
elif res["type"] is "share_network_subnet":
elif res["type"] == "share_network_subnet":
client.delete_share_network_subnet(
share_network_subnet=res_id,
share_network=deletion_params["share_network"],
@@ -123,17 +123,17 @@ class BaseTestCase(base.ClientTestBase):
share_network_subnet=res_id,
share_network=deletion_params["share_network"],
microversion=res["microversion"])
elif res["type"] is "share":
elif res["type"] == "share":
client.delete_share(
res_id, microversion=res["microversion"])
client.wait_for_share_deletion(
res_id, microversion=res["microversion"])
elif res["type"] is "snapshot":
elif res["type"] == "snapshot":
client.delete_snapshot(
res_id, microversion=res["microversion"])
client.wait_for_snapshot_deletion(
res_id, microversion=res["microversion"])
elif res["type"] is "share_replica":
elif res["type"] == "share_replica":
client.delete_share_replica(
res_id, microversion=res["microversion"])
client.wait_for_share_replica_deletion(


+ 2
- 1
manilaclient/tests/functional/client.py View File

@@ -46,7 +46,8 @@ def not_found_wrapper(f):
try:
return f(self, *args, **kwargs)
except tempest_lib_exc.CommandFailed as e:
for regexp in ('No (\w+) with a name or ID', 'not(.*){0,5}found'):
for regexp in (r'No (\w+) with a name or ID',
r'not(.*){0,5}found'):
if re.search(regexp, six.text_type(e.stderr)):
# Raise appropriate 'NotFound' error
raise tempest_lib_exc.NotFound()


+ 1
- 1
manilaclient/tests/functional/test_common.py View File

@@ -36,7 +36,7 @@ class ManilaClientTestCommonReadOnly(base.BaseTestCase):
commands = []
cmds_start = lines.index('Positional arguments:')
cmds_end = lines.index('Optional arguments:')
command_pattern = re.compile('^ {4}([a-z0-9\-\_]+)')
command_pattern = re.compile(r'^ {4}([a-z0-9\-\_]+)')
for line in lines[cmds_start:cmds_end]:
match = command_pattern.match(line)
if match:


+ 2
- 2
manilaclient/tests/unit/common/test_httpclient.py View File

@@ -119,7 +119,7 @@ class ClientTest(utils.TestCase):
**self.TEST_REQUEST_BASE)
# Automatic JSON parsing
self.assertEqual(body, {"hi": "there"})
self.assertEqual(re.split('/v[0-9]+[\.0-9]*',
self.assertEqual(re.split(r'/v[0-9]+[\.0-9]*',
endpoint_url)[0] + "/", cl.base_url)

test_get_call()
@@ -231,7 +231,7 @@ class ClientTest(utils.TestCase):
headers=headers,
data='[1, 2, 3]',
**self.TEST_REQUEST_BASE)
self.assertEqual(re.split('/v[0-9]+[\.0-9]*',
self.assertEqual(re.split(r'/v[0-9]+[\.0-9]*',
endpoint_url)[0] + "/", cl.base_url)

test_post_call()

+ 1
- 0
manilaclient/tests/unit/v2/fakes.py View File

@@ -38,6 +38,7 @@ class FakeClient(fakes.FakeClient):
)
self.client = FakeHTTPClient(**kwargs)


fake_share_instance = {
'id': 1234,
'share_id': 'fake',


+ 8
- 7
manilaclient/tests/unit/v2/test_limits.py View File

@@ -31,15 +31,16 @@ def _get_default_RateLimit(verb="verb1", uri="uri1", regex="regex1",
class TestLimits(utils.TestCase):

def test_repr(self):
l = limits.Limits(None, {"foo": "bar"})
self.assertEqual("<Limits>", repr(l))
li = limits.Limits(None, {"foo": "bar"})
self.assertEqual("<Limits>", repr(li))

def test_absolute(self):
l = limits.Limits(None,
{"absolute": {"name1": "value1", "name2": "value2"}})
li = limits.Limits(None,
{"absolute": {"name1": "value1",
"name2": "value2"}})
l1 = limits.AbsoluteLimit("name1", "value1")
l2 = limits.AbsoluteLimit("name2", "value2")
for item in l.absolute:
for item in li.absolute:
self.assertIn(item, [l1, l2])

def test_rate(self):
@@ -67,12 +68,12 @@ class TestLimits(utils.TestCase):
}]
}]
}
l = limits.Limits(None, limit_param)
li = limits.Limits(None, limit_param)
l1 = limits.RateLimit("verb1", "uri1", "regex1", "value1", "remain1",
"unit1", "next1")
l2 = limits.RateLimit("verb2", "uri2", "regex2", "value2", "remain2",
"unit2", "next2")
for item in l.rate:
for item in li.rate:
self.assertIn(item, [l1, l2])




+ 1
- 0
manilaclient/v1/__init__.py View File

@@ -27,4 +27,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["maniliaclient.v1"] = MovedModule(v2)

+ 1
- 0
manilaclient/v1/contrib/list_extensions.py View File

@@ -32,5 +32,6 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.contrib.list_extensions"] = MovedModule(
list_extensions)

+ 1
- 0
manilaclient/v1/limits.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.limits"] = MovedModule(limits)

+ 1
- 0
manilaclient/v1/quota_classes.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.quota_classes"] = MovedModule(quota_classes)

+ 1
- 0
manilaclient/v1/quotas.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.quotas"] = MovedModule(quotas)

+ 1
- 0
manilaclient/v1/scheduler_stats.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.scheduler_stats"] = MovedModule(scheduler_stats)

+ 1
- 0
manilaclient/v1/security_services.py View File

@@ -32,5 +32,6 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules[
"manilaclient.v1.security_services"] = MovedModule(security_services)

+ 1
- 0
manilaclient/v1/services.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.services"] = MovedModule(services)

+ 1
- 0
manilaclient/v1/share_networks.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.share_networks"] = MovedModule(share_networks)

+ 1
- 0
manilaclient/v1/share_servers.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.share_servers"] = MovedModule(share_servers)

+ 1
- 0
manilaclient/v1/share_snapshots.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.share_snapshots"] = MovedModule(share_snapshots)

+ 1
- 0
manilaclient/v1/share_type_access.py View File

@@ -32,5 +32,6 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules[
"manilaclient.v1.share_type_access"] = MovedModule(share_type_access)

+ 1
- 0
manilaclient/v1/share_types.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.share_types"] = MovedModule(share_types)

+ 1
- 0
manilaclient/v1/shares.py View File

@@ -32,4 +32,5 @@ class MovedModule(object):
def __getattr__(self, attr):
return getattr(self.new_module, attr)


sys.modules["manilaclient.v1.shares"] = MovedModule(shares)

+ 3
- 3
manilaclient/v2/shares.py View File

@@ -461,8 +461,8 @@ class ShareManager(base.ManagerWithFind):
'''
@staticmethod
def _validate_username(access):
sole_periods_spaces_re = '[\s|\.]+$'
valid_username_re = '.[^\"\/\\\[\]\:\;\|\=\,\+\*\?\<\>]{3,254}$'
sole_periods_spaces_re = r'[\s|\.]+$'
valid_username_re = r'.[^\"\/\\\[\]\:\;\|\=\,\+\*\?\<\>]{3,254}$'
username = access

if re.match(sole_periods_spaces_re, username):
@@ -473,7 +473,7 @@ class ShareManager(base.ManagerWithFind):
if not re.match(valid_username_re, username):
exc_str = ('Invalid user or group name. Must be 4-255 characters '
'and consist of alphanumeric characters and '
'exclude special characters "/\[]:;|=,+*?<>')
'exclude special characters "/\\[]:;|=,+*?<>')
raise exceptions.CommandError(exc_str)

@staticmethod


+ 1
- 0
manilaclient/v2/shell.py View File

@@ -384,6 +384,7 @@ def do_credentials(cs, args):
}
cliutils.print_dict(data, "Token")


_quota_resources = [
'shares',
'snapshots',


+ 1
- 1
test-requirements.txt View File

@@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.

# hacking should be first
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
ddt>=1.0.1 # MIT


+ 1
- 0
tools/install_venv.py View File

@@ -247,5 +247,6 @@ def main(argv):
post_process()
print_help()


if __name__ == '__main__':
main(sys.argv)

+ 3
- 1
tox.ini View File

@@ -91,7 +91,9 @@ commands =

[flake8]
# F821: undefined name
ignore = F821
# W503 line break before binary operator
# W504 line break after binary operator
ignore = F821,W503,W504
builtins = _
# [H106] Don't put vim configuration in source files.
# [H203] Use assertIs(Not)None to check for None.


Loading…
Cancel
Save