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 fixtures = ['default_states']
30 patch_filename = '0002-utf-8.patch'
31 patch_encoding = 'utf-8'
34 defaults.project.save()
35 defaults.patch_author_person.save()
36 self.patch_content = read_patch(self.patch_filename,
37 encoding = self.patch_encoding)
38 self.patch = Patch(project = defaults.project,
39 msgid = 'x', name = defaults.patch_name,
40 submitter = defaults.patch_author_person,
41 content = self.patch_content)
43 self.client = Client()
45 def testPatchView(self):
46 response = self.client.get('/patch/%d/' % self.patch.id)
47 self.assertContains(response, self.patch.name)
49 def testMboxView(self):
50 response = self.client.get('/patch/%d/mbox/' % self.patch.id)
51 self.assertEquals(response.status_code, 200)
52 self.assertTrue(self.patch.content in \
53 response.content.decode(self.patch_encoding))
55 def testRawView(self):
56 response = self.client.get('/patch/%d/raw/' % self.patch.id)
57 self.assertEquals(response.status_code, 200)
58 self.assertEquals(response.content.decode(self.patch_encoding),
63 defaults.patch_author_person.delete()
64 defaults.project.delete()
66 class UTF8HeaderPatchViewTest(UTF8PatchViewTest):
67 fixtures = ['default_states']
68 patch_filename = '0002-utf-8.patch'
69 patch_encoding = 'utf-8'
70 patch_author_name = u'P\xe4tch Author'
73 defaults.project.save()
74 self.patch_author = Person(name = self.patch_author_name,
75 email = defaults.patch_author_person.email)
76 self.patch_author.save()
77 self.patch_content = read_patch(self.patch_filename,
78 encoding = self.patch_encoding)
79 self.patch = Patch(project = defaults.project,
80 msgid = 'x', name = defaults.patch_name,
81 submitter = self.patch_author,
82 content = self.patch_content)
84 self.client = Client()
88 self.patch_author.delete()
89 defaults.project.delete()