Update tests to reflect WSME 0.8.0 changes

Error messages have changed when there are invalid subfields and
input handling is somewhat more strict.

This patch was borrowed from a Ceilometer change:
Iea8507ebc54f42786a44bfcd96246b88dd998bf0

Change-Id: I9c68690c4b0a07ad1ac9855424675a9db4625556
Co-Authored-By: Mehdi Abaakouk <sileht@redhat.com>
This commit is contained in:
Chris Dent 2015-08-25 16:42:54 +00:00
parent 217723ce6c
commit fb697129bc
2 changed files with 7 additions and 8 deletions

View File

@ -1411,8 +1411,6 @@ class TestAlarms(TestAlarmsBase):
self._verify_alarm(json, alarm) self._verify_alarm(json, alarm)
def test_put_alarm_wrong_field(self): def test_put_alarm_wrong_field(self):
# Note: wsme will ignore unknown fields so will just not appear in
# the Alarm.
json = { json = {
'this_can_not_be_correct': 'ha', 'this_can_not_be_correct': 'ha',
'enabled': False, 'enabled': False,
@ -1445,9 +1443,10 @@ class TestAlarms(TestAlarmsBase):
alarm_id = data[0]['alarm_id'] alarm_id = data[0]['alarm_id']
resp = self.put_json('/alarms/%s' % alarm_id, resp = self.put_json('/alarms/%s' % alarm_id,
expect_errors=True,
params=json, params=json,
headers=self.auth_headers) headers=self.auth_headers)
self.assertEqual(200, resp.status_code) self.assertEqual(400, resp.status_code)
def test_put_alarm_with_existing_name(self): def test_put_alarm_with_existing_name(self):
"""Test that update a threshold alarm with an existing name.""" """Test that update a threshold alarm with an existing name."""
@ -2210,8 +2209,8 @@ class TestAlarmsRuleThreshold(TestAlarmsBase):
} }
resp = self.post_json('/alarms', params=json, expect_errors=True, resp = self.post_json('/alarms', params=json, expect_errors=True,
status=400, headers=self.auth_headers) status=400, headers=self.auth_headers)
expected_error_message = ("Invalid input for field/attribute field. " expected_error_message = ("Unknown attribute for argument "
"Value: 'None'. Mandatory field missing.") "data.threshold_rule.query: q.field")
fault_string = resp.json['error_message']['faultstring'] fault_string = resp.json['error_message']['faultstring']
self.assertEqual(expected_error_message, fault_string) self.assertEqual(expected_error_message, fault_string)
alarms = list(self.alarm_conn.get_alarms()) alarms = list(self.alarm_conn.get_alarms())
@ -2230,8 +2229,8 @@ class TestAlarmsRuleThreshold(TestAlarmsBase):
} }
resp = self.post_json('/alarms', params=json, expect_errors=True, resp = self.post_json('/alarms', params=json, expect_errors=True,
status=400, headers=self.auth_headers) status=400, headers=self.auth_headers)
expected_error_message = ("Invalid input for field/attribute value. " expected_error_message = ("Unknown attribute for argument "
"Value: 'None'. Mandatory field missing.") "data.threshold_rule.query: q.value")
fault_string = resp.json['error_message']['faultstring'] fault_string = resp.json['error_message']['faultstring']
self.assertEqual(expected_error_message, fault_string) self.assertEqual(expected_error_message, fault_string)
alarms = list(self.alarm_conn.get_alarms()) alarms = list(self.alarm_conn.get_alarms())

View File

@ -33,4 +33,4 @@ stevedore>=1.5.0 # Apache-2.0
tooz>=0.16.0 # Apache-2.0 tooz>=0.16.0 # Apache-2.0
Werkzeug>=0.7 # BSD License Werkzeug>=0.7 # BSD License
WebOb>=1.2.3 WebOb>=1.2.3
WSME>=0.7 WSME>=0.8