def test_form_not_valid_username(self): form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '******', 'password': '******', 'confirm_password': '******', }) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 1) form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '', 'password': '******', 'confirm_password': '******', }) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 1) form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '******', 'password': '******', 'confirm_password': '******', }) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 1)
def test_form_not_valid_password(self): form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '******', 'password': '', 'confirm_password': '******', }) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 2) form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '******', 'password': '******', 'confirm_password': '', }) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 1) form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '******', 'password': '******', 'confirm_password': '******', }) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 2) form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '******', 'password': '******', 'confirm_password': '******', }) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 1) form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '******', 'password': '******', 'confirm_password': '******', }) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 1)
def test_form_valid_data(self): form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '******', 'password': '******', 'confirm_password': '******', }) self.assertTrue(form.validate())
def test_user_already_existss(self): # User exists form = RegistrationForm( data={ 'email': '*****@*****.**', 'username': '******', 'password': '******', 'confirm_password': '******', }) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 1)
def test_form_no_data(self): form = RegistrationForm(data={}) self.assertFalse(form.validate()) self.assertEquals(len(form.errors), 4)