django-rest-framework/djangorestframework/tests/files.py

35 lines
1.1 KiB
Python
Raw Normal View History

2012-08-25 01:11:00 +04:00
# from django.test import TestCase
# from django import forms
2012-08-25 01:11:00 +04:00
# from djangorestframework.compat import RequestFactory
# from djangorestframework.views import View
# from djangorestframework.response import Response
2012-08-25 01:11:00 +04:00
# import StringIO
2012-08-25 01:11:00 +04:00
# class UploadFilesTests(TestCase):
# """Check uploading of files"""
# def setUp(self):
# self.factory = RequestFactory()
2012-08-25 01:11:00 +04:00
# def test_upload_file(self):
2012-08-25 01:11:00 +04:00
# class FileForm(forms.Form):
# file = forms.FileField()
2012-08-25 01:11:00 +04:00
# class MockView(View):
# permissions = ()
# form = FileForm
2011-12-29 17:31:12 +04:00
2012-08-25 01:11:00 +04:00
# def post(self, request, *args, **kwargs):
# return Response({'FILE_NAME': self.CONTENT['file'].name,
# 'FILE_CONTENT': self.CONTENT['file'].read()})
2012-08-25 01:11:00 +04:00
# file = StringIO.StringIO('stuff')
# file.name = 'stuff.txt'
# request = self.factory.post('/', {'file': file})
# view = MockView.as_view()
# response = view(request)
# self.assertEquals(response.raw_content, {"FILE_CONTENT": "stuff", "FILE_NAME": "stuff.txt"})