9256.2.5
by Celso Providelo
Adding view tests |
1 |
DistributionSourcePackageRelease views |
2 |
====================================== |
|
3 |
||
4 |
# Create a brand new publication of 'testing-dspr - 1.0' for tests. |
|
5 |
>>> from lp.soyuz.tests.test_publishing import SoyuzTestPublisher |
|
6 |
>>> stp = SoyuzTestPublisher() |
|
7 |
>>> login('foo.bar@canonical.com') |
|
8 |
>>> stp.prepareBreezyAutotest() |
|
9 |
>>> source = stp.getPubSource('testing-dspr', version='1.0') |
|
10 |
>>> login(ANONYMOUS) |
|
11 |
||
12 |
>>> dspr = stp.ubuntutest.getSourcePackageRelease( |
|
13 |
... source.sourcepackagerelease) |
|
14 |
||
15 |
`DistributionSourcePackageReleaseView` provides 'page_title', which |
|
16 |
simply mimics the `DistributionSourcePackageRelease.title`. |
|
17 |
||
18 |
>>> dspr_view = create_initialized_view(dspr, name="+index") |
|
19 |
||
20 |
>>> print dspr.title |
|
9514.1.8
by Julian Edwards
fix a bunch of tests |
21 |
"testing-dspr" 1.0 source package in ubuntutest |
9256.2.5
by Celso Providelo
Adding view tests |
22 |
|
10156.1.5
by Bjorn Tillenius
Don't use non-ascii characters in doctests. |
23 |
>>> dspr_view.page_title |
24 |
u'\u201ctesting-dspr\u201d 1.0 source package in ubuntutest' |
|
9256.2.5
by Celso Providelo
Adding view tests |
25 |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
26 |
The 'files' property returns a list of files included in the source |
27 |
upload encapsulated as `ProxiedLibraryFileAlias` objects. Their |
|
28 |
'http_url' points to the LP proxied url which normalizes the path |
|
29 |
tofiles allowing them to be downloaded using `dget`. |
|
9256.2.5
by Celso Providelo
Adding view tests |
30 |
|
31 |
>>> for source_file in dspr_view.files: |
|
32 |
... print source_file.filename, source_file.http_url |
|
33 |
testing-dspr_1.0.dsc |
|
34 |
http://.../ubuntutest/+archive/primary/+files/testing-dspr_1.0.dsc |
|
35 |
||
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
36 |
The 'sponsor' property indicates whether the upload was 'sponsored' or |
9256.2.5
by Celso Providelo
Adding view tests |
37 |
not. When the upload was signed by someone else than the source |
38 |
creator, the upload signer is the sponsor. |
|
39 |
||
40 |
>>> print dspr.creator.displayname |
|
41 |
Foo Bar |
|
42 |
||
43 |
>>> print dspr_view.sponsor |
|
44 |
None |
|
45 |
||
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
46 |
# Forcibly change the SPR.creator, so the source becomes 'sponsored'. |
9256.2.5
by Celso Providelo
Adding view tests |
47 |
>>> from zope.security.proxy import removeSecurityProxy |
48 |
>>> login('foo.bar@canonical.com') |
|
49 |
>>> a_person = factory.makePerson(name='novice') |
|
50 |
>>> removeSecurityProxy(dspr.sourcepackagerelease).creator = a_person |
|
51 |
>>> login(ANONYMOUS) |
|
52 |
||
53 |
>>> dspr_view = create_initialized_view(dspr, name="+index") |
|
54 |
||
55 |
>>> print dspr.creator.displayname |
|
56 |
Novice |
|
57 |
||
58 |
>>> print dspr_view.sponsor.displayname |
|
59 |
Foo Bar |
|
60 |
||
61 |
'currently_published' contains only PUBLISHED publications for this |
|
62 |
`DistributionSourcePackageRelease` object. Since the testing DSPR only |
|
63 |
contains a PENDING publication (see `SoyuzTestPublisher.getPubSource`) |
|
64 |
this property is empty. |
|
65 |
||
66 |
>>> len(dspr_view.currently_published) |
|
67 |
0 |
|
68 |
||
69 |
It gets populated according to the publishing cycle, and subsequent |
|
70 |
copies. |
|
71 |
||
72 |
# Publish the pending testing publication. |
|
73 |
>>> login('foo.bar@canonical.com') |
|
7659.7.5
by Julian Edwards
Fix lots of broken stuff |
74 |
>>> source.setPublished() |
9256.2.5
by Celso Providelo
Adding view tests |
75 |
>>> transaction.commit() |
76 |
>>> login(ANONYMOUS) |
|
77 |
||
78 |
>>> dspr_view = create_initialized_view(dspr, name="+index") |
|
79 |
>>> for publishing in dspr_view.currently_published: |
|
80 |
... print publishing.distroseries.name |
|
81 |
breezy-autotest |
|
82 |
||
83 |
# Copy the testing publication to another series. |
|
84 |
>>> from lp.soyuz.interfaces.publishing import PackagePublishingPocket |
|
85 |
>>> login('foo.bar@canonical.com') |
|
86 |
>>> release_pocket = PackagePublishingPocket.RELEASE |
|
87 |
>>> hoary = stp.ubuntutest.getSeries('hoary-test') |
|
88 |
>>> copied_source = source.copyTo( |
|
89 |
... hoary, release_pocket, stp.ubuntutest.main_archive) |
|
7659.7.5
by Julian Edwards
Fix lots of broken stuff |
90 |
>>> copied_source.setPublished() |
9256.2.5
by Celso Providelo
Adding view tests |
91 |
>>> transaction.commit() |
92 |
>>> login(ANONYMOUS) |
|
93 |
||
94 |
>>> dspr_view = create_initialized_view(dspr, name="+index") |
|
95 |
>>> for publishing in dspr_view.currently_published: |
|
96 |
... print publishing.distroseries.name |
|
97 |
hoary-test |
|
98 |
breezy-autotest |
|
99 |
||
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
100 |
'grouped_builds' returns a list of dictionaries which contains |
101 |
`IBuild`s for a given `IDistroSeries`. |
|
9256.2.5
by Celso Providelo
Adding view tests |
102 |
|
103 |
>>> def print_grouped_builds(): |
|
104 |
... for build_group in dspr_view.grouped_builds: |
|
105 |
... arch_tags = ' '.join( |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
106 |
... build.arch_tag for build in build_group['builds']) |
107 |
... print '%s: %s' % (build_group['distroseries'].name, arch_tags) |
|
108 |
... print 'END' |
|
9256.2.5
by Celso Providelo
Adding view tests |
109 |
|
110 |
>>> print_grouped_builds() |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
111 |
END |
9256.2.5
by Celso Providelo
Adding view tests |
112 |
|
113 |
# Create default builds for the testing DSPR. |
|
114 |
>>> login('foo.bar@canonical.com') |
|
115 |
>>> unused = source.createMissingBuilds() |
|
116 |
>>> login(ANONYMOUS) |
|
117 |
||
118 |
>>> dspr_view = create_initialized_view(dspr, name="+index") |
|
119 |
>>> print_grouped_builds() |
|
120 |
breezy-autotest: i386 |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
121 |
END |
9256.2.5
by Celso Providelo
Adding view tests |
122 |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
123 |
The returned dictionaries are ordered by descending distroseries |
124 |
version and their 'builds' are ordered by ascending 'architecturetag'. |
|
9256.2.5
by Celso Providelo
Adding view tests |
125 |
|
126 |
# Create extras builds for the testing DSPR. |
|
127 |
>>> login('foo.bar@canonical.com') |
|
128 |
>>> hoary_amd64 = hoary['amd64'] |
|
129 |
>>> unused = source.sourcepackagerelease.createBuild( |
|
130 |
... hoary_amd64, release_pocket, stp.ubuntutest.main_archive) |
|
131 |
>>> breezy_hppa = stp.breezy_autotest['hppa'] |
|
132 |
>>> unused = source.sourcepackagerelease.createBuild( |
|
133 |
... breezy_hppa, release_pocket, stp.ubuntutest.main_archive) |
|
134 |
>>> login(ANONYMOUS) |
|
135 |
||
136 |
>>> dspr_view = create_initialized_view(dspr, name="+index") |
|
137 |
>>> print_grouped_builds() |
|
138 |
hoary-test: amd64 |
|
139 |
breezy-autotest: hppa i386 |
|
9256.2.11
by Celso Providelo
applying review comments, r=jtv. |
140 |
END |