← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~jtv/launchpad/bug-808651 into lp:launchpad

 

Jeroen T. Vermeulen has proposed merging lp:~jtv/launchpad/bug-808651 into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #808651 in Launchpad itself: "Ordering in DistroSeries.getPackageUploads is not well-tested"
  https://bugs.launchpad.net/launchpad/+bug/808651

For more details, see:
https://code.launchpad.net/~jtv/launchpad/bug-808651/+merge/67504

= Summary =

We've recently fitted a drop-in replacement for the innards of DistroSeries.getPackageUploads.  Problem is, there were sorting intricacies (and shortcomings) in the old version that were never tested, which weren't really tested in the new version either.

This new test ensures that PackageUploads are sorted from newest to oldest, even when mixing multiple types of uploads.


== Proposed fix ==

The test creates uploads of different types.  A few types are repeated in the test list to ensure that uploads of the same types are not swept together in the sort order.


== Tests ==

{{{
./bin/test lp.soyuz.tests.test_packageupload -t getAll_order
}}}


= Launchpad lint =

Checking for conflicts and issues in changed files.

Linting changed files:
  lib/lp/soyuz/tests/test_packageupload.py
-- 
https://code.launchpad.net/~jtv/launchpad/bug-808651/+merge/67504
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/launchpad/bug-808651 into lp:launchpad.
=== modified file 'lib/lp/soyuz/tests/test_packageupload.py'
--- lib/lp/soyuz/tests/test_packageupload.py	2011-07-05 09:24:20 +0000
+++ lib/lp/soyuz/tests/test_packageupload.py	2011-07-11 08:42:39 +0000
@@ -12,6 +12,7 @@
 from zope.security.proxy import removeSecurityProxy
 
 from canonical.config import config
+from canonical.launchpad.interfaces.lpstorm import IStore
 from canonical.testing.layers import LaunchpadZopelessLayer
 from lp.archivepublisher.interfaces.publisherconfig import IPublisherConfigSet
 from lp.archiveuploader.tests import datadir
@@ -815,3 +816,25 @@
             [upload],
             upload_set.getAll(
                 distroseries, name=spn.name, version=upload.displayversion))
+
+    def test_getAll_orders_in_reverse_historical_order(self):
+        # The results from getAll are returned in order of creation,
+        # newest to oldest, regardless of upload type.
+        series = self.factory.makeDistroSeries()
+        store = IStore(series)
+        ordered_uploads = []
+        ordered_uploads.append(self.factory.makeCopyJobPackageUpload(series))
+        store.flush()
+        ordered_uploads.append(self.factory.makeBuildPackageUpload(series))
+        store.flush()
+        ordered_uploads.append(self.factory.makeSourcePackageUpload(series))
+        store.flush()
+        ordered_uploads.append(self.factory.makeCustomPackageUpload(series))
+        store.flush()
+        ordered_uploads.append(self.factory.makeCopyJobPackageUpload(series))
+        store.flush()
+        ordered_uploads.append(self.factory.makeSourcePackageUpload(series))
+        store.flush()
+        self.assertEqual(
+            list(reversed(ordered_uploads)),
+            list(getUtility(IPackageUploadSet).getAll(series)))