Merge lp:~cjwatson/launchpad/bpph-phase-2 into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: William Grant
Approved revision: no longer in the source branch.
Merged at revision: 16512
Proposed branch: lp:~cjwatson/launchpad/bpph-phase-2
Merge into: lp:launchpad
Diff against target: 112 lines (+41/-7)
2 files modified
lib/lp/archivepublisher/model/ftparchive.py (+3/-3)
lib/lp/archivepublisher/tests/test_ftparchive.py (+38/-4)
To merge this branch: bzr merge lp:~cjwatson/launchpad/bpph-phase-2
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+150690@code.launchpad.net

Commit message

Fix ordering of binary overrides.

Description of the change

== Summary ==

I messed up the archivepublisher code in https://code.launchpad.net/~cjwatson/launchpad/bpph-phase/+merge/144154 slightly and only found out about it in QA. This branch corrects my embarrassment.

The fields are in a slightly peculiar order because the function that consumes them is shared between source and binary overrides.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/archivepublisher/model/ftparchive.py'
2--- lib/lp/archivepublisher/model/ftparchive.py 2013-02-13 14:14:04 +0000
3+++ lib/lp/archivepublisher/model/ftparchive.py 2013-02-27 01:21:22 +0000
4@@ -276,7 +276,7 @@
5 """Fetch override information about all published binaries.
6
7 The override information consists of tuples with 'binaryname',
8- 'architecture', 'component', 'section' and 'priority' strings and
9+ 'component', 'section', 'architecture' and 'priority' strings and
10 'phased_update_percentage' integers, in this order.
11
12 :param distroseries: target `IDistroSeries`
13@@ -307,8 +307,8 @@
14 return EmptyResultSet()
15
16 result_set = store.using(*origins).find(
17- (BinaryPackageName.name, DistroArchSeries.architecturetag,
18- Component.name, Section.name,
19+ (BinaryPackageName.name, Component.name, Section.name,
20+ DistroArchSeries.architecturetag,
21 BinaryPackagePublishingHistory.priority,
22 BinaryPackagePublishingHistory.phased_update_percentage),
23 BinaryPackagePublishingHistory.archive == self.publisher.archive,
24
25=== modified file 'lib/lp/archivepublisher/tests/test_ftparchive.py'
26--- lib/lp/archivepublisher/tests/test_ftparchive.py 2013-01-21 16:28:14 +0000
27+++ lib/lp/archivepublisher/tests/test_ftparchive.py 2013-02-27 01:21:22 +0000
28@@ -9,6 +9,7 @@
29 import os
30 import re
31 import shutil
32+from textwrap import dedent
33
34 from zope.component import getUtility
35
36@@ -26,7 +27,10 @@
37 BufferLogger,
38 DevNullLogger,
39 )
40-from lp.soyuz.enums import PackagePublishingPriority
41+from lp.soyuz.enums import (
42+ PackagePublishingPriority,
43+ PackagePublishingStatus,
44+ )
45 from lp.testing import TestCaseWithFactory
46 from lp.testing.dbuser import switch_dbuser
47 from lp.testing.layers import (
48@@ -53,6 +57,9 @@
49 def __init__(self, archive):
50 self.archive = archive
51
52+ def isAllowed(self, distroseries, pocket):
53+ return True
54+
55
56 class FakeSelectResult:
57 """Receive a list and emulate a SelectResult object."""
58@@ -179,7 +186,8 @@
59
60 def test_getBinariesForOverrides(self):
61 # getBinariesForOverrides returns a list of tuples containing:
62- # (sourcename, component, section, priority)
63+ # (sourcename, component, section, archtag, priority,
64+ # phased_update_percentage)
65
66 # Reconfigure FTPArchiveHandler to retrieve sampledata overrides.
67 fa = self._setUpFTPArchiveHandler()
68@@ -190,9 +198,9 @@
69 published_binaries = fa.getBinariesForOverrides(
70 hoary, PackagePublishingPocket.RELEASE)
71 expectedBinaries = [
72- ('pmount', 'hppa', 'main', 'base',
73+ ('pmount', 'main', 'base', 'hppa',
74 PackagePublishingPriority.EXTRA, None),
75- ('pmount', 'i386', 'universe', 'editors',
76+ ('pmount', 'universe', 'editors', 'i386',
77 PackagePublishingPriority.IMPORTANT, None),
78 ]
79 self.assertEqual(expectedBinaries, list(published_binaries))
80@@ -248,6 +256,32 @@
81 "foo/i386\tPhased-Update-Percentage\t50",
82 result_file.read().splitlines())
83
84+ def test_generateOverrides(self):
85+ # generateOverrides generates all the overrides from start to finish.
86+ self._distribution = getUtility(IDistributionSet).getByName('ubuntu')
87+ self._archive = self._distribution.main_archive
88+ self._publisher = SamplePublisher(self._archive)
89+ fa = self._setUpFTPArchiveHandler()
90+ pubs = self._archive.getAllPublishedBinaries(
91+ name="pmount", status=PackagePublishingStatus.PUBLISHED,
92+ distroarchseries=self._distribution.getSeries("hoary")["hppa"])
93+ for pub in pubs:
94+ pub.changeOverride(new_phased_update_percentage=30).setPublished()
95+ fa.generateOverrides(fullpublish=True)
96+ result_path = os.path.join(self._overdir, "override.hoary.main")
97+ with open(result_path) as result_file:
98+ self.assertEqual("pmount\textra\tbase\n", result_file.read())
99+ result_path = os.path.join(self._overdir, "override.hoary.main.src")
100+ with open(result_path) as result_file:
101+ self.assertIn("pmount\teditors\n", result_file.readlines())
102+ result_path = os.path.join(self._overdir, "override.hoary.extra.main")
103+ with open(result_path) as result_file:
104+ self.assertEqual(dedent("""\
105+ pmount\tOrigin\tUbuntu
106+ pmount\tBugs\thttps://bugs.launchpad.net/ubuntu/+filebug
107+ pmount/hppa\tPhased-Update-Percentage\t30
108+ """), result_file.read())
109+
110 def test_getSourceFiles(self):
111 # getSourceFiles returns a list of tuples containing:
112 # (sourcename, filename, component)