From 9aeaf0bf275b74afe4c91cf2ec1dc79750f7aa59 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Thu, 24 Apr 2014 11:28:31 +0800 Subject: [PATCH] utils/Order: Fix application of ordering We can't just re-apply orderings to the same queryset, we need to apply all at once. Signed-off-by: Jeremy Kerr --- apps/patchwork/tests/test_list.py | 78 +++++++++++++++++++++++++++++++ apps/patchwork/utils.py | 6 +-- 2 files changed, 81 insertions(+), 3 deletions(-) diff --git a/apps/patchwork/tests/test_list.py b/apps/patchwork/tests/test_list.py index 1bdb506..a795a5f 100644 --- a/apps/patchwork/tests/test_list.py +++ b/apps/patchwork/tests/test_list.py @@ -18,9 +18,14 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import unittest +import random +import datetime +import string +import re from django.test import TestCase from django.test.client import Client from patchwork.tests.utils import defaults, create_user, find_in_context +from patchwork.models import Person, Patch from django.core.urlresolvers import reverse class EmptyPatchListTest(TestCase): @@ -36,3 +41,76 @@ class EmptyPatchListTest(TestCase): self.assertContains(response, 'No patches to display') self.assertNotContains(response, 'tbody') +class PatchOrderTest(TestCase): + + d = datetime.datetime + patchmeta = [ + ('AlCMyjOsx', 'AlxMyjOsx@nRbqkQV.wBw', d(2014,3,16,13, 4,50, 155643)), + ('MMZnrcDjT', 'MMmnrcDjT@qGaIfOl.tbk', d(2014,1,25,13, 4,50, 162814)), + ('WGirwRXgK', 'WGSrwRXgK@TriIETY.GhE', d(2014,2,14,13, 4,50, 169305)), + ('isjNIuiAc', 'issNIuiAc@OsEirYx.EJh', d(2014,3,15,13, 4,50, 176264)), + ('XkAQpYGws', 'XkFQpYGws@hzntTcm.JSE', d(2014,1,18,13, 4,50, 182493)), + ('uJuCPWMvi', 'uJACPWMvi@AVRBOBl.ecy', d(2014,3,12,13, 4,50, 189554)), + ('TyQmWtcbg', 'TylmWtcbg@DzrNeNH.JuB', d(2014,2, 3,13, 4,50, 195685)), + ('FpvAhWRdX', 'FpKAhWRdX@agxnCAI.wFO', d(2014,3,15,13, 4,50, 201398)), + ('bmoYvnyWa', 'bmdYvnyWa@aeoPnlX.juy', d(2014,3, 4,13, 4,50, 206800)), + ('CiReUQsAq', 'CiieUQsAq@DnOYRuf.TTI', d(2014,3,28,13, 4,50, 212169)), + ] + + def setUp(self): + defaults.project.save() + + for (name, email, date) in self.patchmeta: + patch_name = 'testpatch' + name + person = Person(name = name, email = email) + person.save() + patch = Patch(project = defaults.project, msgid = patch_name, + submitter = person, content = '', date = date) + patch.save() + + def _extract_patch_ids(self, response): + id_re = re.compile('