Merge lp:~rockstar/launchpad/recipe-no-signer into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Merged at revision: 11258
Proposed branch: lp:~rockstar/launchpad/recipe-no-signer
Merge into: lp:launchpad
Diff against target: 153 lines (+55/-8)
5 files modified
lib/lp/soyuz/interfaces/sourcepackagerelease.py (+4/-2)
lib/lp/soyuz/model/sourcepackagerelease.py (+9/-1)
lib/lp/soyuz/templates/archive-index.pt (+1/-1)
lib/lp/soyuz/tests/test_sourcepackagerelease.py (+32/-0)
lib/lp/testing/factory.py (+9/-4)
To merge this branch: bzr merge lp:~rockstar/launchpad/recipe-no-signer
Reviewer Review Type Date Requested Status
Tim Penhey (community) conditional Approve
Review via email: mp+31339@code.launchpad.net

Description of the change

This branch just creates a SourcePackageRelease.uploader that not only knows about how to deal with source package uploads, but source package recipes. I created new unit tests for each uploader case that can happen as well. I also cleaned up some lint as a driveby, but it's still complaining about commas not following whitespace.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Test case in lib/lp/soyuz/tests/test_sourcepackagerelease.py is missing a lot
of docstrings.

> def test_uploader_no_uploader(self):

You shouldn't test for equality to None, use assertIs instead.
    self.assertIs(None, spr.uploader)

Also don't split the lines if they don't need it.

> def test_uploader_dsc_package(self):

Instead of testing against spr.dscsigningkey.owner, just use 'owner' as you
created it in the test. It makes the test more obvious.

    self.assertEqual(owner, spr.uploader)

> def test_uploader_recipe(self):

Keep the assertEqual on one line.

Thanks for the other lint cleanup.

