Skip to content

Commit

Permalink
Fixing workaround for CamelCase renderer issue
Browse files Browse the repository at this point in the history
  • Loading branch information
magul authored and elspawaczo committed Sep 24, 2017
1 parent 5313cb0 commit ec7910c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 13 deletions.
7 changes: 1 addition & 6 deletions backend/apps/volontulo/tests/views/api/offers/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
.. module:: test_list
"""

from io import BytesIO

from rest_framework import status
from rest_framework.test import APITestCase
from djangorestframework_camel_case.parser import CamelCaseJSONParser

from apps.volontulo.tests.views.offers.commons import TestOffersCommons

Expand All @@ -21,9 +18,7 @@ def test_offer_list_fields(self):
"""Test list's fields of offers REST API endpoint."""
response = self.client.get('/api/offers/')
self.assertEqual(response.status_code, status.HTTP_200_OK)
# dirty hack intead of checking response.data because of issue
# djangorestframework-camel-case #26:
for offer in CamelCaseJSONParser().parse(BytesIO(response.content)):
for offer in response.data:
self.assertIsInstance(offer.pop('finished_at'), str)
self.assertIsInstance(offer.pop('id'), int)
self.assertIsInstance(offer.pop('image'), (str, type(None)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@
.. module:: test_list
"""

from io import BytesIO

from rest_framework import status
from rest_framework.test import APITestCase
from djangorestframework_camel_case.parser import CamelCaseJSONParser

from apps.volontulo.tests.views.offers.commons import TestOffersCommons

Expand All @@ -21,10 +18,7 @@ def test_organization_list_fields(self):
"""Test list's fields of organization REST API endpoint."""
response = self.client.get('/api/organizations/')
self.assertEqual(response.status_code, status.HTTP_200_OK)
# dirty hack intead of checking response.data because of issue
# djangorestframework-camel-case #26:
for organization in CamelCaseJSONParser().parse(
BytesIO(response.content)):
for organization in response.data:
self.assertIsInstance(organization.pop('id'), int)
self.assertIsInstance(organization.pop('name'), str)
self.assertIsInstance(organization.pop('slug'), str)
Expand Down

0 comments on commit ec7910c

Please sign in to comment.