~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
=================================
Distro Arch Series Binary Package
=================================

    >>> from lp.soyuz.model.binarypackagename import BinaryPackageName
    >>> from lp.soyuz.model.distroarchseries import DistroArchSeries
    >>> from lp.soyuz.model.distroarchseriesbinarypackage import (
    ...        DistroArchSeriesBinaryPackage)
    >>> hoary_i386 = DistroArchSeries.get(6)
    >>> pmount_name = BinaryPackageName.selectOneBy(name="pmount")
    >>> firefox_name = BinaryPackageName.selectOneBy(name="mozilla-firefox")
    >>> pmount_hoary_i386 = DistroArchSeriesBinaryPackage(
    ...     hoary_i386, pmount_name)
    >>> firefox_hoary_i386 = DistroArchSeriesBinaryPackage(
    ...     hoary_i386, firefox_name)

`DistroArchSeriesBinaryPackage`s have a title property:

    >>> print pmount_hoary_i386.title
    "pmount" binary package in Ubuntu Hoary i386

First, we create a new version of pmount, and a version of mozilla-
firefox that coincides with pmount's. We're hitch-hiking on two existing
builds that are in sampledata!

    >>> from lp.soyuz.model.publishing import (
    ...        BinaryPackagePublishingHistory)
    >>> from lp.services.database.constants import UTC_NOW
    >>> from lp.soyuz.model.binarypackagebuild import BinaryPackageBuild
    >>> from lp.soyuz.model.component import Component
    >>> from lp.soyuz.model.section import Section

    >>> main_component = Component.selectOneBy(name="main")
    >>> misc_section = Section.selectOneBy(name="base")
    >>> from lp.soyuz.enums import BinaryPackageFormat
    >>> binpackageformat = BinaryPackageFormat.DEB
    >>> from lp.soyuz.enums import (
    ...        PackagePublishingPriority, PackagePublishingStatus)
    >>> from lp.registry.interfaces.distribution import IDistributionSet
    >>> from lp.registry.interfaces.pocket import PackagePublishingPocket
    >>> priority = PackagePublishingPriority.STANDARD

XXX: noodles 2008-11-05 bug=294585: The dependency on a database id
needs to be removed.

    >>> bpr = BinaryPackageBuild.get(8).createBinaryPackageRelease(
    ...      binarypackagename=firefox_name.id,
    ...      version="120.6-0",
    ...      summary="Firefox loves lollies",
    ...      description="Lolly-pop loving application",
    ...      binpackageformat=binpackageformat,
    ...      component=main_component.id,
    ...      section=misc_section.id,
    ...      priority=priority,
    ...      shlibdeps=None,
    ...      depends=None,
    ...      recommends=None,
    ...      suggests=None,
    ...      conflicts=None,
    ...      replaces=None,
    ...      provides=None,
    ...      pre_depends=None,
    ...      enhances=None,
    ...      breaks=None,
    ...      essential=False,
    ...      installedsize=0,
    ...      architecturespecific=False,
    ...      debug_package=None)

    >>> pe = BinaryPackagePublishingHistory(
    ...      binarypackagerelease=bpr.id,
    ...      binarypackagename=bpr.binarypackagename,
    ...      component=main_component.id,
    ...      section=misc_section.id,
    ...      priority=priority,
    ...      distroarchseries=hoary_i386.id,
    ...      status=PackagePublishingStatus.PUBLISHED,
    ...      datecreated=UTC_NOW,
    ...      datepublished=UTC_NOW,
    ...      pocket=PackagePublishingPocket.RELEASE,
    ...      datesuperseded=None,
    ...      supersededby=None,
    ...      datemadepending=None,
    ...      dateremoved=None,
    ...      archive=hoary_i386.main_archive)

XXX: noodles 2008-11-06 bug=294585: The dependency on a database id
needs to be removed.

    >>> bpr = BinaryPackageBuild.get(9).createBinaryPackageRelease(
    ...      binarypackagename=pmount_name.id,
    ...      version="cr98.34",
    ...      summary="Pmount bakes cakes",
    ...      description="Phat cake-baker application",
    ...      binpackageformat=binpackageformat,
    ...      component=main_component.id,
    ...      section=misc_section.id,
    ...      priority=priority,
    ...      shlibdeps=None,
    ...      depends=None,
    ...      recommends=None,
    ...      suggests=None,
    ...      conflicts=None,
    ...      replaces=None,
    ...      provides=None,
    ...      pre_depends=None,
    ...      enhances=None,
    ...      breaks=None,
    ...      essential=False,
    ...      installedsize=0,
    ...      architecturespecific=False,
    ...      debug_package=None)

    >>> pe = BinaryPackagePublishingHistory(
    ...      binarypackagerelease=bpr.id,
    ...      binarypackagename=bpr.binarypackagename,
    ...      component=main_component.id,
    ...      section=misc_section.id,
    ...      priority=priority,
    ...      distroarchseries=hoary_i386.id,
    ...      status=PackagePublishingStatus.PUBLISHED,
    ...      datecreated=UTC_NOW,
    ...      datepublished=UTC_NOW,
    ...      pocket=PackagePublishingPocket.RELEASE,
    ...      datesuperseded=None,
    ...      supersededby=None,
    ...      datemadepending=None,
    ...      dateremoved=None,
    ...      archive=hoary_i386.main_archive)

