def test_create_user_duplicate_username_fails(self): #fails user = { 'username': '******', 'first_name': 'bob', 'last_name': 'bob', 'email': '*****@*****.**', 'password1': '1234', 'password2': '1234' } form = UserRegistrationForm(user) form.save() user2 = { 'username': '******', 'first_name': 'bob', 'last_name': 'bob', 'email': '*****@*****.**', 'password1': '1234', 'password2': '1234' } form2 = UserRegistrationForm(user2) with self.assertRaises(ValueError): form2.save()
def test_create_user_all_fields_required(self): #fails # TODO is this testing the right thing? u = { 'username': '', 'first_name': '', 'last_name': '', 'email': '', 'password1': '', 'password2': '' } form = UserRegistrationForm(u) with self.assertRaises(ValueError): form.save() u = {'username': '******'} form = UserRegistrationForm(u) with self.assertRaises(ValueError): form.save() u = { 'username': '******', 'first_name': '', 'last_name': '', 'email': '*****@*****.**', 'password1': '', 'password2': '' } form = UserRegistrationForm(u) with self.assertRaises(ValueError): form.save() u = { 'username': '******', 'first_name': 'bob', 'last_name': '', 'email': '*****@*****.**', 'password1': '', 'password2': '' } form = UserRegistrationForm(u) with self.assertRaises(ValueError): form.save()