diff --git a/README.md b/README.md index d7cc1c6d6..d4c607768 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,11 @@ To run the tests. ./rest_framework/runtests/runtests.py +To run the tests with code coverage. + + pip install -r development.txt + ./rest_framework/runtests/runcoverage.py + # Changelog ### 2.1.16 diff --git a/rest_framework/tests/settings.py b/rest_framework/tests/settings.py new file mode 100644 index 000000000..af5617a9d --- /dev/null +++ b/rest_framework/tests/settings.py @@ -0,0 +1,122 @@ +# Django settings for testproject project. + +DEBUG = True +TEMPLATE_DEBUG = DEBUG +DEBUG_PROPAGATE_EXCEPTIONS = True + +ADMINS = ( +# ('Your Name', 'your_email@domain.com'), +) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'NAME': 'sqlite.db', # Or path to database file if using sqlite3. + 'USER': '', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} + +CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', + } +} + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# On Unix systems, a value of None will cause Django to use the same +# timezone as the operating system. +# If running in a Windows environment this must be set to the same as your +# system time zone. +TIME_ZONE = 'Europe/London' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'en-uk' + +SITE_ID = 1 + +# If you set this to False, Django will make some optimizations so as not +# to load the internationalization machinery. +USE_I18N = True + +# If you set this to False, Django will not format dates, numbers and +# calendars according to the current locale +USE_L10N = True + +# Absolute filesystem path to the directory that will hold user-uploaded files. +# Example: "/home/media/media.lawrence.com/" +MEDIA_ROOT = '' + +# URL that handles the media served from MEDIA_ROOT. Make sure to use a +# trailing slash if there is a path component (optional in other cases). +# Examples: "http://media.lawrence.com", "http://example.com/media/" +MEDIA_URL = '' + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 'u@x-aj9(hoh#rb-^ymf#g2jx_hp0vj7u5#b@ag1n^seu9e!%cy' + +# List of callables that know how to import templates from various sources. +TEMPLATE_LOADERS = ( + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', + # 'django.template.loaders.eggs.Loader', + ) + +MIDDLEWARE_CLASSES = ( + 'django.middleware.common.CommonMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + ) + +ROOT_URLCONF = 'urls' + +TEMPLATE_DIRS = ( +# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". +# Always use forward slashes, even on Windows. +# Don't forget to use absolute paths, not relative paths. +) + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + # Uncomment the next line to enable the admin: + # 'django.contrib.admin', + # Uncomment the next line to enable admin documentation: + # 'django.contrib.admindocs', + 'rest_framework', + 'rest_framework.authtoken', + 'rest_framework.tests', + 'discover_runner' + ) + +TEST_RUNNER = 'discover_runner.runner.DiscoverRunner' + +STATIC_URL = '/static/' + +import django + +if django.VERSION < (1, 3): + INSTALLED_APPS += ('staticfiles',) + + +# If we're running on the Jenkins server we want to archive the coverage reports as XML. +import os + +if os.environ.get('HUDSON_URL', None): + TEST_RUNNER = 'xmlrunner.extra.djangotestrunner.XMLTestRunner' + TEST_OUTPUT_VERBOSE = True + TEST_OUTPUT_DESCRIPTIONS = True + TEST_OUTPUT_DIR = 'xmlrunner' diff --git a/rest_framework/tests/test_authentication.py b/rest_framework/tests/test_authentication.py index 5e7b1a9b8..1a1677b8e 100644 --- a/rest_framework/tests/test_authentication.py +++ b/rest_framework/tests/test_authentication.py @@ -2,7 +2,7 @@ from django.contrib.auth.models import User from django.http import HttpResponse from django.test import Client, TestCase -from rest_framework import permissions +from rest_framework import permissions, status from rest_framework.authtoken.models import Token from rest_framework.authentication import TokenAuthentication, BasicAuthentication, SessionAuthentication from rest_framework.compat import patterns @@ -11,7 +11,6 @@ from rest_framework.views import APIView import json import base64 -import sure class MockView(APIView): permission_classes = (permissions.IsAuthenticated,) @@ -32,7 +31,7 @@ urlpatterns = patterns('', class BasicAuthTests(TestCase): """Basic authentication""" - urls = 'rest_framework.tests.test_authentication' + urls = 'rest_framework.tests.authentication' def setUp(self): self.csrf_client = Client(enforce_csrf_checks=True) @@ -45,30 +44,30 @@ class BasicAuthTests(TestCase): """Ensure POSTing json over basic auth with correct credentials passes and does not require CSRF""" auth = 'Basic %s' % base64.encodestring('%s:%s' % (self.username, self.password)).strip() response = self.csrf_client.post('/basic/', {'example': 'example'}, HTTP_AUTHORIZATION=auth) - response.status_code.should.equal(200) + self.assertEqual(response.status_code, status.HTTP_200_OK) def test_post_json_passing_basic_auth(self): """Ensure POSTing form over basic auth with correct credentials passes and does not require CSRF""" auth = 'Basic %s' % base64.encodestring('%s:%s' % (self.username, self.password)).strip() response = self.csrf_client.post('/basic/', json.dumps({'example': 'example'}), 'application/json', HTTP_AUTHORIZATION=auth) - response.status_code.should.equal(200) + self.assertEqual(response.status_code, status.HTTP_200_OK) def test_post_form_failing_basic_auth(self): """Ensure POSTing form over basic auth without correct credentials fails""" response = self.csrf_client.post('/basic/', {'example': 'example'}) - response.status_code.should.equal(401) + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) def test_post_json_failing_basic_auth(self): """Ensure POSTing json over basic auth without correct credentials fails""" response = self.csrf_client.post('/basic/', json.dumps({'example': 'example'}), 'application/json') - response.status_code.should.equal(401) - response['WWW-Authenticate'].should.equal('Basic realm="api"') + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) + self.assertEqual(response['WWW-Authenticate'], 'Basic realm="api"') class SessionAuthTests(TestCase): """User session authentication""" - urls = 'rest_framework.tests.test_authentication' + urls = 'rest_framework.tests.authentication' def setUp(self): self.csrf_client = Client(enforce_csrf_checks=True) @@ -87,7 +86,7 @@ class SessionAuthTests(TestCase): """ self.csrf_client.login(username=self.username, password=self.password) response = self.csrf_client.post('/session/', {'example': 'example'}) - response.status_code.should.equal(403) + self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) def test_post_form_session_auth_passing(self): """ @@ -95,7 +94,7 @@ class SessionAuthTests(TestCase): """ self.non_csrf_client.login(username=self.username, password=self.password) response = self.non_csrf_client.post('/session/', {'example': 'example'}) - response.status_code.should.equal(200) + self.assertEqual(response.status_code, status.HTTP_200_OK) def test_put_form_session_auth_passing(self): """ @@ -103,19 +102,19 @@ class SessionAuthTests(TestCase): """ self.non_csrf_client.login(username=self.username, password=self.password) response = self.non_csrf_client.put('/session/', {'example': 'example'}) - response.status_code.should.equal(200) + self.assertEqual(response.status_code, status.HTTP_200_OK) def test_post_form_session_auth_failing(self): """ Ensure POSTing form over session authentication without logged in user fails. """ response = self.csrf_client.post('/session/', {'example': 'example'}) - response.status_code.should.equal(403) + self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN) class TokenAuthTests(TestCase): """Token authentication""" - urls = 'rest_framework.tests.test_authentication' + urls = 'rest_framework.tests.authentication' def setUp(self): self.csrf_client = Client(enforce_csrf_checks=True) @@ -131,37 +130,37 @@ class TokenAuthTests(TestCase): """Ensure POSTing json over token auth with correct credentials passes and does not require CSRF""" auth = "Token " + self.key response = self.csrf_client.post('/token/', {'example': 'example'}, HTTP_AUTHORIZATION=auth) - response.status_code.should.equal(200) + self.assertEqual(response.status_code, status.HTTP_200_OK) def test_post_json_passing_token_auth(self): """Ensure POSTing form over token auth with correct credentials passes and does not require CSRF""" auth = "Token " + self.key response = self.csrf_client.post('/token/', json.dumps({'example': 'example'}), 'application/json', HTTP_AUTHORIZATION=auth) - response.status_code.should.equal(200) + self.assertEqual(response.status_code, status.HTTP_200_OK) def test_post_form_failing_token_auth(self): """Ensure POSTing form over token auth without correct credentials fails""" response = self.csrf_client.post('/token/', {'example': 'example'}) - response.status_code.should.equal(401) + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) def test_post_json_failing_token_auth(self): """Ensure POSTing json over token auth without correct credentials fails""" response = self.csrf_client.post('/token/', json.dumps({'example': 'example'}), 'application/json') - response.status_code.should.equal(401) + self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED) def test_token_has_auto_assigned_key_if_none_provided(self): """Ensure creating a token with no key will auto-assign a key""" self.token.delete() token = Token.objects.create(user=self.user) - token.key.should.be.ok + self.assertTrue(bool(token.key)) def test_token_login_json(self): """Ensure token login view using JSON POST works.""" client = Client(enforce_csrf_checks=True) response = client.post('/auth-token/', json.dumps({'username': self.username, 'password': self.password}), 'application/json') - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(json.loads(response.content)['token'], self.key) def test_token_login_json_bad_creds(self): @@ -169,19 +168,19 @@ class TokenAuthTests(TestCase): client = Client(enforce_csrf_checks=True) response = client.post('/auth-token/', json.dumps({'username': self.username, 'password': "badpass"}), 'application/json') - self.assertEqual(response.status_code, 400) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) def test_token_login_json_missing_fields(self): """Ensure token login view using JSON POST fails if missing fields.""" client = Client(enforce_csrf_checks=True) response = client.post('/auth-token/', json.dumps({'username': self.username}), 'application/json') - self.assertEqual(response.status_code, 400) + self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST) def test_token_login_form(self): """Ensure token login view using form POST works.""" client = Client(enforce_csrf_checks=True) response = client.post('/auth-token/', {'username': self.username, 'password': self.password}) - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, status.HTTP_200_OK) self.assertEqual(json.loads(response.content)['token'], self.key) diff --git a/rest_framework/tests/test_decorators.py b/rest_framework/tests/test_decorators.py index 996d241ec..9ccd740b2 100644 --- a/rest_framework/tests/test_decorators.py +++ b/rest_framework/tests/test_decorators.py @@ -56,11 +56,11 @@ class DecoratorTestCase(TestCase): request = self.factory.get('/') response = view(request) - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, status.HTTP_200_OK) request = self.factory.post('/') response = view(request) - self.assertEqual(response.status_code, 405) + self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) def test_calling_put_method(self): @api_view(['GET', 'PUT']) @@ -69,11 +69,11 @@ class DecoratorTestCase(TestCase): request = self.factory.put('/') response = view(request) - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, status.HTTP_200_OK) request = self.factory.post('/') response = view(request) - self.assertEqual(response.status_code, 405) + self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) def test_calling_patch_method(self): @api_view(['GET', 'PATCH']) @@ -82,11 +82,11 @@ class DecoratorTestCase(TestCase): request = self.factory.patch('/') response = view(request) - self.assertEqual(response.status_code, 200) + self.assertEqual(response.status_code, status.HTTP_200_OK) request = self.factory.post('/') response = view(request) - self.assertEqual(response.status_code, 405) + self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED) def test_renderer_classes(self): @api_view(['GET']) diff --git a/rest_framework/tests/test_generics.py b/rest_framework/tests/test_generics.py index 637b6e297..1ee0ed431 100644 --- a/rest_framework/tests/test_generics.py +++ b/rest_framework/tests/test_generics.py @@ -42,7 +42,7 @@ class SlugBasedInstanceView(InstanceView): class TestRootView(TestCase): def setUp(self): """ - Create 3 BasicModel intances. + Create 3 BasicModel instances. """ items = ['foo', 'bar', 'baz'] for item in items: @@ -343,7 +343,7 @@ class ExampleView(generics.ListCreateAPIView): class TestM2MBrowseableAPI(TestCase): def test_m2m_in_browseable_api(self): """ - Test for particularly ugly reression with m2m in browseable API + Test for particularly ugly regression with m2m in browseable API """ request = factory.get('/', HTTP_ACCEPT='text/html') view = ExampleView().as_view() diff --git a/rest_framework/tests/test_htmlrenderer.py b/rest_framework/tests/test_htmlrenderer.py index 7e8256722..bd9055131 100644 --- a/rest_framework/tests/test_htmlrenderer.py +++ b/rest_framework/tests/test_htmlrenderer.py @@ -3,6 +3,7 @@ from django.http import Http404 from django.test import TestCase from django.template import TemplateDoesNotExist, Template import django.template.loader +from rest_framework import status from rest_framework.compat import patterns, url from rest_framework.decorators import api_view, renderer_classes from rest_framework.renderers import TemplateHTMLRenderer @@ -67,13 +68,13 @@ class TemplateHTMLRendererTests(TestCase): def test_not_found_html_view(self): response = self.client.get('/not_found') - self.assertEquals(response.status_code, 404) + self.assertEquals(response.status_code, status.HTTP_404_NOT_FOUND) self.assertEquals(response.content, "404 Not Found") self.assertEquals(response['Content-Type'], 'text/html') def test_permission_denied_html_view(self): response = self.client.get('/permission_denied') - self.assertEquals(response.status_code, 403) + self.assertEquals(response.status_code, status.HTTP_403_FORBIDDEN) self.assertEquals(response.content, "403 Forbidden") self.assertEquals(response['Content-Type'], 'text/html') @@ -104,12 +105,12 @@ class TemplateHTMLRendererExceptionTests(TestCase): def test_not_found_html_view_with_template(self): response = self.client.get('/not_found') - self.assertEquals(response.status_code, 404) + self.assertEquals(response.status_code, status.HTTP_404_NOT_FOUND) self.assertEquals(response.content, "404: Not found") self.assertEquals(response['Content-Type'], 'text/html') def test_permission_denied_html_view_with_template(self): response = self.client.get('/permission_denied') - self.assertEquals(response.status_code, 403) + self.assertEquals(response.status_code, status.HTTP_403_FORBIDDEN) self.assertEquals(response.content, "403: Permission denied") self.assertEquals(response['Content-Type'], 'text/html') diff --git a/rest_framework/tests/test_hyperlinkedserializers.py b/rest_framework/tests/test_hyperlinkedserializers.py index d77580c4f..a6642ade8 100644 --- a/rest_framework/tests/test_hyperlinkedserializers.py +++ b/rest_framework/tests/test_hyperlinkedserializers.py @@ -100,7 +100,7 @@ class TestBasicHyperlinkedView(TestCase): def setUp(self): """ - Create 3 BasicModel intances. + Create 3 BasicModel instances. """ items = ['foo', 'bar', 'baz'] for item in items: @@ -137,7 +137,7 @@ class TestManyToManyHyperlinkedView(TestCase): def setUp(self): """ - Create 3 BasicModel intances. + Create 3 BasicModel instances. """ items = ['foo', 'bar', 'baz'] anchors = [] @@ -234,7 +234,7 @@ class TestOptionalRelationHyperlinkedView(TestCase): def setUp(self): """ - Create 1 OptionalRelationModel intances. + Create 1 OptionalRelationModel instances. """ OptionalRelationModel().save() self.objects = OptionalRelationModel.objects diff --git a/rest_framework/tests/test_relations_slug.py b/rest_framework/tests/test_relations_slug.py index 37ccc75e7..7ea95fe32 100644 --- a/rest_framework/tests/test_relations_slug.py +++ b/rest_framework/tests/test_relations_slug.py @@ -24,7 +24,7 @@ class NullableForeignKeySourceSerializer(serializers.ModelSerializer): model = NullableForeignKeySource -# TODO: M2M Tests, FKTests (Non-nulable), One2One +# TODO: M2M Tests, FKTests (Non-nullable), One2One class PKForeignKeyTests(TestCase): def setUp(self): target = ForeignKeyTarget(name='target-1') diff --git a/rest_framework/tests/test_renderers.py b/rest_framework/tests/test_renderers.py index 5085d1567..97e27a2ba 100644 --- a/rest_framework/tests/test_renderers.py +++ b/rest_framework/tests/test_renderers.py @@ -124,7 +124,7 @@ class RendererEndToEndTests(TestCase): End-to-end testing of renderers using an RendererMixin on a generic view. """ - urls = 'rest_framework.tests.test_renderers' + urls = 'rest_framework.tests.renderers' def test_default_renderer_serializes_content(self): """If the Accept header is not set the default renderer should serialize the response.""" @@ -255,7 +255,7 @@ class JSONPRendererTests(TestCase): Tests specific to the JSONP Renderer """ - urls = 'rest_framework.tests.test_renderers' + urls = 'rest_framework.tests.renderers' def test_without_callback_with_json_renderer(self): """ @@ -263,7 +263,7 @@ class JSONPRendererTests(TestCase): """ resp = self.client.get('/jsonp/jsonrenderer', HTTP_ACCEPT='application/javascript') - self.assertEquals(resp.status_code, 200) + self.assertEquals(resp.status_code, status.HTTP_200_OK) self.assertEquals(resp['Content-Type'], 'application/javascript') self.assertEquals(resp.content, 'callback(%s);' % _flat_repr) @@ -273,7 +273,7 @@ class JSONPRendererTests(TestCase): """ resp = self.client.get('/jsonp/nojsonrenderer', HTTP_ACCEPT='application/javascript') - self.assertEquals(resp.status_code, 200) + self.assertEquals(resp.status_code, status.HTTP_200_OK) self.assertEquals(resp['Content-Type'], 'application/javascript') self.assertEquals(resp.content, 'callback(%s);' % _flat_repr) @@ -284,7 +284,7 @@ class JSONPRendererTests(TestCase): callback_func = 'myjsonpcallback' resp = self.client.get('/jsonp/nojsonrenderer?callback=' + callback_func, HTTP_ACCEPT='application/javascript') - self.assertEquals(resp.status_code, 200) + self.assertEquals(resp.status_code, status.HTTP_200_OK) self.assertEquals(resp['Content-Type'], 'application/javascript') self.assertEquals(resp.content, '%s(%s);' % (callback_func, _flat_repr)) @@ -424,7 +424,7 @@ class CacheRenderTest(TestCase): Tests specific to caching responses """ - urls = 'rest_framework.tests.test_renderers' + urls = 'rest_framework.tests.renderers' cache_key = 'just_a_cache_key' diff --git a/rest_framework/tests/test_reverse.py b/rest_framework/tests/test_reverse.py index d0ff0d677..506b03b0a 100644 --- a/rest_framework/tests/test_reverse.py +++ b/rest_framework/tests/test_reverse.py @@ -16,7 +16,7 @@ urlpatterns = patterns('', class ReverseTests(TestCase): """ - Tests for fully qualifed URLs when using `reverse`. + Tests for fully qualified URLs when using `reverse`. """ urls = 'rest_framework.tests.test_reverse' diff --git a/rest_framework/tests/test_status.py b/rest_framework/tests/test_status.py index 30df5cef3..e8d44447d 100644 --- a/rest_framework/tests/test_status.py +++ b/rest_framework/tests/test_status.py @@ -4,9 +4,184 @@ from rest_framework import status class TestStatus(TestCase): - """Simple sanity test to check the status module""" + """Simple sanity tests to check the status module""" - def test_status(self): - """Ensure the status module is present and correct.""" - self.assertEquals(200, status.HTTP_200_OK) - self.assertEquals(404, status.HTTP_404_NOT_FOUND) + def test_status_HTTP_100_CONTINUE(self): + """Ensure that HTTP_100_CONTINUE equals 100.""" + self.assertEquals(status.HTTP_100_CONTINUE, 100) + + def test_status_HTTP_101_SWITCHING_PROTOCOLS(self): + """Ensure that HTTP_101_SWITCHING_PROTOCOLS equals 101.""" + self.assertEquals(status.HTTP_101_SWITCHING_PROTOCOLS, 101) + + def test_status_HTTP_200_OK(self): + """Ensure that HTTP_200_OK equals 200.""" + self.assertEquals(status.HTTP_200_OK, 200) + + def test_status_HTTP_201_CREATED(self): + """Ensure that HTTP_201_CREATED equals 201.""" + self.assertEquals(status.HTTP_201_CREATED, 201) + + def test_status_HTTP_202_ACCEPTED(self): + """Ensure that HTTP_202_ACCEPTED equals 202.""" + self.assertEquals(status.HTTP_202_ACCEPTED, 202) + + def test_status_HTTP_203_NON_AUTHORITATIVE_INFORMATION(self): + """Ensure that HTTP_203_NON_AUTHORITATIVE_INFORMATION equals 203.""" + self.assertEquals(status.HTTP_203_NON_AUTHORITATIVE_INFORMATION, 203) + + def test_status_HTTP_204_NO_CONTENT(self): + """Ensure that HTTP_204_NO_CONTENT equals 204.""" + self.assertEquals(status.HTTP_204_NO_CONTENT, 204) + + def test_status_HTTP_205_RESET_CONTENT(self): + """Ensure that HTTP_205_RESET_CONTENT equals 205.""" + self.assertEquals(status.HTTP_205_RESET_CONTENT, 205) + + def test_status_HTTP_206_PARTIAL_CONTENT(self): + """Ensure that HTTP_206_PARTIAL_CONTENT equals 206.""" + self.assertEquals(status.HTTP_206_PARTIAL_CONTENT, 206) + + def test_status_HTTP_300_MULTIPLE_CHOICES(self): + """Ensure that HTTP_300_MULTIPLE_CHOICES equals 300.""" + self.assertEquals(status.HTTP_300_MULTIPLE_CHOICES, 300) + + def test_status_HTTP_301_MOVED_PERMANENTLY(self): + """Ensure that HTTP_301_MOVED_PERMANENTLY equals 301.""" + self.assertEquals(status.HTTP_301_MOVED_PERMANENTLY, 301) + + def test_status_HTTP_302_FOUND(self): + """Ensure that HTTP_302_FOUND equals 302.""" + self.assertEquals(status.HTTP_302_FOUND, 302) + + def test_status_HTTP_303_SEE_OTHER(self): + """Ensure that HTTP_303_SEE_OTHER equals 303.""" + self.assertEquals(status.HTTP_303_SEE_OTHER, 303) + + def test_status_HTTP_304_NOT_MODIFIED(self): + """Ensure that HTTP_304_NOT_MODIFIED equals 304.""" + self.assertEquals(status.HTTP_304_NOT_MODIFIED, 304) + + def test_status_HTTP_305_USE_PROXY(self): + """Ensure that HTTP_305_USE_PROXY equals 305.""" + self.assertEquals(status.HTTP_305_USE_PROXY, 305) + + def test_status_HTTP_306_RESERVED(self): + """Ensure that HTTP_306_RESERVED equals 306.""" + self.assertEquals(status.HTTP_306_RESERVED, 306) + + def test_status_HTTP_307_TEMPORARY_REDIRECT(self): + """Ensure that HTTP_307_TEMPORARY_REDIRECT equals 307.""" + self.assertEquals(status.HTTP_307_TEMPORARY_REDIRECT, 307) + + def test_status_HTTP_400_BAD_REQUEST(self): + """Ensure that HTTP_400_BAD_REQUEST equals 400.""" + self.assertEquals(status.HTTP_400_BAD_REQUEST, 400) + + def test_status_HTTP_401_UNAUTHORIZED(self): + """Ensure that HTTP_401_UNAUTHORIZED equals 401.""" + self.assertEquals(status.HTTP_401_UNAUTHORIZED, 401) + + def test_status_HTTP_402_PAYMENT_REQUIRED(self): + """Ensure that HTTP_402_PAYMENT_REQUIRED equals 402.""" + self.assertEquals(status.HTTP_402_PAYMENT_REQUIRED, 402) + + def test_status_HTTP_403_FORBIDDEN(self): + """Ensure that HTTP_403_FORBIDDEN equals 403.""" + self.assertEquals(status.HTTP_403_FORBIDDEN, 403) + + def test_status_HTTP_404_NOT_FOUND(self): + """Ensure that HTTP_404_NOT_FOUND equals 404.""" + self.assertEquals(status.HTTP_404_NOT_FOUND, 404) + + def test_status_HTTP_405_METHOD_NOT_ALLOWED(self): + """Ensure that HTTP_405_METHOD_NOT_ALLOWED equals 405.""" + self.assertEquals(status.HTTP_405_METHOD_NOT_ALLOWED, 405) + + def test_status_HTTP_406_NOT_ACCEPTABLE(self): + """Ensure that HTTP_406_NOT_ACCEPTABLE equals 406.""" + self.assertEquals(status.HTTP_406_NOT_ACCEPTABLE, 406) + + def test_status_HTTP_407_PROXY_AUTHENTICATION_REQUIRED(self): + """Ensure that HTTP_407_PROXY_AUTHENTICATION_REQUIRED equals 407.""" + self.assertEquals(status.HTTP_407_PROXY_AUTHENTICATION_REQUIRED, 407) + + def test_status_HTTP_408_REQUEST_TIMEOUT(self): + """Ensure that HTTP_408_REQUEST_TIMEOUT equals 408.""" + self.assertEquals(status.HTTP_408_REQUEST_TIMEOUT, 408) + + def test_status_HTTP_409_CONFLICT(self): + """Ensure that HTTP_409_CONFLICT equals 409.""" + self.assertEquals(status.HTTP_409_CONFLICT, 409) + + def test_status_HTTP_410_GONE(self): + """Ensure that HTTP_410_GONE equals 410.""" + self.assertEquals(status.HTTP_410_GONE, 410) + + def test_status_HTTP_411_LENGTH_REQUIRED(self): + """Ensure that HTTP_411_LENGTH_REQUIRED equals 411.""" + self.assertEquals(status.HTTP_411_LENGTH_REQUIRED, 411) + + def test_status_HTTP_412_PRECONDITION_FAILED(self): + """Ensure that HTTP_412_PRECONDITION_FAILED equals 412.""" + self.assertEquals(status.HTTP_412_PRECONDITION_FAILED, 412) + + def test_status_HTTP_413_REQUEST_ENTITY_TOO_LARGE(self): + """Ensure that HTTP_413_REQUEST_ENTITY_TOO_LARGE equals 413.""" + self.assertEquals(status.HTTP_413_REQUEST_ENTITY_TOO_LARGE, 413) + + def test_status_HTTP_414_REQUEST_URI_TOO_LONG(self): + """Ensure that HTTP_414_REQUEST_URI_TOO_LONG equals 414.""" + self.assertEquals(status.HTTP_414_REQUEST_URI_TOO_LONG, 414) + + def test_status_HTTP_415_UNSUPPORTED_MEDIA_TYPE(self): + """Ensure that HTTP_415_UNSUPPORTED_MEDIA_TYPE equals 415.""" + self.assertEquals(status.HTTP_415_UNSUPPORTED_MEDIA_TYPE, 415) + + def test_status_HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE(self): + """Ensure that HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE equals 416.""" + self.assertEquals(status.HTTP_416_REQUESTED_RANGE_NOT_SATISFIABLE, 416) + + def test_status_HTTP_417_EXPECTATION_FAILED(self): + """Ensure that HTTP_417_EXPECTATION_FAILED equals 417.""" + self.assertEquals(status.HTTP_417_EXPECTATION_FAILED, 417) + + def test_status_HTTP_428_PRECONDITION_REQUIRED(self): + """Ensure that HTTP_428_PRECONDITION_REQUIRED equals 428.""" + self.assertEquals(status.HTTP_428_PRECONDITION_REQUIRED, 428) + + def test_status_HTTP_429_TOO_MANY_REQUESTS(self): + """Ensure that HTTP_429_TOO_MANY_REQUESTS equals 428.""" + self.assertEquals(status.HTTP_429_TOO_MANY_REQUESTS, 429) + + def test_status_HTTP_431_REQUEST_HEADER_FIELDS_TOO_LARGE(self): + """Ensure that HTTP_431_REQUEST_HEADER_FIELDS_TOO_LARGE equals 431.""" + self.assertEquals(status.HTTP_431_REQUEST_HEADER_FIELDS_TOO_LARGE, 431) + + def test_status_HTTP_500_INTERNAL_SERVER_ERROR(self): + """Ensure that HTTP_500_INTERNAL_SERVER_ERROR equals 500.""" + self.assertEquals(status.HTTP_500_INTERNAL_SERVER_ERROR, 500) + + def HTTP_501_NOT_IMPLEMENTED(self): + """Ensure that HTTP_501_NOT_IMPLEMENTED equals 501.""" + self.assertEquals(status.HTTP_501_NOT_IMPLEMENTED, 501) + + def test_status_HTTP_502_BAD_GATEWAY(self): + """Ensure that HTTP_502_BAD_GATEWAY equals 502.""" + self.assertEquals(status.HTTP_502_BAD_GATEWAY, 502) + + def test_status_HTTP_503_SERVICE_UNAVAILABLE(self): + """Ensure that HTTP_503_SERVICE_UNAVAILABLE equals 503.""" + self.assertEquals(status.HTTP_503_SERVICE_UNAVAILABLE, 503) + + def test_status_HTTP_504_GATEWAY_TIMEOUT(self): + """Ensure that HTTP_504_GATEWAY_TIMEOUT equals 504.""" + self.assertEquals(status.HTTP_504_GATEWAY_TIMEOUT, 504) + + def test_status_HTTP_505_HTTP_VERSION_NOT_SUPPORTED(self): + """Ensure that HTTP_505_HTTP_VERSION_NOT_SUPPORTED equals 505.""" + self.assertEquals(status.HTTP_505_HTTP_VERSION_NOT_SUPPORTED, 505) + + def test_status_HTTP_511_NETWORK_AUTHENTICATION_REQUIRED(self): + """Ensure that HTTP_511_NETWORK_AUTHENTICATION_REQUIRED equals 511.""" + self.assertEquals(status.HTTP_511_NETWORK_AUTHENTICATION_REQUIRED, 511)