try:
from email.mime.nonmultipart import MIMENonMultipart
from email.encoders import encode_7or8bit
+ from email.parser import HeaderParser
import email.utils
except ImportError:
# Python 2.4 compatibility
mail['Message-Id'] = self.msgid
mail.set_unixfrom('From patchwork ' + self.date.ctime())
- return mail
+ copied_headers = ['To', 'Cc']
+ orig_headers = HeaderParser().parsestr(str(self.headers))
+ for header in copied_headers:
+ if header in orig_headers:
+ mail[header] = orig_headers[header]
+
+ return mail
@models.permalink
def get_absolute_url(self):
response = self.client.get('/patch/%d/mbox/' % self.patch.id)
self.assertContains(response,
'Acked-by: 1\nAcked-by: 2\n')
+
+class MboxPassThroughHeaderTest(TestCase):
+ """ Test that we see 'Cc' and 'To' headers passed through from original
+ message to mbox view """
+
+ def setUp(self):
+ defaults.project.save()
+ self.person = defaults.patch_author_person
+ self.person.save()
+
+ self.cc_header = 'Cc: CC Person <cc@example.com>'
+ self.to_header = 'To: To Person <to@example.com>'
+
+ self.patch = Patch(project = defaults.project,
+ msgid = 'p1', name = 'testpatch',
+ submitter = self.person, content = '')
+
+ def testCCHeader(self):
+ self.patch.headers = self.cc_header + '\n'
+ self.patch.save()
+
+ response = self.client.get('/patch/%d/mbox/' % self.patch.id)
+ self.assertContains(response, self.cc_header)
+
+ def testToHeader(self):
+ self.patch.headers = self.to_header + '\n'
+ self.patch.save()
+
+ response = self.client.get('/patch/%d/mbox/' % self.patch.id)
+ self.assertContains(response, self.to_header)