diff options
| author | Tom Christie | 2011-04-11 16:38:00 +0100 |
|---|---|---|
| committer | Tom Christie | 2011-04-11 16:38:00 +0100 |
| commit | 349ffcaf5f03b55d8ffe92999814ba97da5ca870 (patch) | |
| tree | b12c6fd3504af09000d480a8f38c1b76d095afda /djangorestframework/tests | |
| parent | a1ed565081779e3f50e9f0ff280a813a46f3613d (diff) | |
| download | django-rest-framework-349ffcaf5f03b55d8ffe92999814ba97da5ca870.tar.bz2 | |
Rename mixins into Mixin class, rename ResponseException to ErrorResponse, remove NoContent
Diffstat (limited to 'djangorestframework/tests')
| -rw-r--r-- | djangorestframework/tests/content.py | 2 | ||||
| -rw-r--r-- | djangorestframework/tests/emitters.py | 5 | ||||
| -rw-r--r-- | djangorestframework/tests/methods.py | 2 | ||||
| -rw-r--r-- | djangorestframework/tests/validators.py | 20 |
4 files changed, 15 insertions, 14 deletions
diff --git a/djangorestframework/tests/content.py b/djangorestframework/tests/content.py index b99f30f7..6695bf68 100644 --- a/djangorestframework/tests/content.py +++ b/djangorestframework/tests/content.py @@ -3,7 +3,7 @@ Tests for content parsing, and form-overloaded content parsing. """ from django.test import TestCase from djangorestframework.compat import RequestFactory -from djangorestframework.request import RequestMixin +from djangorestframework.mixins import RequestMixin from djangorestframework.parsers import FormParser, MultipartParser, PlainTextParser diff --git a/djangorestframework/tests/emitters.py b/djangorestframework/tests/emitters.py index 7d024ccf..21a7eb95 100644 --- a/djangorestframework/tests/emitters.py +++ b/djangorestframework/tests/emitters.py @@ -2,7 +2,8 @@ from django.conf.urls.defaults import patterns, url from django import http from django.test import TestCase from djangorestframework.compat import View -from djangorestframework.emitters import EmitterMixin, BaseEmitter +from djangorestframework.emitters import BaseEmitter +from djangorestframework.mixins import ResponseMixin from djangorestframework.response import Response DUMMYSTATUS = 200 @@ -11,7 +12,7 @@ DUMMYCONTENT = 'dummycontent' EMITTER_A_SERIALIZER = lambda x: 'Emitter A: %s' % x EMITTER_B_SERIALIZER = lambda x: 'Emitter B: %s' % x -class MockView(EmitterMixin, View): +class MockView(ResponseMixin, View): def get(self, request): response = Response(DUMMYSTATUS, DUMMYCONTENT) return self.emit(response) diff --git a/djangorestframework/tests/methods.py b/djangorestframework/tests/methods.py index 7f6acf4f..0e74dc94 100644 --- a/djangorestframework/tests/methods.py +++ b/djangorestframework/tests/methods.py @@ -1,6 +1,6 @@ from django.test import TestCase from djangorestframework.compat import RequestFactory -from djangorestframework.request import RequestMixin +from djangorestframework.mixins import RequestMixin class TestMethodOverloading(TestCase): diff --git a/djangorestframework/tests/validators.py b/djangorestframework/tests/validators.py index a091cf29..b6563db6 100644 --- a/djangorestframework/tests/validators.py +++ b/djangorestframework/tests/validators.py @@ -3,7 +3,7 @@ from django.db import models from django.test import TestCase from djangorestframework.compat import RequestFactory from djangorestframework.validators import BaseValidator, FormValidator, ModelFormValidator -from djangorestframework.response import ResponseException +from djangorestframework.response import ErrorResponse class TestValidatorMixinInterfaces(TestCase): @@ -81,7 +81,7 @@ class TestNonFieldErrors(TestCase): content = {'field1': 'example1', 'field2': 'example2'} try: FormValidator(view).validate(content) - except ResponseException, exc: + except ErrorResponse, exc: self.assertEqual(exc.response.raw_content, {'errors': [MockForm.ERROR_TEXT]}) else: self.fail('ResourceException was not raised') #pragma: no cover @@ -115,14 +115,14 @@ class TestFormValidation(TestCase): def validation_failure_raises_response_exception(self, validator): """If form validation fails a ResourceException 400 (Bad Request) should be raised.""" content = {} - self.assertRaises(ResponseException, validator.validate, content) + self.assertRaises(ErrorResponse, validator.validate, content) def validation_does_not_allow_extra_fields_by_default(self, validator): """If some (otherwise valid) content includes fields that are not in the form then validation should fail. It might be okay on normal form submission, but for Web APIs we oughta get strict, as it'll help show up broken clients more easily (eg submitting content with a misnamed field)""" content = {'qwerty': 'uiop', 'extra': 'extra'} - self.assertRaises(ResponseException, validator.validate, content) + self.assertRaises(ErrorResponse, validator.validate, content) def validation_allows_extra_fields_if_explicitly_set(self, validator): """If we include an allowed_extra_fields paramater on _validate, then allow fields with those names.""" @@ -139,7 +139,7 @@ class TestFormValidation(TestCase): content = {} try: validator.validate(content) - except ResponseException, exc: + except ErrorResponse, exc: self.assertEqual(exc.response.raw_content, {'field-errors': {'qwerty': ['This field is required.']}}) else: self.fail('ResourceException was not raised') #pragma: no cover @@ -149,7 +149,7 @@ class TestFormValidation(TestCase): content = {'qwerty': ''} try: validator.validate(content) - except ResponseException, exc: + except ErrorResponse, exc: self.assertEqual(exc.response.raw_content, {'field-errors': {'qwerty': ['This field is required.']}}) else: self.fail('ResourceException was not raised') #pragma: no cover @@ -159,7 +159,7 @@ class TestFormValidation(TestCase): content = {'qwerty': 'uiop', 'extra': 'extra'} try: validator.validate(content) - except ResponseException, exc: + except ErrorResponse, exc: self.assertEqual(exc.response.raw_content, {'field-errors': {'extra': ['This field does not exist.']}}) else: self.fail('ResourceException was not raised') #pragma: no cover @@ -169,7 +169,7 @@ class TestFormValidation(TestCase): content = {'qwerty': '', 'extra': 'extra'} try: validator.validate(content) - except ResponseException, exc: + except ErrorResponse, exc: self.assertEqual(exc.response.raw_content, {'field-errors': {'qwerty': ['This field is required.'], 'extra': ['This field does not exist.']}}) else: @@ -286,14 +286,14 @@ class TestModelFormValidator(TestCase): It might be okay on normal form submission, but for Web APIs we oughta get strict, as it'll help show up broken clients more easily (eg submitting content with a misnamed field)""" content = {'qwerty': 'example', 'uiop':'example', 'readonly': 'read only', 'extra': 'extra'} - self.assertRaises(ResponseException, self.validator.validate, content) + self.assertRaises(ErrorResponse, self.validator.validate, content) def test_validate_requires_fields_on_model_forms(self): """If some (otherwise valid) content includes fields that are not in the form then validation should fail. It might be okay on normal form submission, but for Web APIs we oughta get strict, as it'll help show up broken clients more easily (eg submitting content with a misnamed field)""" content = {'readonly': 'read only'} - self.assertRaises(ResponseException, self.validator.validate, content) + self.assertRaises(ErrorResponse, self.validator.validate, content) def test_validate_does_not_require_blankable_fields_on_model_forms(self): """Test standard ModelForm validation behaviour - fields with blank=True are not required.""" |
