Fix more tests on Python 3
* HTTP body type is bytes * query.py: Exception.message attribute was removed on Python 3 * mock calls cannot be sorted (mock calls are not comparable), use the assert_has_calls() with any_order=True instead. * Port decode_unicode() on Python 3: decode bytes from UTF-8 on Python 3 instead of encoding Unicode to UTF-8 * MeterDefinitionException: add message attribute * tox.ini: add more tests to Python 3.4 Change-Id: Iadd1c83b250d2f941262cc6e7dba4c27cb56893d
This commit is contained in:
parent
91dbb9f148
commit
e8cb08fdba
@ -201,7 +201,7 @@ class ValidatedComplexQuery(object):
|
||||
self._validate_filter(self.filter_expr)
|
||||
except (ValueError, jsonschema.exceptions.ValidationError) as e:
|
||||
raise base.ClientSideError(
|
||||
_("Filter expression not valid: %s") % e.message)
|
||||
_("Filter expression not valid: %s") % e)
|
||||
self._replace_isotime_with_datetime(self.filter_expr)
|
||||
self._convert_operator_to_lower_case(self.filter_expr)
|
||||
self._normalize_field_names_for_db_model(self.filter_expr)
|
||||
|
@ -40,6 +40,7 @@ LOG = log.getLogger(__name__)
|
||||
class MeterDefinitionException(Exception):
|
||||
def __init__(self, message, definition_cfg):
|
||||
super(MeterDefinitionException, self).__init__(message)
|
||||
self.message = message
|
||||
self.definition_cfg = definition_cfg
|
||||
|
||||
def __str__(self):
|
||||
|
@ -47,7 +47,7 @@ class TestAPIUpgradePath(v2.FunctionalTest):
|
||||
for endpoint in ['meters', 'samples', 'resources']:
|
||||
response = self.app.get(self.PATH_PREFIX + '/' + endpoint,
|
||||
status=410)
|
||||
self.assertIn('Gnocchi API', response.body)
|
||||
self.assertIn(b'Gnocchi API', response.body)
|
||||
|
||||
for endpoint in ['events', 'event_types']:
|
||||
self.app.get(self.PATH_PREFIX + '/' + endpoint,
|
||||
@ -59,7 +59,7 @@ class TestAPIUpgradePath(v2.FunctionalTest):
|
||||
"orderby": '[{"timestamp": "DESC"}]',
|
||||
"limit": 3
|
||||
}, status=410)
|
||||
self.assertIn('Gnocchi API', response.body)
|
||||
self.assertIn(b'Gnocchi API', response.body)
|
||||
|
||||
def _do_test_alarm_redirect(self):
|
||||
response = self.app.get(self.PATH_PREFIX + '/alarms',
|
||||
@ -95,9 +95,10 @@ class TestAPIUpgradePath(v2.FunctionalTest):
|
||||
def test_gnocchi_enabled_without_database_backend_keystone(self):
|
||||
self._setup_keystone_mock()
|
||||
self._do_test_gnocchi_enabled_without_database_backend()
|
||||
self.assertEqual([mock.call(service_type="alarming"),
|
||||
mock.call(service_type="metric")],
|
||||
sorted(self.ks.service_catalog.url_for.mock_calls))
|
||||
self.ks.service_catalog.url_for.assert_has_calls([
|
||||
mock.call(service_type="alarming"),
|
||||
mock.call(service_type="metric")],
|
||||
any_order=True)
|
||||
|
||||
def test_gnocchi_enabled_without_database_backend_configoptions(self):
|
||||
self._setup_osloconfig_options()
|
||||
|
@ -73,8 +73,10 @@ def decode_unicode(input):
|
||||
# the tuple would become list. So we have to generate the value as
|
||||
# list here.
|
||||
return [decode_unicode(element) for element in input]
|
||||
elif isinstance(input, six.text_type):
|
||||
elif six.PY2 and isinstance(input, six.text_type):
|
||||
return input.encode('utf-8')
|
||||
elif six.PY3 and isinstance(input, six.binary_type):
|
||||
return input.decode('utf-8')
|
||||
else:
|
||||
return input
|
||||
|
||||
|
8
tox.ini
8
tox.ini
@ -49,11 +49,16 @@ commands = python -m testtools.run \
|
||||
ceilometer.tests.api.v2.test_alarm_scenarios.TestAlarms.test_alarms_query_with_timestamp \
|
||||
ceilometer.tests.api.v2.test_alarm_scenarios.TestAlarms.test_get_alarm_history_constrained_by_alarm_id_failed \
|
||||
ceilometer.tests.api.v2.test_alarm_scenarios.TestAlarms.test_post_invalid_alarm_input_enabled_int \
|
||||
ceilometer.tests.api.v2.test_api_upgrade.TestAPIUpgradePath.test_gnocchi_enabled_without_database_backend_configoptions \
|
||||
ceilometer.tests.api.v2.test_api_upgrade.TestAPIUpgradePath.test_gnocchi_enabled_without_database_backend_keystone \
|
||||
ceilometer.tests.api.v2.test_app \
|
||||
ceilometer.tests.api.v2.test_complex_query_scenarios.TestQueryMetersController.test_query_with_isotime \
|
||||
ceilometer.tests.api.v2.test_complex_query_scenarios.TestQueryMetersController.test_query_with_volume_field_name_orderby \
|
||||
ceilometer.tests.api.v2.test_complex_query_scenarios.TestQueryMetersController.test_query_with_wrong_json \
|
||||
ceilometer.tests.api.v2.test_event_scenarios.TestEventAPI.test_get_events_filter_datetime_trait \
|
||||
ceilometer.tests.api.v2.test_list_events_scenarios.TestListEvents.test_metadata \
|
||||
ceilometer.tests.api.v2.test_list_meters_scenarios.TestListMeters.test_query_samples_with_invalid_field_name_and_eq_operator \
|
||||
ceilometer.tests.api.v2.test_list_resources_scenarios.TestListResources.test_metadata \
|
||||
ceilometer.tests.api.v2.test_list_resources_scenarios.TestListResources.test_with_invalid_resource_id \
|
||||
ceilometer.tests.api.v2.test_post_samples_scenarios.TestPostSamples.test_missing_project_user_id \
|
||||
ceilometer.tests.api.v2.test_post_samples_scenarios.TestPostSamples.test_multiple_project_id_and_admin \
|
||||
@ -71,6 +76,8 @@ commands = python -m testtools.run \
|
||||
ceilometer.tests.dispatcher.test_http \
|
||||
ceilometer.tests.energy.test_kwapi \
|
||||
ceilometer.tests.ipmi.platform.test_intel_node_manager \
|
||||
ceilometer.tests.meter.test_notifications.TestMeterDefinition.test_bad_type_cfg_definition \
|
||||
ceilometer.tests.meter.test_notifications.TestMeterDefinition.test_config_missing_fields \
|
||||
ceilometer.tests.network.services.test_fwaas \
|
||||
ceilometer.tests.network.services.test_lbaas \
|
||||
ceilometer.tests.network.services.test_vpnaas \
|
||||
@ -87,6 +94,7 @@ commands = python -m testtools.run \
|
||||
ceilometer.tests.publisher.test_udp \
|
||||
ceilometer.tests.storage.test_get_connection \
|
||||
ceilometer.tests.storage.test_impl_sqlalchemy \
|
||||
ceilometer.tests.storage.test_pymongo_base.CompatibilityTest.test_alarm_get_old_format_matching_metadata_array \
|
||||
ceilometer.tests.test_bin \
|
||||
ceilometer.tests.test_collector \
|
||||
ceilometer.tests.test_coordination \
|
||||
|
Loading…
Reference in New Issue
Block a user