aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Finucane <stephen@that.guru>2016-10-07 19:21:19 +0100
committerStephen Finucane <stephen@that.guru>2016-10-07 19:40:42 +0100
commit61a7843b7a76366b11971df633532da8070e71ee (patch)
tree2cefab08db15e73f98e408843968252585d8128b
parent9f7d11eeb728ed3eb5b542d00082db3be0e9a67f (diff)
downloadpatchwork-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.py24
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):