Patchwork [3/4] tests/mboxviews: test for unchanged postscript

login
register
mail settings
Submitter Andreas Bießmann
Date Nov. 19, 2013, 2:44 p.m.
Message ID <1384872242-18238-3-git-send-email-andreas@biessmann.de>
Download mbox | patch
Permalink /patch/292587/
State New
Headers show

Comments

Andreas Bießmann - Nov. 19, 2013, 2:44 p.m.
Currently a patch containing postscript is always modified in patch_to_mbox()
compared to the input patch.

A comment containing 'some comment\n---\n some/file | 1 +' will be changed to
'some comment\n\n---\nsome/file | 1 +\n' which is annoying.

This patch adds a test to detect that, a follow up patch will fix the error
then.

Signed-off-by: Andreas Bießmann <andreas@biessmann.de>
---
 apps/patchwork/tests/mboxviews.py |   28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

Patch

diff --git a/apps/patchwork/tests/mboxviews.py b/apps/patchwork/tests/mboxviews.py
index 6209513..0e57f42 100644
--- a/apps/patchwork/tests/mboxviews.py
+++ b/apps/patchwork/tests/mboxviews.py
@@ -179,3 +179,31 @@  class MboxDateHeaderTest(TestCase):
         mail = email.message_from_string(response.content)
         mail_date = dateutil.parser.parse(mail['Date'])
         self.assertEqual(mail_date, date)
+
+class MboxCommentPostcriptUnchangedTest(TestCase):
+    """ Test that the mbox view doesn't change the postscript part of a mail.
+        There where always a missing blank right after the postscript
+        delimiter '---' and an additional newline right before. """
+    def setUp(self):
+        defaults.project.save()
+
+        self.person = defaults.patch_author_person
+        self.person.save()
+
+        self.patch = Patch(project = defaults.project,
+                           msgid = 'p1', name = 'testpatch',
+                           submitter = self.person, content = '')
+        self.patch.save()
+
+        self.txt = 'some comment\n---\n some/file | 1 +\n'
+
+        comment = Comment(patch = self.patch, msgid = 'p1',
+                submitter = self.person,
+                content = self.txt)
+        comment.save()
+
+    def testCommentUnchanged(self):
+        response = self.client.get('/patch/%d/mbox/' % self.patch.id)
+        self.assertContains(response, self.txt)
+        self.txt += "\n"
+        self.assertNotContains(response, self.txt)