review: Approve (conditional)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/interfaces/sourcepackagerelease.py'
2--- lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-03-20 23:16:42 +0000
3+++ lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-07-29 23:12:50 +0000
4@@ -137,6 +137,8 @@
5 "The `PackageUpload` record corresponding to original upload of "
6 "this source package release. It's 'None' if it is a source "
7 "imported by Gina.")
8+ uploader = Attribute(
9+ "The user who uploaded the package.")
10
11 # Really ISourcePackageRecipeBuild -- see _schema_circular_imports.
12 source_package_recipe_build = Reference(
13@@ -183,8 +185,8 @@
14
15 :tarball_alias: is a Librarian alias that references to a tarball with
16 translations.
17- :is_published: indicates if the imported files are already published by
18- upstream.
19+ :is_published: indicates if the imported files are already published
20+ by upstream.
21 :importer: is the person that did the import.
22
23 raise DownloadFailed if we are not able to fetch the file from
24
25=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
26--- lib/lp/soyuz/model/sourcepackagerelease.py 2010-07-23 11:18:54 +0000
27+++ lib/lp/soyuz/model/sourcepackagerelease.py 2010-07-29 23:12:50 +0000
28@@ -147,7 +147,6 @@
29 package_diffs = SQLMultipleJoin(
30 'PackageDiff', joinColumn='to_source', orderBy="-date_requested")
31
32-
33 @property
34 def builds(self):
35 """See `ISourcePackageRelease`."""
36@@ -521,6 +520,15 @@
37 return DecoratedResultSet(results, operator.itemgetter(0)).one()
38
39 @property
40+ def uploader(self):
41+ """See `ISourcePackageRelease`"""
42+ if self.source_package_recipe_build is not None:
43+ return self.source_package_recipe_build.requester
44+ if self.dscsigningkey is not None:
45+ return self.dscsigningkey.owner
46+ return None
47+
48+ @property
49 def change_summary(self):
50 """See ISourcePackageRelease"""
51 # this regex is copied from apt-listchanges.py courtesy of MDZ
52
53=== modified file 'lib/lp/soyuz/templates/archive-index.pt'
54--- lib/lp/soyuz/templates/archive-index.pt 2010-03-24 16:54:56 +0000
55+++ lib/lp/soyuz/templates/archive-index.pt 2010-07-29 23:12:50 +0000
56@@ -280,7 +280,7 @@
57 </tal:newer_version>
58 </td>
59 <td tal:define="spr publishing/sourcepackagerelease;
60- signer spr/dscsigningkey/owner/fmt:link|string:no signer">
61+ signer spr/uploader/fmt:link|string:no signer">
62 <span tal:replace="structure signer">Joe Bloggs</span>
63 <tal:date_published
64 condition="publishing/datepublished">
65
66=== added file 'lib/lp/soyuz/tests/test_sourcepackagerelease.py'
67--- lib/lp/soyuz/tests/test_sourcepackagerelease.py 1970-01-01 00:00:00 +0000
68+++ lib/lp/soyuz/tests/test_sourcepackagerelease.py 2010-07-29 23:12:50 +0000
69@@ -0,0 +1,32 @@
70+# Copyright 2010 Canonical Ltd. This software is licensed under the
71+# GNU Affero General Public License version 3 (see the file LICENSE).
72+
73+"""Test SourcePackageRelease."""
74+
75+__metaclass__ = type
76+
77+from canonical.testing import LaunchpadFunctionalLayer
78+
79+from lp.testing import TestCaseWithFactory
80+
81+
82+class TestSourcePackageRelease(TestCaseWithFactory):
83+
84+ layer = LaunchpadFunctionalLayer
85+
86+ def test_uploader_no_uploader(self):
87+ spr = self.factory.makeSourcePackageRelease()
88+ self.assertIs(None, spr.uploader)
89+
90+ def test_uploader_dsc_package(self):
91+ owner = self.factory.makePerson()
92+ key = self.factory.makeGPGKey(owner)
93+ spr = self.factory.makeSourcePackageRelease(dscsigningkey=key)
94+ self.assertEqual(owner, spr.uploader)
95+
96+ def test_uploader_recipe(self):
97+ recipe_build = self.factory.makeSourcePackageRecipeBuild()
98+ recipe = recipe_build.recipe
99+ spr = self.factory.makeSourcePackageRelease(
100+ source_package_recipe_build=recipe_build)
101+ self.assertEqual(recipe_build.requester, spr.uploader)
102
103=== modified file 'lib/lp/testing/factory.py'
104--- lib/lp/testing/factory.py 2010-07-29 07:28:56 +0000
105+++ lib/lp/testing/factory.py 2010-07-29 23:12:50 +0000
106@@ -1051,7 +1051,8 @@
107 CodeReviewNotificationLevel.NOEMAIL, subscribed_by)
108
109 def makeDiff(self, diff_text=DIFF):
110- return ProxyFactory(Diff.fromFile(StringIO(diff_text), len(diff_text)))
111+ return ProxyFactory(
112+ Diff.fromFile(StringIO(diff_text), len(diff_text)))
113
114 def makePreviewDiff(self, conflicts=u''):
115 diff = self.makeDiff()
116@@ -2266,7 +2267,8 @@
117 dsc_standards_version='3.6.2',
118 dsc_format='1.0', dsc_binaries='foo-bin',
119 date_uploaded=UTC_NOW,
120- source_package_recipe_build=None):
121+ source_package_recipe_build=None,
122+ dscsigningkey=None):
123 """Make a `SourcePackageRelease`."""
124 if distroseries is None:
125 if source_package_recipe_build is not None:
126@@ -2325,7 +2327,7 @@
127 changelog_entry=None,
128 dsc=None,
129 copyright=self.getUniqueString(),
130- dscsigningkey=None,
131+ dscsigningkey=dscsigningkey,
132 dsc_maintainer_rfc822=maintainer_email,
133 dsc_standards_version=dsc_standards_version,
134 dsc_format=dsc_format,
135@@ -2766,8 +2768,10 @@
136 unwrapped_types = (
137 DSCFile, InstanceType, MergeDirective2, Message, datetime, int, str, unicode)
138
139+
140 def is_security_proxied_or_harmless(obj):
141- """Check that the given object is security wrapped or a harmless object."""
142+ """Check that the given object is security wrapped or a harmless object.
143+ """
144 if obj is None:
145 return True
146 if builtin_isinstance(obj, Proxy):
147@@ -2793,6 +2797,7 @@
148
149 Whereever you see such a warning: fix it!
150 """
151+
152 def __init__(self):
153 self._factory = BareLaunchpadObjectFactory()
154