I defined an API endpoint which accepts a file (e.g. using Django REST Framework). In Django, the content disposition header can be used when inspecting the response.
Now, if we want to set the header when testing the endpoint, how do I include this header using REST-Framework's APITestCase?
What I tried so far is, but it does not seem to accept the headers.
class TestSaleViews(APITestCase):
def test_sale_detail_view(self):
f = create_named_temporary_file()
files = {'archive': f}
basename = os.path.basename(f.name)
headers = {
'content-disposition': 'attachment; filename={}'.format(basename),
}
response = self.client.post(url, files, format='multipart', **headers)