def test_username_is_required(self): """ test that form is not valid if user is not given """ password = '******' email = '*****@*****.**' form_data = {'password': password, 'email': email} form = ForgotPassword(data=form_data) self.assertFalse(form.is_valid())
def test_email_is_required(self): """ test that form is not valid if email is not given """ password = '******' username = '******' form_data = {'username': username, 'password': password} form = ForgotPassword(data=form_data) self.assertFalse(form.is_valid())
def test_password_is_required(self): """ test that form is not valid if password is not given """ username = '******' email = '*****@*****.**' form_data = {'username': username, 'email': email} form = ForgotPassword(data=form_data) self.assertFalse(form.is_valid())
def test_is_accepted(self): """ test that form is accepted with correct data format """ username = '******' password = '******' email = '*****@*****.**' form_data = { 'username': username, 'password': password, 'email': email } form = ForgotPassword(data=form_data) self.assertTrue(form.is_valid())
def test_username_over_100_char(self): """ test that form is not accepted with username greater than 100 chars """ username = '******' * 101 password = '******' email = '*****@*****.**' form_data = { 'username': username, 'password': password, 'email': email } form = ForgotPassword(data=form_data) self.assertFalse(form.is_valid()) self.assertEqual( form.errors, { 'username': ['Ensure this value has at most 100 characters (it has 101).'], })
def test_email_field_label(self): """ test label shown by form for email is correct """ form = ForgotPassword() self.assertTrue(form.fields['email'].label == 'Email')
def test_password_field_label(self): """ test label shown by form for password is correct """ form = ForgotPassword() self.assertTrue(form.fields['password'].label == 'New Password')
def test_username_field_label(self): """ test label shown by form for username is correct """ form = ForgotPassword() self.assertTrue(form.fields['username'].label == 'Username')