Remove the duplicated error message from Enum
If Enum validation detects invalid parameter, wsme returns a respose like the following message: {"debuginfo": null, "faultcode": "Client", "faultstring": "Invalid input for field/attribute param_enum. Value: 'hourse'. Invalid value (should be one of: dog, cat)" } In faultstring, the first message shows a invalid request. So it is not necessary to contain it in the third message. Change-Id: Ie52660fcf704551ce082f7dca2fadedadb12562a
This commit is contained in:
parent
8f46a0ce71
commit
29547eae59
@ -80,7 +80,7 @@ class TestController(unittest.TestCase):
|
||||
self.assertTrue(
|
||||
res.json_body['faultstring'].startswith(
|
||||
"Invalid input for field/attribute number. Value: 'arf'. \
|
||||
Invalid value (should be one of:"))
|
||||
Value should be one of:"))
|
||||
self.assertIn('v1', res.json_body['faultstring'])
|
||||
self.assertIn('v2', res.json_body['faultstring'])
|
||||
self.assertIn('None', res.json_body['faultstring'])
|
||||
@ -104,7 +104,7 @@ Invalid value (should be one of:"))
|
||||
self.assertTrue(
|
||||
res.json_body['faultstring'].startswith(
|
||||
"Invalid input for field/attribute number. Value: '1'. \
|
||||
Invalid value (should be one of:"))
|
||||
Value should be one of:"))
|
||||
self.assertIn('v1', res.json_body['faultstring'])
|
||||
self.assertIn('v2', res.json_body['faultstring'])
|
||||
self.assertIn('None', res.json_body['faultstring'])
|
||||
|
@ -182,7 +182,7 @@ class TestTypes(unittest.TestCase):
|
||||
|
||||
self.assertRaisesRegexp(exc.InvalidInput,
|
||||
"Invalid input for field/attribute a. \
|
||||
Value: 'v3'. Invalid value \(should be one of: v., v.\)",
|
||||
Value: 'v3'. Value should be one of: v., v.",
|
||||
setattr,
|
||||
obj,
|
||||
'a',
|
||||
|
@ -161,7 +161,7 @@ class Enum(UserType):
|
||||
|
||||
def validate(self, value):
|
||||
if value not in self.values:
|
||||
raise ValueError("Invalid value (should be one of: %s)" %
|
||||
raise ValueError("Value should be one of: %s" %
|
||||
', '.join(map(six.text_type, self.values)))
|
||||
return value
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user