Skip to content
This repository has been archived by the owner on Feb 18, 2019. It is now read-only.

Commit

Permalink
Auth unit tests now use urls= and self.client mechanisms
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Willison committed May 25, 2009
1 parent c62a11e commit 35bcb4c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
8 changes: 8 additions & 0 deletions django_openid/tests/auth_test_urls.py
@@ -0,0 +1,8 @@
from django.conf.urls.defaults import *
from django.http import HttpResponse
from django_openid.registration import RegistrationConsumer

urlpatterns = patterns('',
(r'^$', lambda r: HttpResponse('Index')),
(r'^openid/(.*)', RegistrationConsumer()),
)
18 changes: 9 additions & 9 deletions django_openid/tests/auth_tests.py
Expand Up @@ -3,8 +3,9 @@
from django.http import Http404
from django_openid.registration import RegistrationConsumer
from django_openid import signed
from django.contrib.auth.models import User

from django.contrib.auth.models import User
from django.utils.decorators import decorator_from_middleware
from request_factory import RequestFactory
from openid_mocks import *

Expand All @@ -13,6 +14,7 @@
rf = RequestFactory()

class AuthTest(TestCase):
urls = 'django_openid.tests.auth_test_urls'

def setUp(self):
# Create user accounts associated with OpenIDs
Expand All @@ -31,17 +33,15 @@ def tearDown(self):
))]

def testLoginWithPassword(self):
client = Client()
response = client.post('/openid/login/', {
response = self.client.post('/openid/login/', {
'username': 'no-openids',
'password': 'incorrect-password',
})
# Should get the login page again
self.assert_('login' in response.template_name)

response = client.post('/openid/login/', {
self.assertEqual(
response.template_name, 'django_openid/login_plus_password.html'
)
response = self.client.post('/openid/login/', {
'username': 'no-openids',
'password': 'password',
})
# Should be a redirect
self.assert_(response.has_header('Location'))
self.assertRedirects(response, '/')

0 comments on commit 35bcb4c

Please sign in to comment.