def test_email(self): """loops through variants of the from field in the emails and tests the email address extractor""" for test_case in EMAIL_CASES: self.data['sender'] = test_case[0] expected_result = test_case[1] form = forms.AskByEmailForm(self.data) if expected_result is None: self.assertFalse(form.is_valid()) else: self.assertTrue(form.is_valid()) self.assertEquals(form.cleaned_data['email'], expected_result)
def test_subject_line(self): """loops through various forms of the subject line and makes sure that tags and title are parsed out""" for test_case in SUBJECT_LINE_CASES: self.data['subject'] = test_case[0] form = forms.AskByEmailForm(self.data) output = test_case[1] if output is None: self.assertFalse(form.is_valid()) else: self.assertTrue(form.is_valid()) self.assertEquals(form.cleaned_data['tagnames'], output[0]) self.assertEquals(form.cleaned_data['title'], output[1])
def test_subject_line(self): """loops through various forms of the subject line and makes sure that tags and title are parsed out""" setting_backup = askbot_settings.TAGS_ARE_REQUIRED askbot_settings.update('TAGS_ARE_REQUIRED', True) for test_case in SUBJECT_LINE_CASES: self.data['subject'] = test_case[0] form = forms.AskByEmailForm(self.data) output = test_case[1] if output is None: self.assertFalse(form.is_valid()) else: self.assertTrue(form.is_valid()) self.assertEquals(form.cleaned_data['tagnames'], output[0]) self.assertEquals(form.cleaned_data['title'], output[1]) askbot_settings.update('TAGS_ARE_REQUIRED', setting_backup)