diff options
| -rw-r--r-- | docs/topics/contributing.md | 11 | ||||
| -rw-r--r-- | rest_framework/compat.py | 46 | ||||
| -rw-r--r-- | rest_framework/tests/decorators.py | 2 | ||||
| -rw-r--r-- | rest_framework/tests/files.py | 2 | ||||
| -rw-r--r-- | rest_framework/tests/mixins.py | 2 | ||||
| -rw-r--r-- | rest_framework/tests/package.py | 11 | ||||
| -rw-r--r-- | rest_framework/tests/parsers.py | 4 | ||||
| -rw-r--r-- | rest_framework/tests/request.py | 15 | ||||
| -rw-r--r-- | rest_framework/tests/throttling.py | 2 | ||||
| -rw-r--r-- | tox.ini | 24 |
10 files changed, 45 insertions, 74 deletions
diff --git a/docs/topics/contributing.md b/docs/topics/contributing.md index 8e8b98ac..7fd61c10 100644 --- a/docs/topics/contributing.md +++ b/docs/topics/contributing.md @@ -1,8 +1,15 @@ # Contributing to REST framework +> The world can only really be changed one piece at a time. The art is picking that piece. +> +> — [Tim Berners-Lee][cite] + +## Running the tests + +## Building the docs + ## Managing compatibility issues **Describe compat module** -## Running the tests - +[cite]: http://www.w3.org/People/Berners-Lee/FAQ.html
\ No newline at end of file diff --git a/rest_framework/compat.py b/rest_framework/compat.py index fb3f67d9..ef713ed8 100644 --- a/rest_framework/compat.py +++ b/rest_framework/compat.py @@ -19,52 +19,6 @@ except ImportError: from cgi import parse_qs -# django.test.client.RequestFactory (Required for Django < 1.3) -try: - from django.test.client import RequestFactory -except ImportError: - from django.test import Client - from django.core.handlers.wsgi import WSGIRequest - - # From: http://djangosnippets.org/snippets/963/ - # Lovely stuff - class RequestFactory(Client): - """ - Class that lets you create mock :obj:`Request` objects for use in testing. - - Usage:: - - rf = RequestFactory() - get_request = rf.get('/hello/') - post_request = rf.post('/submit/', {'foo': 'bar'}) - - This class re-uses the :class:`django.test.client.Client` interface. Of which - you can find the docs here__. - - __ http://www.djangoproject.com/documentation/testing/#the-test-client - - Once you have a `request` object you can pass it to any :func:`view` function, - just as if that :func:`view` had been hooked up using a URLconf. - """ - def request(self, **request): - """ - Similar to parent class, but returns the :obj:`request` object as soon as it - has created it. - """ - environ = { - 'HTTP_COOKIE': self.cookies, - 'PATH_INFO': '/', - 'QUERY_STRING': '', - 'REQUEST_METHOD': 'GET', - 'SCRIPT_NAME': '', - 'SERVER_NAME': 'testserver', - 'SERVER_PORT': 80, - 'SERVER_PROTOCOL': 'HTTP/1.1', - } - environ.update(self.defaults) - environ.update(request) - return WSGIRequest(environ) - # django.views.generic.View (Django >= 1.3) try: from django.views.generic import View diff --git a/rest_framework/tests/decorators.py b/rest_framework/tests/decorators.py index 9aeaf7d8..4be53786 100644 --- a/rest_framework/tests/decorators.py +++ b/rest_framework/tests/decorators.py @@ -1,7 +1,7 @@ from django.test import TestCase from rest_framework import status from rest_framework.response import Response -from rest_framework.compat import RequestFactory +from django.test.client import RequestFactory from rest_framework.renderers import JSONRenderer from rest_framework.parsers import JSONParser from rest_framework.authentication import BasicAuthentication diff --git a/rest_framework/tests/files.py b/rest_framework/tests/files.py index eb5c7741..61d7f7b1 100644 --- a/rest_framework/tests/files.py +++ b/rest_framework/tests/files.py @@ -1,7 +1,7 @@ # from django.test import TestCase # from django import forms -# from rest_framework.compat import RequestFactory +# from django.test.client import RequestFactory # from rest_framework.views import View # from rest_framework.response import Response diff --git a/rest_framework/tests/mixins.py b/rest_framework/tests/mixins.py index def06464..8f6d64fb 100644 --- a/rest_framework/tests/mixins.py +++ b/rest_framework/tests/mixins.py @@ -1,7 +1,7 @@ # """Tests for the mixin module""" # from django.test import TestCase # from rest_framework import status -# from rest_framework.compat import RequestFactory +# from django.test.client import RequestFactory # from django.contrib.auth.models import Group, User # from rest_framework.mixins import CreateModelMixin, PaginatorMixin, ReadModelMixin # from rest_framework.resources import ModelResource diff --git a/rest_framework/tests/package.py b/rest_framework/tests/package.py deleted file mode 100644 index db133b09..00000000 --- a/rest_framework/tests/package.py +++ /dev/null @@ -1,11 +0,0 @@ -"""Tests for the rest_framework package setup.""" -from django.test import TestCase -import rest_framework - -class TestVersion(TestCase): - """Simple sanity test to check the VERSION exists""" - - def test_version(self): - """Ensure the VERSION exists.""" - rest_framework.VERSION - diff --git a/rest_framework/tests/parsers.py b/rest_framework/tests/parsers.py index 4cafd660..8ab8a52f 100644 --- a/rest_framework/tests/parsers.py +++ b/rest_framework/tests/parsers.py @@ -1,7 +1,7 @@ # """ # .. # >>> from rest_framework.parsers import FormParser -# >>> from rest_framework.compat import RequestFactory +# >>> from django.test.client import RequestFactory # >>> from rest_framework.views import View # >>> from StringIO import StringIO # >>> from urllib import urlencode @@ -83,7 +83,7 @@ # import httplib, mimetypes # from tempfile import TemporaryFile # from django.test import TestCase -# from rest_framework.compat import RequestFactory +# from django.test.client import RequestFactory # from rest_framework.parsers import MultiPartParser # from rest_framework.views import View # from StringIO import StringIO diff --git a/rest_framework/tests/request.py b/rest_framework/tests/request.py index 805f6efc..42274fcd 100644 --- a/rest_framework/tests/request.py +++ b/rest_framework/tests/request.py @@ -7,7 +7,7 @@ from django.test import TestCase, Client from rest_framework import status from rest_framework.authentication import SessionAuthentication -from rest_framework.compat import RequestFactory +from django.test.client import RequestFactory from rest_framework.parsers import ( FormParser, MultiPartParser, @@ -55,7 +55,7 @@ class TestContentParsing(TestCase): request = Request(factory.head('/')) self.assertEqual(request.DATA, None) - def test_standard_behaviour_determines_form_content_POST(self): + def test_request_DATA_with_form_content(self): """ Ensure request.DATA returns content for POST request with form content. """ @@ -64,7 +64,7 @@ class TestContentParsing(TestCase): request.parser_classes = (FormParser, MultiPartParser) self.assertEqual(request.DATA.items(), data.items()) - def test_standard_behaviour_determines_non_form_content_POST(self): + def test_request_DATA_with_text_content(self): """ Ensure request.DATA returns content for POST request with non-form content. @@ -75,6 +75,15 @@ class TestContentParsing(TestCase): request.parser_classes = (PlainTextParser,) self.assertEqual(request.DATA, content) + def test_request_POST_with_form_content(self): + """ + Ensure request.POST returns content for POST request with form content. + """ + data = {'qwerty': 'uiop'} + request = Request(factory.post('/', data)) + request.parser_classes = (FormParser, MultiPartParser) + self.assertEqual(request.POST.items(), data.items()) + def test_standard_behaviour_determines_form_content_PUT(self): """ Ensure request.DATA returns content for PUT request with form content. diff --git a/rest_framework/tests/throttling.py b/rest_framework/tests/throttling.py index 0058a28e..0b94c25b 100644 --- a/rest_framework/tests/throttling.py +++ b/rest_framework/tests/throttling.py @@ -6,7 +6,7 @@ from django.test import TestCase from django.contrib.auth.models import User from django.core.cache import cache -from rest_framework.compat import RequestFactory +from django.test.client import RequestFactory from rest_framework.views import APIView from rest_framework.throttling import UserRateThrottle from rest_framework.response import Response @@ -1,18 +1,30 @@ [tox] downloadcache = {toxworkdir}/cache/ -envlist = python2.6-django1.5,python2.6-django1.4,python2.6-django1.3 +envlist = py2.7-django1.5,py2.7-django1.4,py2.7-django1.3,py2.6-django1.5,py2.6-django1.4,py2.6-django1.3 [testenv] commands = {envpython} rest_framework/runtests/runtests.py -[testenv:python2.6-django1.5] +[testenv:py2.7-django1.5] +basepython = python2.7 +deps = https://github.com/django/django/zipball/master + +[testenv:py2.7-django1.4] +basepython = python2.7 +deps = django>=1.4.1 + +[testenv:py2.7-django1.3] +basepython = python2.7 +deps = django>=1.3.2 + +[testenv:py2.6-django1.5] basepython = python2.6 deps = https://github.com/django/django/zipball/master -[testenv:python2.6-django1.4] +[testenv:py2.6-django1.4] basepython = python2.6 -deps = django>=1.4,<1.5 +deps = django>=1.4.1 -[testenv:python2.6-django1.3] +[testenv:py2.6-django1.3] basepython = python2.6 -deps = django>=1.3,<1.4 +deps = django>=1.3.2 |
