2012-08-25 01:11:00 +04:00
|
|
|
# from django.test import TestCase
|
|
|
|
# from django import forms
|
2012-02-02 20:19:44 +04:00
|
|
|
|
2012-08-25 01:11:00 +04:00
|
|
|
# from djangorestframework.compat import RequestFactory
|
|
|
|
# from djangorestframework.views import View
|
|
|
|
# from djangorestframework.response import Response
|
2012-02-02 20:19:44 +04:00
|
|
|
|
2012-08-25 01:11:00 +04:00
|
|
|
# import StringIO
|
2011-04-02 19:32:37 +04:00
|
|
|
|
|
|
|
|
2012-08-25 01:11:00 +04:00
|
|
|
# class UploadFilesTests(TestCase):
|
|
|
|
# """Check uploading of files"""
|
|
|
|
# def setUp(self):
|
|
|
|
# self.factory = RequestFactory()
|
2011-04-02 19:32:37 +04:00
|
|
|
|
2012-08-25 01:11:00 +04:00
|
|
|
# def test_upload_file(self):
|
2011-05-12 15:55:13 +04:00
|
|
|
|
2012-08-25 01:11:00 +04:00
|
|
|
# class FileForm(forms.Form):
|
|
|
|
# file = forms.FileField()
|
2011-04-02 19:32:37 +04:00
|
|
|
|
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()})
|
2011-04-02 19:32:37 +04:00
|
|
|
|
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"})
|