diff options
| author | Ian Foote | 2014-01-28 15:54:50 +0000 | 
|---|---|---|
| committer | Ian Foote | 2014-01-28 15:54:50 +0000 | 
| commit | 78e4468f0367cc2a3a5cc6f3570a791ad67c90d9 (patch) | |
| tree | 370759164930fae5bb5483cdb2ac8b06d1df5a2f | |
| parent | 74fec7eeb4e7e2e593ed5e2213020024264681ce (diff) | |
| download | django-rest-framework-78e4468f0367cc2a3a5cc6f3570a791ad67c90d9.tar.bz2 | |
Add file upload test for APIRequestFactory
Remove test_compat
| -rw-r--r-- | rest_framework/tests/test_compat.py | 13 | ||||
| -rw-r--r-- | rest_framework/tests/test_testing.py | 9 | 
2 files changed, 9 insertions, 13 deletions
diff --git a/rest_framework/tests/test_compat.py b/rest_framework/tests/test_compat.py deleted file mode 100644 index 4916d19b..00000000 --- a/rest_framework/tests/test_compat.py +++ /dev/null @@ -1,13 +0,0 @@ -import django -from django.test import TestCase - - -class TestCompat(TestCase): -    def test_force_bytes_or_smart_bytes(self): -        from rest_framework.compat import force_bytes_or_smart_bytes -        if django.VERSION >= (1, 5): -            from django.utils.encoding import force_bytes -            self.assertEqual(force_bytes_or_smart_bytes, force_bytes) -        else: -            from django.utils.encoding import smart_str -            self.assertEqual(force_bytes_or_smart_bytes, smart_str) 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})  | 
