From 8362f81a8d0c6509f8cd55cd496b7f5986e62148 Mon Sep 17 00:00:00 2001 From: Vincent Fournier Date: Tue, 12 May 2015 11:16:10 -0400 Subject: [PATCH] Fix python34 support Thanks @ntfournier ! Change-Id: I5b8075d0cb04cbde594dcb9be7c999dd6e90be70 --- surveil/api/controllers/v2/bansho/config.py | 5 +++-- .../v2/config/businessimpactmodulations.py | 7 ++++--- .../api/controllers/v2/config/checkmodulations.py | 7 ++++--- surveil/api/controllers/v2/config/contactgroups.py | 8 +++++--- surveil/api/controllers/v2/config/contacts.py | 7 ++++--- surveil/api/controllers/v2/config/hostgroups.py | 7 ++++--- .../api/controllers/v2/config/macromodulations.py | 7 ++++--- .../api/controllers/v2/config/notificationways.py | 7 ++++--- surveil/api/controllers/v2/config/realms.py | 7 ++++--- surveil/api/controllers/v2/config/servicegroup.py | 8 +++++--- surveil/api/controllers/v2/config/timeperiods.py | 7 ++++--- surveil/api/handlers/status/influxdb_query.py | 4 ++-- .../v2/config/test_businessimpactmodulations.py | 2 +- .../controllers/v2/config/test_checkmodulation.py | 2 +- .../controllers/v2/config/test_macromodulations.py | 2 +- .../controllers/v2/config/test_notificationways.py | 2 +- .../api/controllers/v2/config/test_timeperiods.py | 2 +- .../tests/api/controllers/v2/status/test_hosts.py | 12 ++++++++---- .../tests/api/controllers/v2/status/test_services.py | 6 ++++-- .../tests/api/handlers/live/test_fields_filter.py | 2 +- .../tests/api/handlers/live/test_influxdb_query.py | 8 ++++---- tox.ini | 2 +- 22 files changed, 70 insertions(+), 51 deletions(-) diff --git a/surveil/api/controllers/v2/bansho/config.py b/surveil/api/controllers/v2/bansho/config.py index 95dad87..f3a78e7 100644 --- a/surveil/api/controllers/v2/bansho/config.py +++ b/surveil/api/controllers/v2/bansho/config.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.handlers.bansho import config_handler @@ -24,7 +25,7 @@ from surveil.common import util class ConfigController(rest.RestController): @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(unicode) + @wsme_pecan.wsexpose(wtypes.text) def get(self): """Retrieve user config, empty dict if no config exists.""" user_name = pecan.request.headers.get('X-User-Id') @@ -33,7 +34,7 @@ class ConfigController(rest.RestController): return config @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(body=unicode) + @wsme_pecan.wsexpose(body=wtypes.text,) def post(self, config): """Save user config. diff --git a/surveil/api/controllers/v2/config/businessimpactmodulations.py b/surveil/api/controllers/v2/config/businessimpactmodulations.py index 52e0580..1c6bcb8 100644 --- a/surveil/api/controllers/v2/config/businessimpactmodulations.py +++ b/surveil/api/controllers/v2/config/businessimpactmodulations.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import businessimpactmodulation as mod @@ -33,7 +34,7 @@ class BusinessImpactModulationsController(rest.RestController): return modulations @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(mod.BusinessImpactModulation, unicode) + @wsme_pecan.wsexpose(mod.BusinessImpactModulation, wtypes.text) def get_one(self, modulation_name): """Returns a specific business impact modulation.""" handler = bh.BusinessImpactModulationHandler(pecan.request) @@ -52,7 +53,7 @@ class BusinessImpactModulationsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(mod.BusinessImpactModulation, - unicode, + wtypes.text, status_code=204) def delete(self, modulation_name): """Returns a specific business impact modulation.""" @@ -61,7 +62,7 @@ class BusinessImpactModulationsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(mod.BusinessImpactModulation, - unicode, + wtypes.text, body=mod.BusinessImpactModulation, status_code=204) def put(self, modulaion_name, modulation): diff --git a/surveil/api/controllers/v2/config/checkmodulations.py b/surveil/api/controllers/v2/config/checkmodulations.py index c5c83b5..d83392e 100644 --- a/surveil/api/controllers/v2/config/checkmodulations.py +++ b/surveil/api/controllers/v2/config/checkmodulations.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import checkmodulation @@ -33,7 +34,7 @@ class CheckModulationsController(rest.RestController): return checkmodulations @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(checkmodulation.CheckModulation, unicode) + @wsme_pecan.wsexpose(checkmodulation.CheckModulation, wtypes.text) def get_one(self, checkmodulation_name): """Returns a specific check modulation.""" handler = checkmodulation_handler.CheckModulationHandler(pecan.request) @@ -52,7 +53,7 @@ class CheckModulationsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(checkmodulation.CheckModulation, - unicode, status_code=204) + wtypes.text, status_code=204) def delete(self, checkmodulation_name): """Returns a specific check modulation.""" handler = checkmodulation_handler.CheckModulationHandler(pecan.request) @@ -60,7 +61,7 @@ class CheckModulationsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(checkmodulation.CheckModulation, - unicode, + wtypes.text, body=checkmodulation.CheckModulation, status_code=204) def put(self, checkmodulation_name, checkmodulation): diff --git a/surveil/api/controllers/v2/config/contactgroups.py b/surveil/api/controllers/v2/config/contactgroups.py index 42f4e30..298d419 100644 --- a/surveil/api/controllers/v2/config/contactgroups.py +++ b/surveil/api/controllers/v2/config/contactgroups.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import contactgroup @@ -33,7 +34,7 @@ class ContactGroupsController(rest.RestController): return contact_groups @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(contactgroup.ContactGroup, unicode) + @wsme_pecan.wsexpose(contactgroup.ContactGroup, wtypes.text) def get_one(self, group_name): """Returns a contact group.""" handler = contactgroup_handler.ContactGroupHandler(pecan.request) @@ -51,7 +52,8 @@ class ContactGroupsController(rest.RestController): handler.create(data) @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(contactgroup.ContactGroup, unicode, status_code=204) + @wsme_pecan.wsexpose(contactgroup.ContactGroup, wtypes.text, + status_code=204) def delete(self, group_name): """Delete a specific contact group.""" handler = contactgroup_handler.ContactGroupHandler(pecan.request) @@ -59,7 +61,7 @@ class ContactGroupsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(contactgroup.ContactGroup, - unicode, + wtypes.text, body=contactgroup.ContactGroup, status_code=204) def put(self, group_name, contactgroup): diff --git a/surveil/api/controllers/v2/config/contacts.py b/surveil/api/controllers/v2/config/contacts.py index 95e7e40..ec8b841 100644 --- a/surveil/api/controllers/v2/config/contacts.py +++ b/surveil/api/controllers/v2/config/contacts.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import contact @@ -33,7 +34,7 @@ class ContactsController(rest.RestController): return hosts @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(contact.Contact, unicode) + @wsme_pecan.wsexpose(contact.Contact, wtypes.text) def get_one(self, contact_name): """Returns a specific contact.""" handler = contact_handler.ContactHandler(pecan.request) @@ -51,7 +52,7 @@ class ContactsController(rest.RestController): handler.create(data) @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(contact.Contact, unicode, status_code=204) + @wsme_pecan.wsexpose(contact.Contact, wtypes.text, status_code=204) def delete(self, contact_name): """Returns a specific contact.""" handler = contact_handler.ContactHandler(pecan.request) @@ -59,7 +60,7 @@ class ContactsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(contact.Contact, - unicode, + wtypes.text, body=contact.Contact, status_code=204) def put(self, contact_name, contact): diff --git a/surveil/api/controllers/v2/config/hostgroups.py b/surveil/api/controllers/v2/config/hostgroups.py index 314e85c..a7397d1 100644 --- a/surveil/api/controllers/v2/config/hostgroups.py +++ b/surveil/api/controllers/v2/config/hostgroups.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import hostgroup @@ -33,7 +34,7 @@ class HostGroupsController(rest.RestController): return host_groups @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(hostgroup.HostGroup, unicode) + @wsme_pecan.wsexpose(hostgroup.HostGroup, wtypes.text) def get_one(self, group_name): """Returns a host group.""" handler = hostgroup_handler.HostGroupHandler(pecan.request) @@ -51,7 +52,7 @@ class HostGroupsController(rest.RestController): handler.create(data) @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(hostgroup.HostGroup, unicode, status_code=204) + @wsme_pecan.wsexpose(hostgroup.HostGroup, wtypes.text, status_code=204) def delete(self, group_name): """Returns a specific host group.""" handler = hostgroup_handler.HostGroupHandler(pecan.request) @@ -59,7 +60,7 @@ class HostGroupsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(hostgroup.HostGroup, - unicode, + wtypes.text, body=hostgroup.HostGroup, status_code=204) def put(self, group_name, hostgroup): diff --git a/surveil/api/controllers/v2/config/macromodulations.py b/surveil/api/controllers/v2/config/macromodulations.py index 14ae821..bac5478 100644 --- a/surveil/api/controllers/v2/config/macromodulations.py +++ b/surveil/api/controllers/v2/config/macromodulations.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import macromodulation @@ -33,7 +34,7 @@ class MacroModulationController(rest.RestController): return modulations @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(macromodulation.MacroModulation, unicode) + @wsme_pecan.wsexpose(macromodulation.MacroModulation, wtypes.text) def get_one(self, timeperiod_name): """Returns a specific macro modulation.""" handler = macromodulation_handler.MacroModulationHandler(pecan.request) @@ -52,7 +53,7 @@ class MacroModulationController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(macromodulation.MacroModulation, - unicode, + wtypes.text, status_code=204) def delete(self, modulation_name): """Returns a specific macro modulation.""" @@ -61,7 +62,7 @@ class MacroModulationController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(macromodulation.MacroModulation, - unicode, + wtypes.text, body=macromodulation.MacroModulation, status_code=204) def put(self, modulation_name, modulation): diff --git a/surveil/api/controllers/v2/config/notificationways.py b/surveil/api/controllers/v2/config/notificationways.py index 0b577f0..06749fe 100644 --- a/surveil/api/controllers/v2/config/notificationways.py +++ b/surveil/api/controllers/v2/config/notificationways.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import notificationway @@ -33,7 +34,7 @@ class NotificationWaysController(rest.RestController): return notificationsway @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(notificationway.NotificationWay, unicode) + @wsme_pecan.wsexpose(notificationway.NotificationWay, wtypes.text) def get_one(self, notificationway_name): """Returns a specific notification way.""" handler = notificationway_handler.NotificationWayHandler(pecan.request) @@ -53,7 +54,7 @@ class NotificationWaysController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose( notificationway.NotificationWay, - unicode, + wtypes.text, status_code=204 ) def delete(self, notificationway_name): @@ -63,7 +64,7 @@ class NotificationWaysController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(notificationway.NotificationWay, - unicode, + wtypes.text, body=notificationway.NotificationWay, status_code=204) def put(self, notificationway_name, notificationway): diff --git a/surveil/api/controllers/v2/config/realms.py b/surveil/api/controllers/v2/config/realms.py index e12902e..0c2aa3e 100644 --- a/surveil/api/controllers/v2/config/realms.py +++ b/surveil/api/controllers/v2/config/realms.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import realm @@ -33,7 +34,7 @@ class RealmsController(rest.RestController): return realms @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(realm.Realm, unicode) + @wsme_pecan.wsexpose(realm.Realm, wtypes.text) def get_one(self, realm_name): """Returns a specific realm.""" handler = realm_handler.RealmHandler(pecan.request) @@ -51,7 +52,7 @@ class RealmsController(rest.RestController): handler.create(data) @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(realm.Realm, unicode, status_code=204) + @wsme_pecan.wsexpose(realm.Realm, wtypes.text, status_code=204) def delete(self, realm_name): """Deletes a specific realm.""" handler = realm_handler.RealmHandler(pecan.request) @@ -59,7 +60,7 @@ class RealmsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(realm.Realm, - unicode, + wtypes.text, body=realm.Realm, status_code=204) def put(self, realm_name, realm): diff --git a/surveil/api/controllers/v2/config/servicegroup.py b/surveil/api/controllers/v2/config/servicegroup.py index b1db17f..83936b5 100644 --- a/surveil/api/controllers/v2/config/servicegroup.py +++ b/surveil/api/controllers/v2/config/servicegroup.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import servicegroup @@ -33,7 +34,7 @@ class ServiceGroupsController(rest.RestController): return service_groups @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(servicegroup.ServiceGroup, unicode) + @wsme_pecan.wsexpose(servicegroup.ServiceGroup, wtypes.text) def get_one(self, group_name): """Returns a service group.""" handler = servicegroup_handler.ServiceGroupHandler(pecan.request) @@ -51,7 +52,8 @@ class ServiceGroupsController(rest.RestController): handler.create(data) @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(servicegroup.ServiceGroup, unicode, status_code=204) + @wsme_pecan.wsexpose(servicegroup.ServiceGroup, wtypes.text, + status_code=204) def delete(self, group_name): """Returns a specific service group.""" handler = servicegroup_handler.ServiceGroupHandler(pecan.request) @@ -59,7 +61,7 @@ class ServiceGroupsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(servicegroup.ServiceGroup, - unicode, + wtypes.text, body=servicegroup.ServiceGroup, status_code=204) def put(self, group_name, servicegroup): diff --git a/surveil/api/controllers/v2/config/timeperiods.py b/surveil/api/controllers/v2/config/timeperiods.py index 8e88f1b..9ef2b5d 100644 --- a/surveil/api/controllers/v2/config/timeperiods.py +++ b/surveil/api/controllers/v2/config/timeperiods.py @@ -15,6 +15,7 @@ import pecan from pecan import rest +import wsme.types as wtypes import wsmeext.pecan as wsme_pecan from surveil.api.datamodel.config import timeperiod @@ -33,7 +34,7 @@ class TimePeriodsController(rest.RestController): return time_periods @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(timeperiod.TimePeriod, unicode) + @wsme_pecan.wsexpose(timeperiod.TimePeriod, wtypes.text) def get_one(self, timeperiod_name): """Returns a specific time period.""" handler = timeperiod_handler.TimePeriodHandler(pecan.request) @@ -51,7 +52,7 @@ class TimePeriodsController(rest.RestController): handler.create(data) @util.policy_enforce(['authenticated']) - @wsme_pecan.wsexpose(timeperiod.TimePeriod, unicode, status_code=204) + @wsme_pecan.wsexpose(timeperiod.TimePeriod, wtypes.text, status_code=204) def delete(self, timeperiod_name): """Returns a specific time period.""" handler = timeperiod_handler.TimePeriodHandler(pecan.request) @@ -59,7 +60,7 @@ class TimePeriodsController(rest.RestController): @util.policy_enforce(['authenticated']) @wsme_pecan.wsexpose(timeperiod.TimePeriod, - unicode, + wtypes.text, body=timeperiod.TimePeriod, status_code=204) def put(self, timeperiod_name, timeperiod): diff --git a/surveil/api/handlers/status/influxdb_query.py b/surveil/api/handlers/status/influxdb_query.py index aba0f75..e88d459 100644 --- a/surveil/api/handlers/status/influxdb_query.py +++ b/surveil/api/handlers/status/influxdb_query.py @@ -50,8 +50,8 @@ def _build_where_clause(filters): clause = [] first = True - for filter_name, filter_data in filters.items(): - for field, values in filter_data.items(): + for filter_name, filter_data in sorted(filters.items()): + for field, values in sorted(filter_data.items()): for value in values: if first: clause.append('WHERE') diff --git a/surveil/tests/api/controllers/v2/config/test_businessimpactmodulations.py b/surveil/tests/api/controllers/v2/config/test_businessimpactmodulations.py index 9aafd20..49a09c4 100644 --- a/surveil/tests/api/controllers/v2/config/test_businessimpactmodulations.py +++ b/surveil/tests/api/controllers/v2/config/test_businessimpactmodulations.py @@ -42,7 +42,7 @@ class TestBusinessImpactModulationController(functionalTest.FunctionalTest): def test_get_all_modulations(self): response = self.get('/v2/config/businessimpactmodulations') - self.assertItemsEqual( + self.assert_count_equal_backport( json.loads(response.body.decode()), [ {'business_impact': 1, diff --git a/surveil/tests/api/controllers/v2/config/test_checkmodulation.py b/surveil/tests/api/controllers/v2/config/test_checkmodulation.py index eecdfda..e7d1456 100644 --- a/surveil/tests/api/controllers/v2/config/test_checkmodulation.py +++ b/surveil/tests/api/controllers/v2/config/test_checkmodulation.py @@ -42,7 +42,7 @@ class TestCheckModulationsController(functionalTest.FunctionalTest): def test_get_all_checkmodulations(self): response = self.get('/v2/config/checkmodulations') - self.assertItemsEqual( + self.assert_count_equal_backport( json.loads(response.body.decode()), [ {'checkmodulation_name': 'ping_day', diff --git a/surveil/tests/api/controllers/v2/config/test_macromodulations.py b/surveil/tests/api/controllers/v2/config/test_macromodulations.py index 1ea200e..8e745b1 100644 --- a/surveil/tests/api/controllers/v2/config/test_macromodulations.py +++ b/surveil/tests/api/controllers/v2/config/test_macromodulations.py @@ -44,7 +44,7 @@ class TestMacroModulationController(functionalTest.FunctionalTest): def test_get_all_macromodulations(self): response = self.get('/v2/config/macromodulations') - self.assertItemsEqual( + self.assert_count_equal_backport( [ { 'macromodulation_name': 'HighDuringNight', diff --git a/surveil/tests/api/controllers/v2/config/test_notificationways.py b/surveil/tests/api/controllers/v2/config/test_notificationways.py index 0cdf057..91f8d73 100644 --- a/surveil/tests/api/controllers/v2/config/test_notificationways.py +++ b/surveil/tests/api/controllers/v2/config/test_notificationways.py @@ -51,7 +51,7 @@ class TestNotificationWayController(functionalTest.FunctionalTest): def test_get_all_notificationways(self): response = self.get('/v2/config/notificationways') - self.assertItemsEqual( + self.assert_count_equal_backport( json.loads(response.body.decode()), [ { diff --git a/surveil/tests/api/controllers/v2/config/test_timeperiods.py b/surveil/tests/api/controllers/v2/config/test_timeperiods.py index 543ac4a..3a9c687 100644 --- a/surveil/tests/api/controllers/v2/config/test_timeperiods.py +++ b/surveil/tests/api/controllers/v2/config/test_timeperiods.py @@ -42,7 +42,7 @@ class TestTimePeriodsController(functionalTest.FunctionalTest): def test_get_all_timeperiods(self): response = self.get('/v2/config/timeperiods') - self.assertItemsEqual( + self.assert_count_equal_backport( json.loads(response.body.decode()), [ {'timeperiod_name': 'misc-single-days', diff --git a/surveil/tests/api/controllers/v2/status/test_hosts.py b/surveil/tests/api/controllers/v2/status/test_hosts.py index 927629a..6a88b2d 100644 --- a/surveil/tests/api/controllers/v2/status/test_hosts.py +++ b/surveil/tests/api/controllers/v2/status/test_hosts.py @@ -127,7 +127,8 @@ class TestStatusHosts(functionalTest.FunctionalTest): "acknowledged": True, "host_name": "ws-arbiter"}] - self.assertItemsEqual(json.loads(response.body), expected) + self.assert_count_equal_backport(json.loads(response.body.decode()), + expected) def test_query_hosts(self): query = { @@ -144,7 +145,8 @@ class TestStatusHosts(functionalTest.FunctionalTest): expected = [{"host_name": "ws-arbiter", "last_check": 1429405764}] - self.assertItemsEqual(json.loads(response.body), expected) + self.assert_count_equal_backport(json.loads(response.body.decode()), + expected) def test_get_specific_host(self): @@ -161,7 +163,8 @@ class TestStatusHosts(functionalTest.FunctionalTest): "host_name": "localhost", "address": "localhost"} - self.assertItemsEqual(json.loads(response.body), expected) + self.assert_count_equal_backport(json.loads(response.body.decode()), + expected) def test_get_specific_host_service(self): response = self.get( @@ -175,4 +178,5 @@ class TestStatusHosts(functionalTest.FunctionalTest): 'state': 'OK', 'host_name': 'ws-arbiter', 'service_description': 'check-ws-arbiter'} - self.assertItemsEqual(json.loads(response.body), expected) + self.assert_count_equal_backport(json.loads(response.body.decode()), + expected) diff --git a/surveil/tests/api/controllers/v2/status/test_services.py b/surveil/tests/api/controllers/v2/status/test_services.py index 58e9e82..23c2021 100644 --- a/surveil/tests/api/controllers/v2/status/test_services.py +++ b/surveil/tests/api/controllers/v2/status/test_services.py @@ -74,7 +74,8 @@ class TestStatusServices(functionalTest.FunctionalTest): }, ] - self.assertItemsEqual(json.loads(response.body), expected) + self.assertEqual(json.loads(response.body.decode()), + expected) def test_query_services(self): query = { @@ -97,4 +98,5 @@ class TestStatusServices(functionalTest.FunctionalTest): 'service_description': 'Apache'} ] - self.assertEqual(json.loads(response.body), expected) + self.assertEqual(json.loads(response.body.decode()), + expected) diff --git a/surveil/tests/api/handlers/live/test_fields_filter.py b/surveil/tests/api/handlers/live/test_fields_filter.py index 8874659..0eb1ba5 100644 --- a/surveil/tests/api/handlers/live/test_fields_filter.py +++ b/surveil/tests/api/handlers/live/test_fields_filter.py @@ -47,4 +47,4 @@ class FieldsFilterTest(base.BaseTestCase): expected = [{"last_check": 1429400984, "host_name": "test_keystone"}] - self.assertItemsEqual(result, expected) + self.assert_count_equal_backport(result, expected) diff --git a/surveil/tests/api/handlers/live/test_influxdb_query.py b/surveil/tests/api/handlers/live/test_influxdb_query.py index d1613e6..73cabf3 100644 --- a/surveil/tests/api/handlers/live/test_influxdb_query.py +++ b/surveil/tests/api/handlers/live/test_influxdb_query.py @@ -35,7 +35,7 @@ class LiveQueryFilterTest(base.BaseTestCase): expected = "WHERE state=0 AND description='test_keystone'" - self.assertItemsEqual(result, expected) + self.assert_count_equal_backport(result, expected) def test_build_where_clause_no_filters(self): filters = {} @@ -46,7 +46,7 @@ class LiveQueryFilterTest(base.BaseTestCase): expected = "" - self.assertItemsEqual(result, expected) + self.assert_count_equal_backport(result, expected) def test_build_influx_query(self): query = live_query.LiveQuery( @@ -64,7 +64,7 @@ class LiveQueryFilterTest(base.BaseTestCase): expected = "SELECT * FROM ALERT GROUP BY *, host_name LIMIT 10" - self.assertItemsEqual(result, expected) + self.assert_count_equal_backport(result, expected) def test_build_influx_query_orderby(self): query = live_query.LiveQuery( @@ -86,4 +86,4 @@ class LiveQueryFilterTest(base.BaseTestCase): "GROUP BY *, host_name " "ORDER BY time DESC LIMIT 10") - self.assertItemsEqual(result, expected) + self.assert_count_equal_backport(result, expected) diff --git a/tox.ini b/tox.ini index 884f9b5..bcbb1a1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,6 +1,6 @@ [tox] minverson = 1.6 -envlist = py33, py27, pep8, docs +envlist = py34, py27, pep8, docs skipsdist = True [testenv]