Browse Source

Fix body validation for Python 3

The API should expect timestamp as text, not binary data.

Change-Id: I07a26c09a19a96907da7210b3fb1544a409b562a
Story: 2003240
Task: 26832
Witold Bedyk 6 months ago
parent
commit
4b33d1b338

+ 1
- 2
monasca_events_api/app/controller/v1/body_validation.py View File

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

+ 1
- 1
monasca_events_api/tests/unit/test_body_valodiation.py View File

@@ -41,7 +41,7 @@ class TestBodyValidation(base.BaseTestCase):
41 41
         self.assertRaises(MultipleInvalid, validate_body, body)
42 42
 
43 43
     def test_correct_body(self):
44
-        body = [{'events': [], 'timestamp': '2012-10-29T13:42:11Z+0200'},
44
+        body = [{'events': [], 'timestamp': u'2012-10-29T13:42:11Z+0200'},
45 45
                 {'events': {}, 'timestamp': u'2012-10-29T13:42:11Z+0200'}]
46 46
         for b in body:
47 47
             validate_body(b)

Loading…
Cancel
Save