def test_accept_invitation_form(self): form = AcceptInvitationForm() form._errors = {} form.cleaned_data = { 'first_name': 'Foo', 'last_name': 'Bar', 'password1': 'test', 'password2': 'test', 'username': '******' } form.clean() self.assertEquals(len(form._errors.keys()), 0)
def test_accept_invitation_form_duplicate_username(self): user = UserFactory() form = AcceptInvitationForm() # required fields form._errors = {} form.cleaned_data = { 'first_name': 'Foo', 'last_name': 'Bar', 'password1': 'test', 'password2': 'test', 'username': user.username } form.clean() self.assertEquals(len(form._errors.keys()), 1) self.assertTrue('username' in form._errors)
def test_accept_invitation_form_invalid_passwords(self): form = AcceptInvitationForm() # required fields form._errors = {} form.cleaned_data = { 'first_name': 'Foo', 'last_name': 'Bar', 'password1': 'a', 'password2': 'b', 'username': '******' } form.clean() self.assertEquals(len(form._errors.keys()), 2) self.assertTrue('password1' in form._errors) self.assertTrue('password2' in form._errors)