aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/tests/test_testing.py
diff options
context:
space:
mode:
Diffstat (limited to 'rest_framework/tests/test_testing.py')
-rw-r--r--rest_framework/tests/test_testing.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/rest_framework/tests/test_testing.py b/rest_framework/tests/test_testing.py
index c08dd493..83ae8148 100644
--- a/rest_framework/tests/test_testing.py
+++ b/rest_framework/tests/test_testing.py
@@ -2,6 +2,8 @@
from __future__ import unicode_literals
from django.conf.urls import patterns, url
+from io import BytesIO
+
from django.contrib.auth.models import User
from django.test import TestCase
from rest_framework.decorators import api_view
@@ -143,3 +145,20 @@ 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})
+
+ def test_request_factory_url_arguments(self):
+ """
+ This is a non regression test against #1461
+ """
+ factory = APIRequestFactory()
+ request = factory.get('/view/?demo=test')
+ self.assertEqual(dict(request.GET), {'demo': ['test']})
+ request = factory.get('/view/', {'demo': 'test'})
+ self.assertEqual(dict(request.GET), {'demo': ['test']})