def setUp(self): self.form = UserForm(data={ 'first_name': 'John', 'initial': 'Q', 'last_name': 'Doe', 'email': '*****@*****.**', })
class TestUserForm(TestCase): def setUp(self): self.form = UserForm(data={ 'first_name': 'John', 'initial': 'Q', 'last_name': 'Doe', 'email': '*****@*****.**', }) def test_initial_conditions(self): self.assertTrue(self.form.is_valid()) def test_no_initial(self): self.form.data['initial'] = '' self.assertTrue(self.form.is_valid()) def test_bad_initial(self): self.form.data['initial'] = 'foo' self.assertFalse(self.form.is_valid()) def test_missing_email(self): self.form.data['email'] = '' self.assertFalse(self.form.is_valid()) def test_missing_first_name(self): self.form.data['first_name'] = '' self.assertFalse(self.form.is_valid()) def test_missing_last_name(self): self.form.data['last_name'] = '' self.assertFalse(self.form.is_valid())