def test_non_staff_login(self): """ The form should raise an error because our user isn't staff """ form = EmailAdminAuthenticationForm( data={'email': self.email, 'password': self.password} ) self.assertFalse(form.is_valid())
def test_staff_login(self): """ Promote our user to staff then try again - the form should validate. """ self.user.is_staff = True self.user.save() form = EmailAdminAuthenticationForm( data={'email': self.email, 'password': self.password} ) self.assertTrue(form.is_valid())