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.

Change-Id: I5da442bb2f1e634e6b3fe37a6ea3820cea1db96f
tags/3.3.1^0
Andreas Jaeger 3 months ago
parent
commit
e96e99f1ec
8 changed files with 25 additions and 24 deletions
  1. +1
    -1
      test-requirements.txt
  2. +1
    -1
      tox.ini
  3. +1
    -1
      troveclient/_i18n.py
  4. +2
    -2
      troveclient/compat/tests/test_auth.py
  5. +16
    -16
      troveclient/tests/test_base.py
  6. +2
    -2
      troveclient/tests/test_v1_shell.py
  7. +1
    -0
      troveclient/tests/utils.py
  8. +1
    -1
      troveclient/v1/metadata.py

+ 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>=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
fixtures>=3.0.0 # Apache-2.0/BSD
oslotest>=3.2.0 # Apache-2.0


+ 1
- 1
tox.ini View File

@@ -63,7 +63,7 @@ commands = sphinx-build -a -E -W -d releasenotes/build/doctrees -b html releasen

[flake8]
enable-extensions = H106,H203,H904
ignore = H202,H405,H501
ignore = H202,H405,H501,W504
show-source = True
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build,releasenotes



+ 1
- 1
troveclient/_i18n.py View File

@@ -37,4 +37,4 @@ _P = _translators.plural_form


def get_available_languages():
return oslo_i18n.get_available_languages(DOMAIN)
return oslo_i18n.get_available_languages(DOMAIN)

+ 2
- 2
troveclient/compat/tests/test_auth.py View File

@@ -107,8 +107,8 @@ class AuthenticatorTest(testtools.TestCase):
body = "test_body"
authObj.client._time_request = mock.Mock(return_value=(resp, body))

l = authObj._authenticate(mock.Mock(), mock.Mock())
self.assertEqual('loc', l)
lo = authObj._authenticate(mock.Mock(), mock.Mock())
self.assertEqual('loc', lo)

# test any response code other than 200 and 305
resp.status = 404


+ 16
- 16
troveclient/tests/test_base.py View File

@@ -212,38 +212,38 @@ class ManagerListTest(ManagerTest):

def test_list_with_body_none(self):
body = None
l = self.manager._list("url", self.response_key, obj_class, body)
self.assertEqual(len(self.data_g), len(l))
for i in range(0, len(l)):
self.assertEqual(self.data_g[i], l[i])
li = self.manager._list("url", self.response_key, obj_class, body)
self.assertEqual(len(self.data_g), len(li))
for i in range(0, len(li)):
self.assertEqual(self.data_g[i], li[i])

def test_list_body_not_none(self):
body = "something"
l = self.manager._list("url", self.response_key, obj_class, body)
self.assertEqual(len(self.data_p), len(l))
for i in range(0, len(l)):
self.assertEqual(self.data_p[i], l[i])
li = self.manager._list("url", self.response_key, obj_class, body)
self.assertEqual(len(self.data_p), len(li))
for i in range(0, len(li)):
self.assertEqual(self.data_p[i], li[i])

def test_list_key_mapping(self):
data_ = {"values": ["p1", "p2"]}
body_ = {self.response_key: data_}
url_ = "test_url_post"
self.manager.api.client.post = mock.Mock(return_value=(url_, body_))
l = self.manager._list("url", self.response_key,
obj_class, "something")
li = self.manager._list("url", self.response_key,
obj_class, "something")
data = data_["values"]
self.assertEqual(len(data), len(l))
for i in range(0, len(l)):
self.assertEqual(data[i], l[i])
self.assertEqual(len(data), len(li))
for i in range(0, len(li)):
self.assertEqual(data[i], li[i])

def test_list_without_key_mapping(self):
data_ = {"v1": "1", "v2": "2"}
body_ = {self.response_key: data_}
url_ = "test_url_post"
self.manager.api.client.post = mock.Mock(return_value=(url_, body_))
l = self.manager._list("url", self.response_key,
obj_class, "something")
self.assertEqual(len(data_), len(l))
li = self.manager._list("url", self.response_key,
obj_class, "something")
self.assertEqual(len(data_), len(li))


class MangerPaginationTests(ManagerTest):


+ 2
- 2
troveclient/tests/test_v1_shell.py View File

@@ -221,7 +221,7 @@ class ShellTest(utils.TestCase):

def test_flavor_list_error(self):
cmd = 'flavor-list --datastore_type mysql'
exepcted_error_msg = ('Missing argument\(s\): '
exepcted_error_msg = (r'Missing argument\(s\): '
'datastore_type, datastore_version_id')
self.assertRaisesRegex(
exceptions.MissingArgs, exepcted_error_msg, self.run_command,
@@ -256,7 +256,7 @@ class ShellTest(utils.TestCase):

def test_volume_type_list_error(self):
cmd = 'volume-type-list --datastore_type mysql'
exepcted_error_msg = ('Missing argument\(s\): '
exepcted_error_msg = (r'Missing argument\(s\): '
'datastore_type, datastore_version_id')
self.assertRaisesRegex(
exceptions.MissingArgs, exepcted_error_msg, self.run_command,


+ 1
- 0
troveclient/tests/utils.py View File

@@ -58,6 +58,7 @@ def _patch_mock_to_raise_for_invalid_assert_calls():
mock.Mock.__getattr__ = raise_for_invalid_assert_calls(
mock.Mock.__getattr__)


# NOTE(gibi): needs to be called only once at import time
# to patch the mock lib
_patch_mock_to_raise_for_invalid_assert_calls()


+ 1
- 1
troveclient/v1/metadata.py View File

@@ -23,7 +23,7 @@ class MetadataResource(base.Resource):

def __contains__(self, item):
if item in self.__dict__:
return True
return True
else:
return False



Loading…
Cancel
Save