diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2011-02-11 08:45:51 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2011-02-11 08:46:53 +0800 |
commit | e465e7dd69c1f09ff1322424732a3668cdfd2f10 (patch) | |
tree | 7dcdc7cdf7c6ead15374dd4a7aa9c14710be2284 | |
parent | fae459d0b284b9a04cdf95f375357addc8ed36ec (diff) | |
download | patchwork-e465e7dd69c1f09ff1322424732a3668cdfd2f10.tar.bz2 patchwork-e465e7dd69c1f09ff1322424732a3668cdfd2f10.tar.xz |
tests/parser: Add subject encoding tests
We should now be able to decode internationalised Subject headers, so
add tests for this.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
-rw-r--r-- | apps/patchwork/tests/patchparser.py | 23 | ||||
-rw-r--r-- | apps/patchwork/tests/utils.py | 6 |
2 files changed, 29 insertions, 0 deletions
diff --git a/apps/patchwork/tests/patchparser.py b/apps/patchwork/tests/patchparser.py index ff0025a..1135a0a 100644 --- a/apps/patchwork/tests/patchparser.py +++ b/apps/patchwork/tests/patchparser.py @@ -173,6 +173,29 @@ class SenderUTF8QPSplitEncodingTest(SenderEncodingTest): class SenderUTF8B64EncodingTest(SenderUTF8QPEncodingTest): from_header = '=?utf-8?B?w6l4YW1wbGUgdXNlcg==?= <user@example.com>' +class SubjectEncodingTest(PatchTest): + sender = 'example user <user@example.com>' + subject = 'test subject' + subject_header = 'test subject' + + def setUp(self): + mail = 'From: %s\n' % self.sender + \ + 'Subject: %s\n\n' % self.subject_header + \ + 'test\n\n' + defaults.patch + self.projects = defaults.project + self.email = message_from_string(mail) + + def testSubjectEncoding(self): + (patch, comment) = find_content(self.project, self.email) + self.assertEquals(patch.name, self.subject) + +class SubjectUTF8QPEncodingTest(SubjectEncodingTest): + subject = u'test s\xfcbject' + subject_header = '=?utf-8?q?test=20s=c3=bcbject?=' + +class SubjectUTF8QPMultipleEncodingTest(SubjectEncodingTest): + subject = u'test s\xfcbject' + subject_header = 'test =?utf-8?q?s=c3=bcbject?=' class SenderCorrelationTest(unittest.TestCase): existing_sender = 'Existing Sender <existing@example.com>' diff --git a/apps/patchwork/tests/utils.py b/apps/patchwork/tests/utils.py index a85e168..cf445aa 100644 --- a/apps/patchwork/tests/utils.py +++ b/apps/patchwork/tests/utils.py @@ -50,6 +50,12 @@ class defaults(object): patch_name = 'Test Patch' + patch = """--- /dev/null 2011-01-01 00:00:00.000000000 +0800 ++++ a 2011-01-01 00:00:00.000000000 +0800 +@@ -0,0 +1 @@ ++a +""" + _user_idx = 1 def create_user(): global _user_idx |