From f79c54871da0c36daaa559ec4a86f3e926bbe9ff Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Wed, 23 Apr 2014 21:02:46 +0800 Subject: tests: Make tests compatible with django 1.6 The default test runner in django 1.6 relies on tests being named test*.py, rather that an explicit .test module. Signed-off-by: Jeremy Kerr --- apps/patchwork/tests/test_person.py | 55 +++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 apps/patchwork/tests/test_person.py (limited to 'apps/patchwork/tests/test_person.py') diff --git a/apps/patchwork/tests/test_person.py b/apps/patchwork/tests/test_person.py new file mode 100644 index 0000000..d948096 --- /dev/null +++ b/apps/patchwork/tests/test_person.py @@ -0,0 +1,55 @@ +# Patchwork - automated patch tracking system +# Copyright (C) 2013 Jeremy Kerr +# +# This file is part of the Patchwork package. +# +# Patchwork is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# Patchwork is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Patchwork; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +import unittest +from django.test import TestCase +from django.test.client import Client +from patchwork.models import EmailConfirmation, Person, Bundle +import json + +class SubmitterCompletionTest(TestCase): + def setUp(self): + self.people = [ + Person(name = "Test Name", email = "test1@example.com"), + Person(email = "test2@example.com"), + ] + map(lambda p: p.save(), self.people) + + def testNameComplete(self): + response = self.client.get('/submitter/', {'q': 'name'}) + self.assertEquals(response.status_code, 200) + data = json.loads(response.content) + self.assertEquals(len(data), 1) + self.assertEquals(data[0]['fields']['name'], 'Test Name') + + def testEmailComplete(self): + response = self.client.get('/submitter/', {'q': 'test2'}) + self.assertEquals(response.status_code, 200) + data = json.loads(response.content) + self.assertEquals(len(data), 1) + self.assertEquals(data[0]['fields']['email'], 'test2@example.com') + + def testCompleteLimit(self): + for i in range(3,10): + person = Person(email = 'test%d@example.com' % i) + person.save() + response = self.client.get('/submitter/', {'q': 'test', 'l': 5}) + self.assertEquals(response.status_code, 200) + data = json.loads(response.content) + self.assertEquals(len(data), 5) -- cgit v1.2.3