I have a django test method that is supposed to test that the correct image was returned in an httpresponse. Here is the code for the test:
c = Client()
originalFilePath = '../static_cdn/test.jpg'
image_data = open(originalFilePath, "rb")
with open(originalFilePath, "rb") as fp:
response = c.post('/', {'image': fp})
self.assertEqual(image_data, response)
The test isn't working because I'm comparing the opened image with the entire http response instead of just the image it has. I've tried to access the image by checking for fields it may have but it doesn't appear to have any. In the view I'm returning the image using HttpResponse(image_data, content_type="image/jpg")
and from looking at the fields from the class in the docs I'm not seeing a field that would return the image. How can I access the image from the httpresponse so that it can be tested?