1 # Patchwork - automated patch tracking system
2 # Copyright (C) 2008 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
23 from patchwork.models import Patch, Person
24 from patchwork.tests.utils import defaults, read_patch
25 from django.test import TestCase
26 from django.test.client import Client
28 class UTF8PatchViewTest(TestCase):
29 patch_filename = '0002-utf-8.patch'
30 patch_encoding = 'utf-8'
33 defaults.project.save()
34 defaults.patch_author_person.save()
35 self.patch_content = read_patch(self.patch_filename,
36 encoding = self.patch_encoding)
37 self.patch = Patch(project = defaults.project,
38 msgid = 'x', name = defaults.patch_name,
39 submitter = defaults.patch_author_person,
40 content = self.patch_content)
42 self.client = Client()
44 def testPatchView(self):
45 response = self.client.get('/patch/%d/' % self.patch.id)
46 self.assertContains(response, self.patch.name)
48 def testMboxView(self):
49 response = self.client.get('/patch/%d/mbox/' % self.patch.id)
50 self.assertEquals(response.status_code, 200)
51 self.assertTrue(self.patch.content in \
52 response.content.decode(self.patch_encoding))
54 def testRawView(self):
55 response = self.client.get('/patch/%d/raw/' % self.patch.id)
56 self.assertEquals(response.status_code, 200)
57 self.assertEquals(response.content.decode(self.patch_encoding),
62 defaults.patch_author_person.delete()
63 defaults.project.delete()
65 class UTF8HeaderPatchViewTest(UTF8PatchViewTest):
66 patch_filename = '0002-utf-8.patch'
67 patch_encoding = 'utf-8'
68 patch_author_name = u'P\xe4tch Author'
71 defaults.project.save()
72 self.patch_author = Person(name = self.patch_author_name,
73 email = defaults.patch_author_person.email)
74 self.patch_author.save()
75 self.patch_content = read_patch(self.patch_filename,
76 encoding = self.patch_encoding)
77 self.patch = Patch(project = defaults.project,
78 msgid = 'x', name = defaults.patch_name,
79 submitter = self.patch_author,
80 content = self.patch_content)
82 self.client = Client()
86 self.patch_author.delete()
87 defaults.project.delete()