I'm having trouble finding the perfect way to test the API endpoint developed by Django using the Django Rest Framework. I use the integrated APITestCase and execute the query as follows:
response = self.client.get('/resources')
The official documentation ( http://www.django-rest-framework.org/api-guide/testing ) states that it is better to use response.datainstaed response.content. My model includes a field DateTimeField, and response.datalooks like this:
{'id': 1, 'issued': datetime.datetime(2014, 5, 3, 0, 0, tzinfo=<UTC>)}
If the real answer in the browser looks like this:
{"id": 1, "issued": "2014-05-03T00:00:00Z"}
So, I'm not sure how to argue that these two are equal !?
source
share