aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/test_testing.py
diff options
context:
space:
mode:
authorIan Foote2014-01-28 15:54:50 +0000
committerIan Foote2014-01-28 15:54:50 +0000
commit78e4468f0367cc2a3a5cc6f3570a791ad67c90d9 (patch)
tree370759164930fae5bb5483cdb2ac8b06d1df5a2f /rest_framework/tests/test_testing.py
parent74fec7eeb4e7e2e593ed5e2213020024264681ce (diff)
downloaddjango-rest-framework-78e4468f0367cc2a3a5cc6f3570a791ad67c90d9.tar.bz2
Add file upload test for APIRequestFactory
Remove test_compat
Diffstat (limited to 'rest_framework/tests/test_testing.py')
-rw-r--r--rest_framework/tests/test_testing.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/rest_framework/tests/test_testing.py b/rest_framework/tests/test_testing.py
index 48b8956b..71bd8b55 100644
--- a/rest_framework/tests/test_testing.py
+++ b/rest_framework/tests/test_testing.py
@@ -1,6 +1,8 @@
# -- coding: utf-8 --
from __future__ import unicode_literals
+from io import BytesIO
+
from django.contrib.auth.models import User
from django.test import TestCase
from rest_framework.compat import patterns, url
@@ -143,3 +145,10 @@ class TestAPIRequestFactory(TestCase):
force_authenticate(request, user=user)
response = view(request)
self.assertEqual(response.data['user'], 'example')
+
+ def test_upload_file(self):
+ # This is a 1x1 black png
+ simple_png = BytesIO(b'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\rIDATx\x9cc````\x00\x00\x00\x05\x00\x01\xa5\xf6E@\x00\x00\x00\x00IEND\xaeB`\x82')
+ simple_png.name = 'test.png'
+ factory = APIRequestFactory()
+ factory.post('/', data={'image': simple_png})