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:
Witold Bedyk 2018-10-01 17:39:48 +02:00
parent 13c429b1f7
commit 4b33d1b338
2 changed files with 2 additions and 3 deletions

View File

@ -24,8 +24,7 @@ LOG = log.getLogger(__name__)
default_schema = Schema({Required("events"): Any(list, dict),
Required("timestamp"):
Any(str, unicode) if six.PY2 else str})
Required("timestamp"): six.text_type})
def validate_body(request_body):

View File

@ -41,7 +41,7 @@ class TestBodyValidation(base.BaseTestCase):
self.assertRaises(MultipleInvalid, validate_body, body)
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'}]
for b in body:
validate_body(b)