Refactored Watcher codebase to add py34 support
Even though Watcher was mentioning python 3.4 as supported, it really wasn't the case as all the unit tests were not passing in this version of Python. This patchset fixes all the failing tests in Python 3.4 while keeping Watcher Python 2.7 compatible. DocImpact BugImpact Change-Id: Ie74acc08ef0a2899349a4b419728c89e416a18cb
This commit is contained in:
committed by
Jean-Emile DARTOIS
parent
b1fe7a5f3d
commit
d934971458
@@ -367,20 +367,21 @@ class TestListAction(api_base.FunctionalTest):
|
||||
uuid=utils.generate_uuid(),
|
||||
next=id_ + 1)
|
||||
response = self.get_json('/actions/')
|
||||
reference_uuids = [(s['next_uuid'] if 'next_uuid' in s else None)
|
||||
for s in response['actions']]
|
||||
reference_uuids = [
|
||||
s.get('next_uuid', '') for s in response['actions']
|
||||
]
|
||||
|
||||
response = self.get_json('/actions/?sort_key=next_uuid')
|
||||
|
||||
self.assertEqual(5, len(response['actions']))
|
||||
uuids = [(s['next_uuid'] if 'next_uuid' in s else None)
|
||||
uuids = [(s['next_uuid'] if 'next_uuid' in s else '')
|
||||
for s in response['actions']]
|
||||
self.assertEqual(sorted(reference_uuids), uuids)
|
||||
|
||||
response = self.get_json('/actions/?sort_key=next_uuid&sort_dir=desc')
|
||||
|
||||
self.assertEqual(5, len(response['actions']))
|
||||
uuids = [(s['next_uuid'] if 'next_uuid' in s else None)
|
||||
uuids = [(s['next_uuid'] if 'next_uuid' in s else '')
|
||||
for s in response['actions']]
|
||||
self.assertEqual(sorted(reference_uuids, reverse=True), uuids)
|
||||
|
||||
|
||||
@@ -38,19 +38,19 @@ class TestListGoal(api_base.FunctionalTest):
|
||||
self._assert_goal_fields(response['goals'][0])
|
||||
|
||||
def test_get_one(self):
|
||||
goal_name = CONF.watcher_goals.goals.keys()[0]
|
||||
goal_name = list(CONF.watcher_goals.goals.keys())[0]
|
||||
response = self.get_json('/goals/%s' % goal_name)
|
||||
self.assertEqual(goal_name, response['name'])
|
||||
self._assert_goal_fields(response)
|
||||
|
||||
def test_detail(self):
|
||||
goal_name = CONF.watcher_goals.goals.keys()[0]
|
||||
goal_name = list(CONF.watcher_goals.goals.keys())[0]
|
||||
response = self.get_json('/goals/detail')
|
||||
self.assertEqual(goal_name, response['goals'][0]["name"])
|
||||
self._assert_goal_fields(response['goals'][0])
|
||||
|
||||
def test_detail_against_single(self):
|
||||
goal_name = CONF.watcher_goals.goals.keys()[0]
|
||||
goal_name = list(CONF.watcher_goals.goals.keys())[0]
|
||||
response = self.get_json('/goals/%s/detail' % goal_name,
|
||||
expect_errors=True)
|
||||
self.assertEqual(404, response.status_int)
|
||||
|
||||
@@ -123,7 +123,7 @@ class TestJsonPatchType(base.TestCase):
|
||||
'value': {'cat': 'meow'}}]
|
||||
ret = self._patch_json(valid_patches, False)
|
||||
self.assertEqual(200, ret.status_int)
|
||||
self.assertEqual(sorted(valid_patches), sorted(ret.json))
|
||||
self.assertEqual(valid_patches, ret.json)
|
||||
|
||||
def test_cannot_update_internal_attr(self):
|
||||
patch = [{'path': '/internal', 'op': 'replace', 'value': 'foo'}]
|
||||
@@ -244,7 +244,6 @@ class TestJsonType(base.TestCase):
|
||||
vts = str(types.jsontype)
|
||||
self.assertIn(str(wtypes.text), vts)
|
||||
self.assertIn(str(int), vts)
|
||||
self.assertIn(str(long), vts)
|
||||
self.assertIn(str(float), vts)
|
||||
self.assertIn(str(types.BooleanType), vts)
|
||||
self.assertIn(str(list), vts)
|
||||
|
||||
Reference in New Issue
Block a user