def send_test_mail(self): form = ContactForm({'name': 'Test Case', 'email': '*****@*****.**', 'subject': 'Test subject', 'body': 'Test body'}) # Validate the data so we know it's safe and stored appropiatly, # the assertion is there just to make sure self.assertTrue(form.is_valid()) form.send_mail()
def test_name_email_subject_body_fields_required(self): form = ContactForm({'name': ''}) self.assertFalse(form.is_valid()) # Check if required by just checking whether errors were raised self.assertIn('name', form.errors) self.assertIn('email', form.errors) self.assertIn('subject', form.errors) self.assertIn('body', form.errors)