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: Ia621c3fea2b8ded8df7727c07931ad071a61e736
This commit is contained in:
parent
ed80204406
commit
e71c636dfa
@ -116,4 +116,5 @@ class CompositeRule(wtypes.UserType):
|
|||||||
def __call__(**rule):
|
def __call__(**rule):
|
||||||
return rule
|
return rule
|
||||||
|
|
||||||
|
|
||||||
composite_rule = CompositeRule()
|
composite_rule = CompositeRule()
|
||||||
|
@ -100,7 +100,7 @@ class ValidatedComplexQuery(object):
|
|||||||
valid_fields = _list_to_regexp(valid_keys)
|
valid_fields = _list_to_regexp(valid_keys)
|
||||||
|
|
||||||
if metadata_allowed:
|
if metadata_allowed:
|
||||||
valid_filter_fields = valid_fields + "|^metadata\.[\S]+$"
|
valid_filter_fields = valid_fields + r"|^metadata\.[\S]+$"
|
||||||
else:
|
else:
|
||||||
valid_filter_fields = valid_fields
|
valid_filter_fields = valid_fields
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ class ParsableErrorMiddleware(object):
|
|||||||
if error is not None and 'faultstring' in fault:
|
if error is not None and 'faultstring' in fault:
|
||||||
fault['faultstring'] = i18n.translate(error,
|
fault['faultstring'] = i18n.translate(error,
|
||||||
user_locale)
|
user_locale)
|
||||||
except ValueError as err:
|
except ValueError:
|
||||||
fault = app_data
|
fault = app_data
|
||||||
body = json.dumps({'error_message': fault})
|
body = json.dumps({'error_message': fault})
|
||||||
if six.PY3:
|
if six.PY3:
|
||||||
|
@ -198,7 +198,7 @@ class AlarmEvaluationService(cotyledon.Service):
|
|||||||
super(AlarmEvaluationService, self).__init__(worker_id)
|
super(AlarmEvaluationService, self).__init__(worker_id)
|
||||||
self.conf = conf
|
self.conf = conf
|
||||||
|
|
||||||
ef = lambda: futures.ThreadPoolExecutor(max_workers=10)
|
ef = lambda: futures.ThreadPoolExecutor(max_workers=10) # noqa: E731
|
||||||
self.periodic = periodics.PeriodicWorker.create(
|
self.periodic = periodics.PeriodicWorker.create(
|
||||||
[], executor_factory=ef)
|
[], executor_factory=ef)
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class LoadBalancerMemberHealthEvaluator(evaluator.Evaluator):
|
|||||||
for m in ret.get("members", []):
|
for m in ret.get("members", []):
|
||||||
try:
|
try:
|
||||||
created_time = parser.parse(m['created_at'], ignoretz=True)
|
created_time = parser.parse(m['created_at'], ignoretz=True)
|
||||||
except ValueError as e:
|
except ValueError:
|
||||||
LOG.warning('Failed to parse the member created time.')
|
LOG.warning('Failed to parse the member created time.')
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ def run_migrations_online():
|
|||||||
context.run_migrations()
|
context.run_migrations()
|
||||||
conn.disconnect()
|
conn.disconnect()
|
||||||
|
|
||||||
|
|
||||||
if not hasattr(config, "conf"):
|
if not hasattr(config, "conf"):
|
||||||
from aodh import service
|
from aodh import service
|
||||||
config.conf = service.prepare_service([])
|
config.conf = service.prepare_service([])
|
||||||
|
@ -18,8 +18,8 @@ from aodh.tests.functional.api import v2 as tests_api
|
|||||||
class TestCapabilitiesController(tests_api.FunctionalTest):
|
class TestCapabilitiesController(tests_api.FunctionalTest):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestCapabilitiesController, self).setUp()
|
super(TestCapabilitiesController, self).setUp()
|
||||||
self.url = '/capabilities'
|
self.url = '/capabilities'
|
||||||
|
|
||||||
def test_capabilities(self):
|
def test_capabilities(self):
|
||||||
data = self.get_json(self.url)
|
data = self.get_json(self.url)
|
||||||
|
@ -32,14 +32,14 @@ class TestQuotas(v2.FunctionalTest):
|
|||||||
resp = self.get_json('/quotas', headers=self.auth_headers, status=200)
|
resp = self.get_json('/quotas', headers=self.auth_headers, status=200)
|
||||||
|
|
||||||
self.assertEqual(self.project, resp.get('project_id'))
|
self.assertEqual(self.project, resp.get('project_id'))
|
||||||
self.assertTrue(len(resp.get('quotas', [])) > 0)
|
self.assertGreater(len(resp.get('quotas', [])), 0)
|
||||||
|
|
||||||
def test_get_project_quotas_by_user(self):
|
def test_get_project_quotas_by_user(self):
|
||||||
resp = self.get_json('/quotas?project_id=%s' % self.project,
|
resp = self.get_json('/quotas?project_id=%s' % self.project,
|
||||||
headers=self.auth_headers, status=200)
|
headers=self.auth_headers, status=200)
|
||||||
|
|
||||||
self.assertEqual(self.project, resp.get('project_id'))
|
self.assertEqual(self.project, resp.get('project_id'))
|
||||||
self.assertTrue(len(resp.get('quotas', [])) > 0)
|
self.assertGreater(len(resp.get('quotas', [])), 0)
|
||||||
|
|
||||||
def test_get_other_project_quotas_by_user_failed(self):
|
def test_get_other_project_quotas_by_user_failed(self):
|
||||||
self.get_json(
|
self.get_json(
|
||||||
@ -58,7 +58,7 @@ class TestQuotas(v2.FunctionalTest):
|
|||||||
status=200)
|
status=200)
|
||||||
|
|
||||||
self.assertEqual(self.other_project, resp.get('project_id'))
|
self.assertEqual(self.other_project, resp.get('project_id'))
|
||||||
self.assertTrue(len(resp.get('quotas', [])) > 0)
|
self.assertGreater(len(resp.get('quotas', [])), 0)
|
||||||
|
|
||||||
def test_post_quotas_by_admin(self):
|
def test_post_quotas_by_admin(self):
|
||||||
auth_headers = copy.copy(self.auth_headers)
|
auth_headers = copy.copy(self.auth_headers)
|
||||||
|
@ -317,7 +317,7 @@ class AlarmHistoryTest(AlarmTestBase):
|
|||||||
"on_behalf_of": alarm.project_id,
|
"on_behalf_of": alarm.project_id,
|
||||||
"severity": severity,
|
"severity": severity,
|
||||||
"timestamp": datetime.datetime(2014, 4, 7, 7, 34)
|
"timestamp": datetime.datetime(2014, 4, 7, 7, 34)
|
||||||
}
|
}
|
||||||
self.alarm_conn.record_alarm_change(alarm_change=alarm_change)
|
self.alarm_conn.record_alarm_change(alarm_change=alarm_change)
|
||||||
filter_expr = {"=": {"severity": "low"}}
|
filter_expr = {"=": {"severity": "low"}}
|
||||||
history = list(self.alarm_conn.query_alarm_history(
|
history = list(self.alarm_conn.query_alarm_history(
|
||||||
|
5
tox.ini
5
tox.ini
@ -80,7 +80,10 @@ setenv = OS_TEST_PATH=aodh/tests/functional/
|
|||||||
commands = pifpaf -g AODH_TEST_STORAGE_URL run postgresql -- oslo_debug_helper {posargs}
|
commands = pifpaf -g AODH_TEST_STORAGE_URL run postgresql -- oslo_debug_helper {posargs}
|
||||||
|
|
||||||
[flake8]
|
[flake8]
|
||||||
ignore =
|
# W503 line break before binary operator
|
||||||
|
# W504 line break after binary operator
|
||||||
|
# E402 module level import not at top of file
|
||||||
|
ignore = W503,W504,E402
|
||||||
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
exclude=.venv,.git,.tox,dist,doc,*lib/python*,*egg,build
|
||||||
# [H106] Do not put vim configuration in source files.
|
# [H106] Do not put vim configuration in source files.
|
||||||
# [H203] Use assertIs(Not)None to check for None.
|
# [H203] Use assertIs(Not)None to check for None.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user