Permalink
Browse files

Made the monkey patched django test client more like the real test cl…

…ient. i.e. it returns True for successful login now. All tests should verify this.
  • Loading branch information...
1 parent ca6b167 commit 55d5abbe017b29cb3e76bc2420b4fe21c03156b0 @kumar303 kumar303 committed Nov 1, 2010
View
@@ -187,7 +187,7 @@ def test_auth_middleware(self):
response = client.get('/auth/hello')
self.assertEqual(200, response.status_code)
# Log in as a test user.
- client.login(email='test@test.com')
+ assert client.login(email='test@test.com')
# Logged in, active users should be able to reach '/'.
response = client.get('/')
self.assertEqual(200, response.status_code)
@@ -420,7 +420,7 @@ class UserViewsTestCase(FormTestCaseHelper, DjangoTestCase):
def setUp(self):
for u in User.all():
u.delete()
- self.client.login(email="test@test.com", roles=[roles.VOLUNTEER_COORDINATOR])
+ assert self.client.login(email="test@test.com", roles=[roles.VOLUNTEER_COORDINATOR])
def test_email_is_case_insensitive_on_creation(self):
resp = self.client.post('/auth/add_user/', {
@@ -29,7 +29,7 @@
class TestJSONHandler(DjangoTestCase):
def setUp(self):
- self.client.login(email="test@test.com", roles=[roles.DJ])
+ assert self.client.login(email="test@test.com", roles=[roles.DJ])
def test_json_error(self):
response = self.client.get('/common/_make_json_error')
@@ -46,6 +46,8 @@ def chirp_Client_login(self, **credentials):
if user:
token = auth._create_security_token(user)
self.cookies[auth._CHIRP_SECURITY_TOKEN_COOKIE] = token
+ if token:
+ return True
def chirp_Client_logout(self):
View
@@ -29,7 +29,7 @@ class ViewsTestCase(TestCase):
def setUp(self):
# Log in.
- self.client.login(email="test@test.com")
+ assert self.client.login(email="test@test.com")
# Create an image entry.
self.img = models.DjDbImage(image_data="test data",
@@ -58,7 +58,7 @@ def test_image_serving(self):
class AutocompleteViewsTestCase(TestCase):
def setUp(self):
- self.client.login(email="test@test.com", roles=[roles.DJ])
+ assert self.client.login(email="test@test.com", roles=[roles.DJ])
idx = search.Indexer()
@@ -174,7 +174,7 @@ class UpdateAlbumViewsTestCase(TestCase):
def setUp(self):
# Log in.
self.client = Client()
- self.client.login(email='test@test.com', roles=[roles.DJ])
+ assert self.client.login(email='test@test.com', roles=[roles.DJ])
# Get user.
self.user = models.User.all().filter('email =', 'test@test.com')[0]
@@ -221,7 +221,7 @@ class ReviewViewsTestCase(TestCase):
def setUp(self):
# Log in.
self.client = Client()
- self.client.login(email='test@test.com', roles=[roles.DJ])
+ assert self.client.login(email='test@test.com', roles=[roles.DJ])
# Get user.
self.user = models.User.all().filter('email =', 'test@test.com')[0]
@@ -425,7 +425,7 @@ class CommentViewsTestCase(TestCase):
def setUp(self):
# Log in.
self.client = Client()
- self.client.login(email='test@test.com', roles=[roles.DJ])
+ assert self.client.login(email='test@test.com', roles=[roles.DJ])
# Get user.
self.user = models.User.all().filter('email =', 'test@test.com')[0]
@@ -560,7 +560,7 @@ class AlbumCategoryViewsTestCase(TestCase):
def setUp(self):
# Log in.
self.client = Client()
- self.client.login(email='test@test.com', roles=[roles.DJ])
+ assert self.client.login(email='test@test.com', roles=[roles.DJ])
# Get user.
self.user = models.User.all().filter('email =', 'test@test.com')[0]
@@ -619,7 +619,7 @@ class TrackViewsTestCase(TestCase):
def setUp(self):
# Log in.
self.client = Client()
- self.client.login(email='test@test.com', roles=[roles.DJ])
+ assert self.client.login(email='test@test.com', roles=[roles.DJ])
# Get user.
self.user = models.User.all().filter('email =', 'test@test.com')[0]
@@ -706,7 +706,7 @@ class CrateViewsTestCase(TestCase):
def setUp(self):
# Log in.
self.client = Client()
- self.client.login(email='test@test.com', roles=[roles.DJ])
+ assert self.client.login(email='test@test.com', roles=[roles.DJ])
# Get user.
self.user = models.User.all().filter('email =', 'test@test.com')[0]
View
@@ -49,7 +49,7 @@ class TestErrorHandler(DjangoTestCase):
def setUp(self):
self.orig_middleware = [m for m in settings.MIDDLEWARE_CLASSES]
self.client.handler = ClientHandlerWithErroHandler() # custom handler with middleware applied
- self.client.login(email="test@test.com", roles=[roles.DJ])
+ assert self.client.login(email="test@test.com", roles=[roles.DJ])
def tearDown(self):
settings.MIDDLEWARE_CLASSES = self.orig_middleware
View
@@ -60,7 +60,7 @@ def assert_json_success(self, json_response):
class TestJobs(JobsTestCase):
def setUp(self):
- self.client.login(email="test@test.com", roles=[roles.DJ])
+ assert self.client.login(email="test@test.com", roles=[roles.DJ])
@job_worker('counter')
def counter(data, request_params):
@@ -188,7 +188,7 @@ def test_job_reaper_kills_old_jobs(self):
class TestJobsWithParams(JobsTestCase):
def setUp(self):
- self.client.login(email="test@test.com", roles=[roles.DJ])
+ assert self.client.login(email="test@test.com", roles=[roles.DJ])
@job_worker('report')
def report_worker(data, request_params):
@@ -36,7 +36,7 @@ class TestPlaylistReport(PlaylistViewsTest):
def setUp(self):
super(TestPlaylistReport, self).setUp()
- self.client.login(email="test@test.com", roles=[roles.DJ, roles.MUSIC_DIRECTOR])
+ assert self.client.login(email="test@test.com", roles=[roles.DJ, roles.MUSIC_DIRECTOR])
def test_report_landing_page(self):
# sanity check:
@@ -96,7 +96,7 @@ def create_stevie_wonder_album_data():
class PlaylistViewsTest(FormTestCaseHelper, TestCase):
def setUp(self):
- self.client.login(email="test@test.com", roles=[roles.DJ])
+ assert self.client.login(email="test@test.com", roles=[roles.DJ])
setup_dbconfig()
def tearDown(self):
View
@@ -46,7 +46,7 @@ def clear_data():
class TestTrafficLogViews(DjangoTestCase):
def setUp(self):
- self.client.login(email="test@test.com", roles=[roles.DJ])
+ assert self.client.login(email="test@test.com", roles=[roles.DJ])
def tearDown(self):
clear_data()
@@ -89,7 +89,7 @@ def test_landing_page_shows_spots(self):
class TestTrafficLogAdminViews(FormTestCaseHelper, DjangoTestCase):
def setUp(self):
- self.client.login(email="test@test.com", roles=[roles.TRAFFIC_LOG_ADMIN, roles.DJ])
+ assert self.client.login(email="test@test.com", roles=[roles.TRAFFIC_LOG_ADMIN, roles.DJ])
def tearDown(self):
clear_data()
@@ -522,7 +522,7 @@ def test_spot_copy(self):
class TestTrafficLogDJViews(FormTestCaseHelper, DjangoTestCase):
def setUp(self):
- self.client.login(email="dj-test@test.com", roles=[roles.DJ])
+ assert self.client.login(email="dj-test@test.com", roles=[roles.DJ])
def tearDown(self):
clear_data()
@@ -649,7 +649,7 @@ def test_spot_constraint_delete(self):
class TestTrafficLogReport(FormTestCaseHelper, DjangoTestCase):
def setUp(self):
- self.client.login(email="test@test.com", roles=[roles.TRAFFIC_LOG_ADMIN])
+ assert self.client.login(email="test@test.com", roles=[roles.TRAFFIC_LOG_ADMIN])
author = User(email='test')
author.save()

0 comments on commit 55d5abb

Please sign in to comment.