WSME 0.5b5 breaking unit tests
- fix tests to accept new (accurate) response codes - wsme doesn't like us sending gettextutils.Message values. pass in a regular string Change-Id: Ie9e05edfd542ba1fe8c6fdbeed2daab12cf30caf Fixes:Bug #1227264
This commit is contained in:
parent
5bf2072ac7
commit
3a480cb424
@ -197,17 +197,17 @@ class Query(_Base):
|
|||||||
msg = _('Failed to convert the metadata value %(value)s'
|
msg = _('Failed to convert the metadata value %(value)s'
|
||||||
' to the expected data type %(type)s.') % \
|
' to the expected data type %(type)s.') % \
|
||||||
{'value': self.value, 'type': self.type}
|
{'value': self.value, 'type': self.type}
|
||||||
raise wsme.exc.ClientSideError(msg)
|
raise wsme.exc.ClientSideError(unicode(msg))
|
||||||
except TypeError:
|
except TypeError:
|
||||||
msg = _('The data type %s is not supported. The supported'
|
msg = _('The data type %s is not supported. The supported'
|
||||||
' data type list is: integer, float, boolean and'
|
' data type list is: integer, float, boolean and'
|
||||||
' string.') % (self.type)
|
' string.') % (self.type)
|
||||||
raise wsme.exc.ClientSideError(msg)
|
raise wsme.exc.ClientSideError(unicode(msg))
|
||||||
except Exception:
|
except Exception:
|
||||||
msg = _('Unexpected exception converting %(value)s to'
|
msg = _('Unexpected exception converting %(value)s to'
|
||||||
' the expected data type %(type)s.') % \
|
' the expected data type %(type)s.') % \
|
||||||
{'value': self.value, 'type': self.type}
|
{'value': self.value, 'type': self.type}
|
||||||
raise wsme.exc.ClientSideError(msg)
|
raise wsme.exc.ClientSideError(unicode(msg))
|
||||||
return converted_value
|
return converted_value
|
||||||
|
|
||||||
|
|
||||||
@ -672,7 +672,7 @@ class MeterController(rest.RestController):
|
|||||||
if period and period < 0:
|
if period and period < 0:
|
||||||
error = _("Period must be positive.")
|
error = _("Period must be positive.")
|
||||||
pecan.response.translatable_error = error
|
pecan.response.translatable_error = error
|
||||||
raise wsme.exc.ClientSideError(error)
|
raise wsme.exc.ClientSideError(unicode(error))
|
||||||
|
|
||||||
kwargs = _query_to_kwargs(q, storage.SampleFilter.__init__)
|
kwargs = _query_to_kwargs(q, storage.SampleFilter.__init__)
|
||||||
kwargs['meter'] = self._id
|
kwargs['meter'] = self._id
|
||||||
@ -834,7 +834,7 @@ class ResourcesController(rest.RestController):
|
|||||||
pecan.response.translatable_error = error
|
pecan.response.translatable_error = error
|
||||||
raise wsme.exc.InvalidInput("resource_id",
|
raise wsme.exc.InvalidInput("resource_id",
|
||||||
resource_id,
|
resource_id,
|
||||||
error)
|
unicode(error))
|
||||||
return Resource.from_db_and_links(resources[0],
|
return Resource.from_db_and_links(resources[0],
|
||||||
self._resource_links(resource_id))
|
self._resource_links(resource_id))
|
||||||
|
|
||||||
@ -1011,7 +1011,7 @@ class AlarmController(rest.RestController):
|
|||||||
if len(alarms) < 1:
|
if len(alarms) < 1:
|
||||||
error = _("Unknown alarm")
|
error = _("Unknown alarm")
|
||||||
pecan.response.translatable_error = error
|
pecan.response.translatable_error = error
|
||||||
raise wsme.exc.ClientSideError(error)
|
raise wsme.exc.ClientSideError(unicode(error))
|
||||||
return alarms[0]
|
return alarms[0]
|
||||||
|
|
||||||
def _record_change(self, data, now, on_behalf_of=None, type=None):
|
def _record_change(self, data, now, on_behalf_of=None, type=None):
|
||||||
@ -1141,7 +1141,7 @@ class AlarmsController(rest.RestController):
|
|||||||
if len(alarms) > 0:
|
if len(alarms) > 0:
|
||||||
error = _("Alarm with that name exists")
|
error = _("Alarm with that name exists")
|
||||||
pecan.response.translatable_error = error
|
pecan.response.translatable_error = error
|
||||||
raise wsme.exc.ClientSideError(error)
|
raise wsme.exc.ClientSideError(unicode(error))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
kwargs = data.as_dict(storage.models.Alarm)
|
kwargs = data.as_dict(storage.models.Alarm)
|
||||||
@ -1150,7 +1150,7 @@ class AlarmsController(rest.RestController):
|
|||||||
LOG.exception(ex)
|
LOG.exception(ex)
|
||||||
error = _("Alarm incorrect")
|
error = _("Alarm incorrect")
|
||||||
pecan.response.translatable_error = error
|
pecan.response.translatable_error = error
|
||||||
raise wsme.exc.ClientSideError(error)
|
raise wsme.exc.ClientSideError(unicode(error))
|
||||||
|
|
||||||
alarm = conn.create_alarm(alarm_in)
|
alarm = conn.create_alarm(alarm_in)
|
||||||
self._record_creation(conn, change, alarm.alarm_id, now)
|
self._record_creation(conn, change, alarm.alarm_id, now)
|
||||||
|
@ -124,7 +124,7 @@ class TestAlarms(FunctionalTest,
|
|||||||
'statistic': 'avg',
|
'statistic': 'avg',
|
||||||
'repeat_actions': True,
|
'repeat_actions': True,
|
||||||
}
|
}
|
||||||
self.post_json('/alarms', params=json, status=200,
|
self.post_json('/alarms', params=json, status=201,
|
||||||
headers=self.auth_headers)
|
headers=self.auth_headers)
|
||||||
alarms = list(self.conn.get_alarms())
|
alarms = list(self.conn.get_alarms())
|
||||||
self.assertEqual(4, len(alarms))
|
self.assertEqual(4, len(alarms))
|
||||||
@ -180,7 +180,7 @@ class TestAlarms(FunctionalTest,
|
|||||||
|
|
||||||
self.delete('/alarms/%s' % data[0]['alarm_id'],
|
self.delete('/alarms/%s' % data[0]['alarm_id'],
|
||||||
headers=self.auth_headers,
|
headers=self.auth_headers,
|
||||||
status=200)
|
status=204)
|
||||||
alarms = list(self.conn.get_alarms())
|
alarms = list(self.conn.get_alarms())
|
||||||
self.assertEqual(2, len(alarms))
|
self.assertEqual(2, len(alarms))
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ class TestAlarms(FunctionalTest,
|
|||||||
def _delete_alarm(self, alarm, auth_headers=None):
|
def _delete_alarm(self, alarm, auth_headers=None):
|
||||||
self.delete('/alarms/%s' % alarm['alarm_id'],
|
self.delete('/alarms/%s' % alarm['alarm_id'],
|
||||||
headers=auth_headers or self.auth_headers,
|
headers=auth_headers or self.auth_headers,
|
||||||
status=200)
|
status=204)
|
||||||
|
|
||||||
def _assert_is_subset(self, expected, actual):
|
def _assert_is_subset(self, expected, actual):
|
||||||
for k, v in expected.iteritems():
|
for k, v in expected.iteritems():
|
||||||
@ -242,7 +242,7 @@ class TestAlarms(FunctionalTest,
|
|||||||
comparison_operator='le',
|
comparison_operator='le',
|
||||||
threshold=42.0,
|
threshold=42.0,
|
||||||
statistic='max')
|
statistic='max')
|
||||||
self.post_json('/alarms', params=new_alarm, status=200,
|
self.post_json('/alarms', params=new_alarm, status=201,
|
||||||
headers=self.auth_headers)
|
headers=self.auth_headers)
|
||||||
alarm = self.get_json('/alarms')[3]
|
alarm = self.get_json('/alarms')[3]
|
||||||
history = self._get_alarm_history(alarm)
|
history = self._get_alarm_history(alarm)
|
||||||
@ -304,7 +304,7 @@ class TestAlarms(FunctionalTest,
|
|||||||
comparison_operator='le',
|
comparison_operator='le',
|
||||||
threshold=42.0,
|
threshold=42.0,
|
||||||
statistic='max')
|
statistic='max')
|
||||||
self.post_json('/alarms', params=new_alarm, status=200,
|
self.post_json('/alarms', params=new_alarm, status=201,
|
||||||
headers=member_auth)
|
headers=member_auth)
|
||||||
alarm = self.get_json('/alarms', headers=member_auth)[0]
|
alarm = self.get_json('/alarms', headers=member_auth)[0]
|
||||||
|
|
||||||
@ -366,7 +366,7 @@ class TestAlarms(FunctionalTest,
|
|||||||
alarm = self._get_alarm('a')
|
alarm = self._get_alarm('a')
|
||||||
self.delete('/alarms/%s' % alarm['alarm_id'],
|
self.delete('/alarms/%s' % alarm['alarm_id'],
|
||||||
headers=self.auth_headers,
|
headers=self.auth_headers,
|
||||||
status=200)
|
status=204)
|
||||||
history = self._get_alarm_history(alarm)
|
history = self._get_alarm_history(alarm)
|
||||||
self.assertEqual(2, len(history))
|
self.assertEqual(2, len(history))
|
||||||
self._assert_is_subset(dict(alarm_id=alarm['alarm_id'],
|
self._assert_is_subset(dict(alarm_id=alarm['alarm_id'],
|
||||||
|
Loading…
Reference in New Issue
Block a user