Browse Source

#893: fix build on py3k

Rafał Pitoń 7 years ago
parent
commit
f00999bafc
2 changed files with 4 additions and 4 deletions
  1. 1 1
      misago/markup/api.py
  2. 3 3
      misago/markup/tests/test_api.py

+ 1 - 1
misago/markup/api.py

@@ -11,7 +11,7 @@ def parse_markup(request):
     serializer = MarkupSerializer(data=request.data)
     serializer = MarkupSerializer(data=request.data)
     if not serializer.is_valid():
     if not serializer.is_valid():
         return Response(
         return Response(
-            serializer.errors['non_field_errors'][0],
+            {'detail': serializer.errors['non_field_errors'][0]},
             status=status.HTTP_400_BAD_REQUEST,
             status=status.HTTP_400_BAD_REQUEST,
         )
         )
 
 

+ 3 - 3
misago/markup/tests/test_api.py

@@ -27,13 +27,13 @@ class ParseMarkupApiTests(AuthenticatedUserTestCase):
     def test_invalid_data(self):
     def test_invalid_data(self):
         """api handles post that is invalid type"""
         """api handles post that is invalid type"""
         response = self.client.post(self.api_link, '[]', content_type="application/json")
         response = self.client.post(self.api_link, '[]', content_type="application/json")
-        self.assertContains(response, "Invalid data. Expected a dictionary, but got list.", status_code=400)
+        self.assertContains(response, "Invalid data. Expected a dictionary", status_code=400)
 
 
         response = self.client.post(self.api_link, '123', content_type="application/json")
         response = self.client.post(self.api_link, '123', content_type="application/json")
-        self.assertContains(response, "Invalid data. Expected a dictionary, but got int.", status_code=400)
+        self.assertContains(response, "Invalid data. Expected a dictionary", status_code=400)
 
 
         response = self.client.post(self.api_link, '"string"', content_type="application/json")
         response = self.client.post(self.api_link, '"string"', content_type="application/json")
-        self.assertContains(response, "Invalid data. Expected a dictionary, but got unicode.", status_code=400)
+        self.assertContains(response, "Invalid data. Expected a dictionary", status_code=400)
 
 
         response = self.client.post(self.api_link, 'malformed', content_type="application/json")
         response = self.client.post(self.api_link, 'malformed', content_type="application/json")
         self.assertContains(response, "JSON parse error - No JSON object could be decoded", status_code=400)
         self.assertContains(response, "JSON parse error - No JSON object could be decoded", status_code=400)