mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-07-27 08:29:59 +03:00
Resolved conflicts before merge.
This commit is contained in:
parent
2b8cba55a8
commit
79fa5c9588
|
@ -79,6 +79,11 @@ To run the tests.
|
||||||
|
|
||||||
./rest_framework/runtests/runtests.py
|
./rest_framework/runtests/runtests.py
|
||||||
|
|
||||||
|
To run the tests with code coverage.
|
||||||
|
|
||||||
|
pip install -r development.txt
|
||||||
|
./rest_framework/runtests/runcoverage.py
|
||||||
|
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
### 2.1.16
|
### 2.1.16
|
||||||
|
|
122
rest_framework/tests/settings.py
Normal file
122
rest_framework/tests/settings.py
Normal file
|
@ -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'
|
|
@ -2,7 +2,7 @@ from django.contrib.auth.models import User
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.test import Client, TestCase
|
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.authtoken.models import Token
|
||||||
from rest_framework.authentication import TokenAuthentication, BasicAuthentication, SessionAuthentication
|
from rest_framework.authentication import TokenAuthentication, BasicAuthentication, SessionAuthentication
|
||||||
from rest_framework.compat import patterns
|
from rest_framework.compat import patterns
|
||||||
|
@ -11,7 +11,6 @@ from rest_framework.views import APIView
|
||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
import sure
|
|
||||||
|
|
||||||
class MockView(APIView):
|
class MockView(APIView):
|
||||||
permission_classes = (permissions.IsAuthenticated,)
|
permission_classes = (permissions.IsAuthenticated,)
|
||||||
|
@ -32,7 +31,7 @@ urlpatterns = patterns('',
|
||||||
|
|
||||||
class BasicAuthTests(TestCase):
|
class BasicAuthTests(TestCase):
|
||||||
"""Basic authentication"""
|
"""Basic authentication"""
|
||||||
urls = 'rest_framework.tests.test_authentication'
|
urls = 'rest_framework.tests.authentication'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.csrf_client = Client(enforce_csrf_checks=True)
|
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"""
|
"""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()
|
auth = 'Basic %s' % base64.encodestring('%s:%s' % (self.username, self.password)).strip()
|
||||||
response = self.csrf_client.post('/basic/', {'example': 'example'}, HTTP_AUTHORIZATION=auth)
|
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):
|
def test_post_json_passing_basic_auth(self):
|
||||||
"""Ensure POSTing form over basic auth with correct credentials passes and does not require CSRF"""
|
"""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()
|
auth = 'Basic %s' % base64.encodestring('%s:%s' % (self.username, self.password)).strip()
|
||||||
response = self.csrf_client.post('/basic/', json.dumps({'example': 'example'}), 'application/json',
|
response = self.csrf_client.post('/basic/', json.dumps({'example': 'example'}), 'application/json',
|
||||||
HTTP_AUTHORIZATION=auth)
|
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):
|
def test_post_form_failing_basic_auth(self):
|
||||||
"""Ensure POSTing form over basic auth without correct credentials fails"""
|
"""Ensure POSTing form over basic auth without correct credentials fails"""
|
||||||
response = self.csrf_client.post('/basic/', {'example': 'example'})
|
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):
|
def test_post_json_failing_basic_auth(self):
|
||||||
"""Ensure POSTing json over basic auth without correct credentials fails"""
|
"""Ensure POSTing json over basic auth without correct credentials fails"""
|
||||||
response = self.csrf_client.post('/basic/', json.dumps({'example': 'example'}), 'application/json')
|
response = self.csrf_client.post('/basic/', json.dumps({'example': 'example'}), 'application/json')
|
||||||
response.status_code.should.equal(401)
|
self.assertEqual(response.status_code, status.HTTP_401_UNAUTHORIZED)
|
||||||
response['WWW-Authenticate'].should.equal('Basic realm="api"')
|
self.assertEqual(response['WWW-Authenticate'], 'Basic realm="api"')
|
||||||
|
|
||||||
|
|
||||||
class SessionAuthTests(TestCase):
|
class SessionAuthTests(TestCase):
|
||||||
"""User session authentication"""
|
"""User session authentication"""
|
||||||
urls = 'rest_framework.tests.test_authentication'
|
urls = 'rest_framework.tests.authentication'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.csrf_client = Client(enforce_csrf_checks=True)
|
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)
|
self.csrf_client.login(username=self.username, password=self.password)
|
||||||
response = self.csrf_client.post('/session/', {'example': 'example'})
|
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):
|
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)
|
self.non_csrf_client.login(username=self.username, password=self.password)
|
||||||
response = self.non_csrf_client.post('/session/', {'example': 'example'})
|
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):
|
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)
|
self.non_csrf_client.login(username=self.username, password=self.password)
|
||||||
response = self.non_csrf_client.put('/session/', {'example': 'example'})
|
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):
|
def test_post_form_session_auth_failing(self):
|
||||||
"""
|
"""
|
||||||
Ensure POSTing form over session authentication without logged in user fails.
|
Ensure POSTing form over session authentication without logged in user fails.
|
||||||
"""
|
"""
|
||||||
response = self.csrf_client.post('/session/', {'example': 'example'})
|
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):
|
class TokenAuthTests(TestCase):
|
||||||
"""Token authentication"""
|
"""Token authentication"""
|
||||||
urls = 'rest_framework.tests.test_authentication'
|
urls = 'rest_framework.tests.authentication'
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.csrf_client = Client(enforce_csrf_checks=True)
|
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"""
|
"""Ensure POSTing json over token auth with correct credentials passes and does not require CSRF"""
|
||||||
auth = "Token " + self.key
|
auth = "Token " + self.key
|
||||||
response = self.csrf_client.post('/token/', {'example': 'example'}, HTTP_AUTHORIZATION=auth)
|
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):
|
def test_post_json_passing_token_auth(self):
|
||||||
"""Ensure POSTing form over token auth with correct credentials passes and does not require CSRF"""
|
"""Ensure POSTing form over token auth with correct credentials passes and does not require CSRF"""
|
||||||
auth = "Token " + self.key
|
auth = "Token " + self.key
|
||||||
response = self.csrf_client.post('/token/', json.dumps({'example': 'example'}), 'application/json',
|
response = self.csrf_client.post('/token/', json.dumps({'example': 'example'}), 'application/json',
|
||||||
HTTP_AUTHORIZATION=auth)
|
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):
|
def test_post_form_failing_token_auth(self):
|
||||||
"""Ensure POSTing form over token auth without correct credentials fails"""
|
"""Ensure POSTing form over token auth without correct credentials fails"""
|
||||||
response = self.csrf_client.post('/token/', {'example': 'example'})
|
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):
|
def test_post_json_failing_token_auth(self):
|
||||||
"""Ensure POSTing json over token auth without correct credentials fails"""
|
"""Ensure POSTing json over token auth without correct credentials fails"""
|
||||||
response = self.csrf_client.post('/token/', json.dumps({'example': 'example'}), 'application/json')
|
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):
|
def test_token_has_auto_assigned_key_if_none_provided(self):
|
||||||
"""Ensure creating a token with no key will auto-assign a key"""
|
"""Ensure creating a token with no key will auto-assign a key"""
|
||||||
self.token.delete()
|
self.token.delete()
|
||||||
token = Token.objects.create(user=self.user)
|
token = Token.objects.create(user=self.user)
|
||||||
token.key.should.be.ok
|
self.assertTrue(bool(token.key))
|
||||||
|
|
||||||
def test_token_login_json(self):
|
def test_token_login_json(self):
|
||||||
"""Ensure token login view using JSON POST works."""
|
"""Ensure token login view using JSON POST works."""
|
||||||
client = Client(enforce_csrf_checks=True)
|
client = Client(enforce_csrf_checks=True)
|
||||||
response = client.post('/auth-token/',
|
response = client.post('/auth-token/',
|
||||||
json.dumps({'username': self.username, 'password': self.password}), 'application/json')
|
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)
|
self.assertEqual(json.loads(response.content)['token'], self.key)
|
||||||
|
|
||||||
def test_token_login_json_bad_creds(self):
|
def test_token_login_json_bad_creds(self):
|
||||||
|
@ -169,19 +168,19 @@ class TokenAuthTests(TestCase):
|
||||||
client = Client(enforce_csrf_checks=True)
|
client = Client(enforce_csrf_checks=True)
|
||||||
response = client.post('/auth-token/',
|
response = client.post('/auth-token/',
|
||||||
json.dumps({'username': self.username, 'password': "badpass"}), 'application/json')
|
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):
|
def test_token_login_json_missing_fields(self):
|
||||||
"""Ensure token login view using JSON POST fails if missing fields."""
|
"""Ensure token login view using JSON POST fails if missing fields."""
|
||||||
client = Client(enforce_csrf_checks=True)
|
client = Client(enforce_csrf_checks=True)
|
||||||
response = client.post('/auth-token/',
|
response = client.post('/auth-token/',
|
||||||
json.dumps({'username': self.username}), 'application/json')
|
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):
|
def test_token_login_form(self):
|
||||||
"""Ensure token login view using form POST works."""
|
"""Ensure token login view using form POST works."""
|
||||||
client = Client(enforce_csrf_checks=True)
|
client = Client(enforce_csrf_checks=True)
|
||||||
response = client.post('/auth-token/',
|
response = client.post('/auth-token/',
|
||||||
{'username': self.username, 'password': self.password})
|
{'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)
|
self.assertEqual(json.loads(response.content)['token'], self.key)
|
||||||
|
|
|
@ -56,11 +56,11 @@ class DecoratorTestCase(TestCase):
|
||||||
|
|
||||||
request = self.factory.get('/')
|
request = self.factory.get('/')
|
||||||
response = view(request)
|
response = view(request)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
request = self.factory.post('/')
|
request = self.factory.post('/')
|
||||||
response = view(request)
|
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):
|
def test_calling_put_method(self):
|
||||||
@api_view(['GET', 'PUT'])
|
@api_view(['GET', 'PUT'])
|
||||||
|
@ -69,11 +69,11 @@ class DecoratorTestCase(TestCase):
|
||||||
|
|
||||||
request = self.factory.put('/')
|
request = self.factory.put('/')
|
||||||
response = view(request)
|
response = view(request)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
request = self.factory.post('/')
|
request = self.factory.post('/')
|
||||||
response = view(request)
|
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):
|
def test_calling_patch_method(self):
|
||||||
@api_view(['GET', 'PATCH'])
|
@api_view(['GET', 'PATCH'])
|
||||||
|
@ -82,11 +82,11 @@ class DecoratorTestCase(TestCase):
|
||||||
|
|
||||||
request = self.factory.patch('/')
|
request = self.factory.patch('/')
|
||||||
response = view(request)
|
response = view(request)
|
||||||
self.assertEqual(response.status_code, 200)
|
self.assertEqual(response.status_code, status.HTTP_200_OK)
|
||||||
|
|
||||||
request = self.factory.post('/')
|
request = self.factory.post('/')
|
||||||
response = view(request)
|
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):
|
def test_renderer_classes(self):
|
||||||
@api_view(['GET'])
|
@api_view(['GET'])
|
||||||
|
|
|
@ -42,7 +42,7 @@ class SlugBasedInstanceView(InstanceView):
|
||||||
class TestRootView(TestCase):
|
class TestRootView(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""
|
"""
|
||||||
Create 3 BasicModel intances.
|
Create 3 BasicModel instances.
|
||||||
"""
|
"""
|
||||||
items = ['foo', 'bar', 'baz']
|
items = ['foo', 'bar', 'baz']
|
||||||
for item in items:
|
for item in items:
|
||||||
|
@ -343,7 +343,7 @@ class ExampleView(generics.ListCreateAPIView):
|
||||||
class TestM2MBrowseableAPI(TestCase):
|
class TestM2MBrowseableAPI(TestCase):
|
||||||
def test_m2m_in_browseable_api(self):
|
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')
|
request = factory.get('/', HTTP_ACCEPT='text/html')
|
||||||
view = ExampleView().as_view()
|
view = ExampleView().as_view()
|
||||||
|
|
|
@ -3,6 +3,7 @@ from django.http import Http404
|
||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.template import TemplateDoesNotExist, Template
|
from django.template import TemplateDoesNotExist, Template
|
||||||
import django.template.loader
|
import django.template.loader
|
||||||
|
from rest_framework import status
|
||||||
from rest_framework.compat import patterns, url
|
from rest_framework.compat import patterns, url
|
||||||
from rest_framework.decorators import api_view, renderer_classes
|
from rest_framework.decorators import api_view, renderer_classes
|
||||||
from rest_framework.renderers import TemplateHTMLRenderer
|
from rest_framework.renderers import TemplateHTMLRenderer
|
||||||
|
@ -67,13 +68,13 @@ class TemplateHTMLRendererTests(TestCase):
|
||||||
|
|
||||||
def test_not_found_html_view(self):
|
def test_not_found_html_view(self):
|
||||||
response = self.client.get('/not_found')
|
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, "404 Not Found")
|
||||||
self.assertEquals(response['Content-Type'], 'text/html')
|
self.assertEquals(response['Content-Type'], 'text/html')
|
||||||
|
|
||||||
def test_permission_denied_html_view(self):
|
def test_permission_denied_html_view(self):
|
||||||
response = self.client.get('/permission_denied')
|
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, "403 Forbidden")
|
||||||
self.assertEquals(response['Content-Type'], 'text/html')
|
self.assertEquals(response['Content-Type'], 'text/html')
|
||||||
|
|
||||||
|
@ -104,12 +105,12 @@ class TemplateHTMLRendererExceptionTests(TestCase):
|
||||||
|
|
||||||
def test_not_found_html_view_with_template(self):
|
def test_not_found_html_view_with_template(self):
|
||||||
response = self.client.get('/not_found')
|
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, "404: Not found")
|
||||||
self.assertEquals(response['Content-Type'], 'text/html')
|
self.assertEquals(response['Content-Type'], 'text/html')
|
||||||
|
|
||||||
def test_permission_denied_html_view_with_template(self):
|
def test_permission_denied_html_view_with_template(self):
|
||||||
response = self.client.get('/permission_denied')
|
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, "403: Permission denied")
|
||||||
self.assertEquals(response['Content-Type'], 'text/html')
|
self.assertEquals(response['Content-Type'], 'text/html')
|
||||||
|
|
|
@ -100,7 +100,7 @@ class TestBasicHyperlinkedView(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""
|
"""
|
||||||
Create 3 BasicModel intances.
|
Create 3 BasicModel instances.
|
||||||
"""
|
"""
|
||||||
items = ['foo', 'bar', 'baz']
|
items = ['foo', 'bar', 'baz']
|
||||||
for item in items:
|
for item in items:
|
||||||
|
@ -137,7 +137,7 @@ class TestManyToManyHyperlinkedView(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""
|
"""
|
||||||
Create 3 BasicModel intances.
|
Create 3 BasicModel instances.
|
||||||
"""
|
"""
|
||||||
items = ['foo', 'bar', 'baz']
|
items = ['foo', 'bar', 'baz']
|
||||||
anchors = []
|
anchors = []
|
||||||
|
@ -234,7 +234,7 @@ class TestOptionalRelationHyperlinkedView(TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""
|
"""
|
||||||
Create 1 OptionalRelationModel intances.
|
Create 1 OptionalRelationModel instances.
|
||||||
"""
|
"""
|
||||||
OptionalRelationModel().save()
|
OptionalRelationModel().save()
|
||||||
self.objects = OptionalRelationModel.objects
|
self.objects = OptionalRelationModel.objects
|
||||||
|
|
|
@ -24,7 +24,7 @@ class NullableForeignKeySourceSerializer(serializers.ModelSerializer):
|
||||||
model = NullableForeignKeySource
|
model = NullableForeignKeySource
|
||||||
|
|
||||||
|
|
||||||
# TODO: M2M Tests, FKTests (Non-nulable), One2One
|
# TODO: M2M Tests, FKTests (Non-nullable), One2One
|
||||||
class PKForeignKeyTests(TestCase):
|
class PKForeignKeyTests(TestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
target = ForeignKeyTarget(name='target-1')
|
target = ForeignKeyTarget(name='target-1')
|
||||||
|
|
|
@ -124,7 +124,7 @@ class RendererEndToEndTests(TestCase):
|
||||||
End-to-end testing of renderers using an RendererMixin on a generic view.
|
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):
|
def test_default_renderer_serializes_content(self):
|
||||||
"""If the Accept header is not set the default renderer should serialize the response."""
|
"""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
|
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):
|
def test_without_callback_with_json_renderer(self):
|
||||||
"""
|
"""
|
||||||
|
@ -263,7 +263,7 @@ class JSONPRendererTests(TestCase):
|
||||||
"""
|
"""
|
||||||
resp = self.client.get('/jsonp/jsonrenderer',
|
resp = self.client.get('/jsonp/jsonrenderer',
|
||||||
HTTP_ACCEPT='application/javascript')
|
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-Type'], 'application/javascript')
|
||||||
self.assertEquals(resp.content, 'callback(%s);' % _flat_repr)
|
self.assertEquals(resp.content, 'callback(%s);' % _flat_repr)
|
||||||
|
|
||||||
|
@ -273,7 +273,7 @@ class JSONPRendererTests(TestCase):
|
||||||
"""
|
"""
|
||||||
resp = self.client.get('/jsonp/nojsonrenderer',
|
resp = self.client.get('/jsonp/nojsonrenderer',
|
||||||
HTTP_ACCEPT='application/javascript')
|
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-Type'], 'application/javascript')
|
||||||
self.assertEquals(resp.content, 'callback(%s);' % _flat_repr)
|
self.assertEquals(resp.content, 'callback(%s);' % _flat_repr)
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ class JSONPRendererTests(TestCase):
|
||||||
callback_func = 'myjsonpcallback'
|
callback_func = 'myjsonpcallback'
|
||||||
resp = self.client.get('/jsonp/nojsonrenderer?callback=' + callback_func,
|
resp = self.client.get('/jsonp/nojsonrenderer?callback=' + callback_func,
|
||||||
HTTP_ACCEPT='application/javascript')
|
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-Type'], 'application/javascript')
|
||||||
self.assertEquals(resp.content, '%s(%s);' % (callback_func, _flat_repr))
|
self.assertEquals(resp.content, '%s(%s);' % (callback_func, _flat_repr))
|
||||||
|
|
||||||
|
@ -424,7 +424,7 @@ class CacheRenderTest(TestCase):
|
||||||
Tests specific to caching responses
|
Tests specific to caching responses
|
||||||
"""
|
"""
|
||||||
|
|
||||||
urls = 'rest_framework.tests.test_renderers'
|
urls = 'rest_framework.tests.renderers'
|
||||||
|
|
||||||
cache_key = 'just_a_cache_key'
|
cache_key = 'just_a_cache_key'
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ urlpatterns = patterns('',
|
||||||
|
|
||||||
class ReverseTests(TestCase):
|
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'
|
urls = 'rest_framework.tests.test_reverse'
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,184 @@ from rest_framework import status
|
||||||
|
|
||||||
|
|
||||||
class TestStatus(TestCase):
|
class TestStatus(TestCase):
|
||||||
"""Simple sanity test to check the status module"""
|
"""Simple sanity tests to check the status module"""
|
||||||
|
|
||||||
def test_status(self):
|
def test_status_HTTP_100_CONTINUE(self):
|
||||||
"""Ensure the status module is present and correct."""
|
"""Ensure that HTTP_100_CONTINUE equals 100."""
|
||||||
self.assertEquals(200, status.HTTP_200_OK)
|
self.assertEquals(status.HTTP_100_CONTINUE, 100)
|
||||||
self.assertEquals(404, status.HTTP_404_NOT_FOUND)
|
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user