1 # Patchwork - automated patch tracking system
2 # Copyright (C) 2009 Jeremy Kerr <jk@ozlabs.org>
4 # This file is part of the Patchwork package.
6 # Patchwork is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # Patchwork is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Patchwork; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 from django.test import TestCase
22 from django.test.client import Client
23 from patchwork.models import Patch, Comment, Person
24 from patchwork.tests.utils import defaults, create_user, find_in_context
26 class MboxPatchResponseTest(TestCase):
27 """ Test that the mbox view appends the Acked-by from a patch comment """
29 defaults.project.save()
31 self.person = defaults.patch_author_person
34 self.patch = Patch(project = defaults.project,
35 msgid = 'p1', name = 'testpatch',
36 submitter = self.person, content = '')
38 comment = Comment(patch = self.patch, msgid = 'p1',
39 submitter = self.person,
40 content = 'comment 1 text\nAcked-by: 1\n')
43 comment = Comment(patch = self.patch, msgid = 'p2',
44 submitter = self.person,
45 content = 'comment 2 text\nAcked-by: 2\n')
48 def testPatchResponse(self):
49 response = self.client.get('/patch/%d/mbox/' % self.patch.id)
50 self.assertContains(response,
51 'Acked-by: 1\nAcked-by: 2\n')
53 class MboxPatchSplitResponseTest(TestCase):
54 """ Test that the mbox view appends the Acked-by from a patch comment,
55 and places it before an '---' update line. """
57 defaults.project.save()
59 self.person = defaults.patch_author_person
62 self.patch = Patch(project = defaults.project,
63 msgid = 'p1', name = 'testpatch',
64 submitter = self.person, content = '')
66 comment = Comment(patch = self.patch, msgid = 'p1',
67 submitter = self.person,
68 content = 'comment 1 text\nAcked-by: 1\n---\nupdate\n')
71 comment = Comment(patch = self.patch, msgid = 'p2',
72 submitter = self.person,
73 content = 'comment 2 text\nAcked-by: 2\n')
76 def testPatchResponse(self):
77 response = self.client.get('/patch/%d/mbox/' % self.patch.id)
78 self.assertContains(response,
79 'Acked-by: 1\nAcked-by: 2\n')
81 class MboxPassThroughHeaderTest(TestCase):
82 """ Test that we see 'Cc' and 'To' headers passed through from original
83 message to mbox view """
86 defaults.project.save()
87 self.person = defaults.patch_author_person
90 self.cc_header = 'Cc: CC Person <cc@example.com>'
91 self.to_header = 'To: To Person <to@example.com>'
93 self.patch = Patch(project = defaults.project,
94 msgid = 'p1', name = 'testpatch',
95 submitter = self.person, content = '')
97 def testCCHeader(self):
98 self.patch.headers = self.cc_header + '\n'
101 response = self.client.get('/patch/%d/mbox/' % self.patch.id)
102 self.assertContains(response, self.cc_header)
104 def testToHeader(self):
105 self.patch.headers = self.to_header + '\n'
108 response = self.client.get('/patch/%d/mbox/' % self.patch.id)
109 self.assertContains(response, self.to_header)