diff options
author | Stephen Finucane <stephen@that.guru> | 2016-10-07 19:21:19 +0100 |
---|---|---|
committer | Stephen Finucane <stephen@that.guru> | 2016-10-07 19:40:42 +0100 |
commit | 61a7843b7a76366b11971df633532da8070e71ee (patch) | |
tree | 2cefab08db15e73f98e408843968252585d8128b | |
parent | 9f7d11eeb728ed3eb5b542d00082db3be0e9a67f (diff) | |
download | patchwork-61a7843b7a76366b11971df633532da8070e71ee.tar patchwork-61a7843b7a76366b11971df633532da8070e71ee.tar.gz |
tests: Reduce duplication in MailParsingTest
...and rename to 'EncodingParseTest' to signify function of tests.
Signed-off-by: Stephen Finucane <stephen@that.guru>
-rw-r--r-- | patchwork/tests/test_parser.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/patchwork/tests/test_parser.py b/patchwork/tests/test_parser.py index 83ce204..912b821 100644 --- a/patchwork/tests/test_parser.py +++ b/patchwork/tests/test_parser.py @@ -543,35 +543,33 @@ class PatchParseTest(PatchTest): self.assertEqual(2, diff.count('\ No newline at end of file')) -class MailParsingTest(TestCase): +class EncodingParseTest(TestCase): + """Test parsing of patches with different encoding issues.""" def setUp(self): self.project = create_project() - def test_invalid_header_char(self): - """Validate behaviour when an invalid character is in a header.""" - mail = read_mail('0012-invalid-header-char.mbox', self.project) + def _test_encoded_patch_parse(self, mbox_filename): + mail = read_mail(mbox_filename, self.project) parse_mail(mail, list_id=self.project.listid) self.assertEqual(Patch.objects.all().count(), 1) + def test_invalid_header_char(self): + """Validate behaviour when an invalid character is in a header.""" + self._test_encoded_patch_parse('0012-invalid-header-char.mbox') + def test_utf8_mail(self): """Validate behaviour when a UTF-8 char is in a message.""" - mail = read_mail('0013-with-utf8-body.mbox') - parse_mail(mail, list_id=self.project.listid) - self.assertEqual(Patch.objects.all().count(), 1) + self._test_encoded_patch_parse('0013-with-utf8-body.mbox') def test_utf8_unencoded_headers(self): """Validate behaviour when unencoded UTF-8 is in headers, including subject and from.""" - mail = read_mail('0014-with-unencoded-utf8-headers.mbox') - parse_mail(mail, list_id=self.project.listid) - self.assertEqual(Patch.objects.all().count(), 1) + self._test_encoded_patch_parse('0014-with-unencoded-utf8-headers.mbox') def test_invalid_utf8_headers(self): """Validate behaviour when invalid encoded UTF-8 is in headers.""" - mail = read_mail('0015-with-invalid-utf8-headers.mbox') - parse_mail(mail, list_id=self.project.listid) - self.assertEqual(Patch.objects.all().count(), 1) + self._test_encoded_patch_parse('0015-with-invalid-utf8-headers.mbox') class DelegateRequestTest(TestCase): |