Then, we ensure that grabbing the current release of pmount and the old
release both are sane.

    >>> current_release = pmount_hoary_i386.currentrelease
    >>> current_release.version
    u'cr98.34'

    >>> current_release.name
    u'pmount'

    >>> old_release = pmount_hoary_i386['0.1-1']
    >>> old_release.version
    u'0.1-1'

    >>> old_release.name
    u'pmount'

The source package that was used to build the current release is
available in the binary package's distro_source_package attribute.

    >>> distro_source_package = firefox_hoary_i386.distro_source_package
    >>> distro_source_package.displayname
    u'mozilla-firefox in Ubuntu'

If a given binary package doesn't have a current release, then the
distro_source_package attribute should return None.

    >>> from zope.security.proxy import removeSecurityProxy
    >>> deb_wdy_i386 = removeSecurityProxy(
    ...        getUtility(IDistributionSet)['debian']['woody']['i386'])
    >>> pmount_woody_i386 = DistroArchSeriesBinaryPackage(
    ...        deb_wdy_i386, pmount_name)
    >>> print pmount_woody_i386.distro_source_package
    None

Check the publishing record of packages returned by 'currentrelease' and
'__getitem__', which are different and in 'Published' state.

    >>> pe.id == current_release.current_publishing_record.id
    True

    >>> (pe.status.title,
    ...     pe.distroarchseries.architecturetag)
    ('Published', u'i386')

    >>> old_pubrec = old_release.current_publishing_record
    >>> (old_pubrec.id , old_pubrec.status.title,
    ...     old_pubrec.distroarchseries.architecturetag)
    (12, 'Published', u'i386')

Note that it is only really possible to have two packages in the
"Published" status if domination hasn't run yet.


Package caches and DARBP summaries
----------------------------------

Bug 208233 teaches us that DistroArchSeriesBinaryPackage summaries use
package caches to generate their output, and unfortunately that means
they can interact poorly with PPA-published packages which live in the
same cache table. Here's a test that ensures that the code that fetches
summaries works.

XXX: this is really too complicated, and the code in
DistroArchSeriesBinaryPackage.summary should be simplified.

    -- kiko, 2008-03-28

    >>> from lp.registry.interfaces.distribution import IDistributionSet
    >>> from lp.registry.interfaces.person import IPersonSet
    >>> ubuntu = getUtility(IDistributionSet)['ubuntu']
    >>> cprov = getUtility(IPersonSet).getByName('cprov')
    >>> warty = ubuntu['warty']

First, update the cache tables for Celso's PPA:

    >>> from lp.services.config import config
    >>> from lp.testing.layers import LaunchpadZopelessLayer
    >>> LaunchpadZopelessLayer.switchDbUser(config.statistician.dbuser)

    >>> from lp.services.log.logger import FakeLogger
    >>> from lp.soyuz.model.distributionsourcepackagecache import (
    ...        DistributionSourcePackageCache)
    >>> DistributionSourcePackageCache.updateAll(
    ...       ubuntu, archive=cprov.archive, ztm=LaunchpadZopelessLayer.txn,
    ...       log=FakeLogger())
    DEBUG ...
    DEBUG Considering source 'pmount'
    ...

    >>> from lp.soyuz.model.distroseriespackagecache import (
    ...        DistroSeriesPackageCache)
    >>> DistroSeriesPackageCache.updateAll(
    ...       warty, archive=cprov.archive, ztm=LaunchpadZopelessLayer.txn,
    ...       log=FakeLogger())
    DEBUG Considering binary 'mozilla-firefox'
    ...

    >>> cprov.archive.updateArchiveCache()
    >>> from lp.services.database.sqlbase import commit
    >>> commit()
    >>> flush_database_updates()

Then, supersede all pmount publications in warty for pmount (this sets
us up to demonstrate bug 208233).

    >>> LaunchpadZopelessLayer.switchDbUser('archivepublisher')
    >>> from lp.soyuz.model.binarypackagename import BinaryPackageName
    >>> from lp.soyuz.model.distroarchseries import DistroArchSeries
    >>> from lp.soyuz.model.distroarchseriesbinarypackage import (
    ...        DistroArchSeriesBinaryPackage)
    >>> from lp.soyuz.model.publishing import BinaryPackagePublishingHistory
    >>> warty_i386 = DistroArchSeries.get(1)
    >>> pmount_name = BinaryPackageName.selectOneBy(name="pmount")
    >>> pmount_warty_i386 = DistroArchSeriesBinaryPackage(warty_i386,
    ...                                                      pmount_name)
    >>> pubs = BinaryPackagePublishingHistory.selectBy(
    ...          archive=1,
    ...          distroarchseries=warty_i386,
    ...          status=PackagePublishingStatus.PUBLISHED)
    >>> for p in pubs:
    ...      if p.binarypackagerelease.binarypackagename == pmount_name:
    ...          s = p.supersede()
    >>> commit()
    >>> flush_database_updates()
    >>> LaunchpadZopelessLayer.switchDbUser(config.statistician.dbuser)

Now, if that bug is actually fixed, this works:

    >>> pmount_warty_i386.summary
    u'pmount shortdesc'

    >>> pmount_warty_i386.description
    u'pmount description'

Yay!