Regression for #1810: Test login view renders

This commit is contained in:
Carlton Gibson 2014-09-01 10:07:05 +02:00
parent f777a73bc7
commit 1c9c5d5c32
3 changed files with 14 additions and 2 deletions

View File

@ -6,7 +6,7 @@ your API requires authentication:
urlpatterns = patterns('', urlpatterns = patterns('',
... ...
url(r'^auth', include('rest_framework.urls', namespace='rest_framework')) url(r'^auth/', include('rest_framework.urls', namespace='rest_framework'))
) )
The urls must be namespaced as 'rest_framework', and you should make sure The urls must be namespaced as 'rest_framework', and you should make sure

View File

@ -5,6 +5,7 @@ def pytest_configure():
DEBUG_PROPAGATE_EXCEPTIONS=True, DEBUG_PROPAGATE_EXCEPTIONS=True,
DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3', DATABASES={'default': {'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:'}}, 'NAME': ':memory:'}},
SITE_ID=1,
SECRET_KEY='not very secret in tests', SECRET_KEY='not very secret in tests',
USE_I18N=True, USE_I18N=True,
USE_L10N=True, USE_L10N=True,

View File

@ -57,7 +57,8 @@ urlpatterns = patterns(
authentication_classes=[OAuthAuthentication], authentication_classes=[OAuthAuthentication],
permission_classes=[permissions.TokenHasReadWriteScope] permission_classes=[permissions.TokenHasReadWriteScope]
) )
) ),
url(r'^auth/', include('rest_framework.urls', namespace='rest_framework'))
) )
@ -134,6 +135,16 @@ class SessionAuthTests(TestCase):
def tearDown(self): def tearDown(self):
self.csrf_client.logout() self.csrf_client.logout()
def test_login_view_renders_on_get(self):
"""
Ensure the login template renders for a basic GET.
cf. [#1810](https://github.com/tomchristie/django-rest-framework/pull/1810)
"""
response = self.csrf_client.get('/auth/login/')
self.assertContains(response, '<Label class="span4">Username:</label>')
def test_post_form_session_auth_failing_csrf(self): def test_post_form_session_auth_failing_csrf(self):
""" """
Ensure POSTing form over session authentication without CSRF token fails. Ensure POSTing form over session authentication without CSRF token fails.