'Make sure only staff members can log in.
Successful posts to the login page will redirect to the orignal url.
Unsuccessfull attempts will continue to render the login page with
a 200 status code.'

def testLogin(self):

    request = self.client.get('/test_admin/admin/')
    self.assertEqual(request.status_code, 200)
    login = self.client.post('/test_admin/admin/', self.super_login)
    self.assertRedirects(login, '/test_admin/admin/')
    self.assertFalse(login.context)
    self.client.get('/test_admin/admin/logout/')
    request = self.client.get('/test_admin/admin/')
    self.assertEqual(request.status_code, 200)
    login = self.client.post('/test_admin/admin/', self.super_email_login)
    self.assertContains(login, 'Your    e-mail    address    is    not    your    username')
    login = self.client.post('/test_admin/admin/', self.super_email_bad_login)
    self.assertContains(login, 'Please    enter    a    correct    username    and    password.')
    new_user = User(username='jondoe', password='secret', email='super@example.com')
    new_user.save()
    login = self.client.post('/test_admin/admin/', self.super_email_login)
    self.assertContains(login, 'Please    enter    a    correct    username    and    password.')
    request = self.client.get('/test_admin/admin/')
    self.assertEqual(request.status_code, 200)
    login = self.client.post('/test_admin/admin/', self.adduser_login)
    self.assertRedirects(login, '/test_admin/admin/')
    self.assertFalse(login.context)
    self.client.get('/test_admin/admin/logout/')
    request = self.client.get('/test_admin/admin/')
    self.assertEqual(request.status_code, 200)
    login = self.client.post('/test_admin/admin/', self.changeuser_login)
    self.assertRedirects(login, '/test_admin/admin/')
    self.assertFalse(login.context)
    self.client.get('/test_admin/admin/logout/')
    request = self.client.get('/test_admin/admin/')
    self.assertEqual(request.status_code, 200)
    login = self.client.post('/test_admin/admin/', self.deleteuser_login)
    self.assertRedirects(login, '/test_admin/admin/')
    self.assertFalse(login.context)
    self.client.get('/test_admin/admin/logout/')
    request = self.client.get('/test_admin/admin/')
    self.assertEqual(request.status_code, 200)
    login = self.client.post('/test_admin/admin/', self.joepublic_login)
    self.assertEqual(login.status_code, 200)
    self.assertContains(login, 'Please    enter    a    correct    username    and    password.')
    request = self.client.get('/test_admin/admin/')
    self.assertEqual(request.status_code, 200)
    login = self.client.post('/test_admin/admin/', self.no_username_login)
    self.assertEqual(login.status_code, 200)
    form = login.context[0].get('form')
    self.assertEqual(form.errors['username'][0], 'This    field    is    required.')
