def test_form_valid_data(self): """ Form should be valid. """ form = PressInquiryForm(self.data) # make sure form is valid assert form.is_valid()
def test_form_honeypot(self): """ Form with honeypot text box filled should not be valid. """ self.data['office_fax'] = 'spammer' form = PressInquiryForm(self.data) assert not form.is_valid()
def test_form_missing_data(self): """ With incorrect data (missing email), form should not be valid and should have user_email in the errors hash. """ self.data.update(user_email='') # remove required user_email form = PressInquiryForm(self.data) # make sure form is invalid assert not form.is_valid() # make sure user_email errors are in form self.assertIn('user_email', form.errors)