def test_upload_endpoint_that_return_success(self):
url = reverse('files:file-upload')
filename = 'bahtiyar.jpg'
client = APIClient()
client.login(username='johndoe', password='johndoe')
client.credentials(HTTP_CONTENT_DISPOSITION='attachment; filename={}'.format(filename))
file = DjangoFile(open('/data/{}'.format(filename), 'rb'))
response = client.post(url, {'name': filename, 'attachment': file})
file.close()
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
评论列表
文章目录