Fix body validation for Python 3
The API should expect timestamp as text, not binary data. Change-Id: I07a26c09a19a96907da7210b3fb1544a409b562a Story: 2003240 Task: 26832
This commit is contained in:
parent
13c429b1f7
commit
4b33d1b338
|
@ -24,8 +24,7 @@ LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
default_schema = Schema({Required("events"): Any(list, dict),
|
default_schema = Schema({Required("events"): Any(list, dict),
|
||||||
Required("timestamp"):
|
Required("timestamp"): six.text_type})
|
||||||
Any(str, unicode) if six.PY2 else str})
|
|
||||||
|
|
||||||
|
|
||||||
def validate_body(request_body):
|
def validate_body(request_body):
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestBodyValidation(base.BaseTestCase):
|
||||||
self.assertRaises(MultipleInvalid, validate_body, body)
|
self.assertRaises(MultipleInvalid, validate_body, body)
|
||||||
|
|
||||||
def test_correct_body(self):
|
def test_correct_body(self):
|
||||||
body = [{'events': [], 'timestamp': '2012-10-29T13:42:11Z+0200'},
|
body = [{'events': [], 'timestamp': u'2012-10-29T13:42:11Z+0200'},
|
||||||
{'events': {}, 'timestamp': u'2012-10-29T13:42:11Z+0200'}]
|
{'events': {}, 'timestamp': u'2012-10-29T13:42:11Z+0200'}]
|
||||||
for b in body:
|
for b in body:
|
||||||
validate_body(b)
|
validate_body(b)
|
||||||
|
|
Loading…
Reference in New Issue