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
=== modified file 'lib/lp/soyuz/interfaces/sourcepackagerelease.py'
--- lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-03-20 23:16:42 +0000
+++ lib/lp/soyuz/interfaces/sourcepackagerelease.py 2010-07-29 23:12:50 +0000
@@ -137,6 +137,8 @@
137 "The `PackageUpload` record corresponding to original upload of "137 "The `PackageUpload` record corresponding to original upload of "
138 "this source package release. It's 'None' if it is a source "138 "this source package release. It's 'None' if it is a source "
139 "imported by Gina.")139 "imported by Gina.")
140 uploader = Attribute(
141 "The user who uploaded the package.")
140142
141 # Really ISourcePackageRecipeBuild -- see _schema_circular_imports.143 # Really ISourcePackageRecipeBuild -- see _schema_circular_imports.
142 source_package_recipe_build = Reference(144 source_package_recipe_build = Reference(
@@ -183,8 +185,8 @@
183185
184 :tarball_alias: is a Librarian alias that references to a tarball with186 :tarball_alias: is a Librarian alias that references to a tarball with
185 translations.187 translations.
186 :is_published: indicates if the imported files are already published by188 :is_published: indicates if the imported files are already published
187 upstream.189 by upstream.
188 :importer: is the person that did the import.190 :importer: is the person that did the import.
189191
190 raise DownloadFailed if we are not able to fetch the file from192 raise DownloadFailed if we are not able to fetch the file from
191193
=== modified file 'lib/lp/soyuz/model/sourcepackagerelease.py'
--- lib/lp/soyuz/model/sourcepackagerelease.py 2010-07-23 11:18:54 +0000
+++ lib/lp/soyuz/model/sourcepackagerelease.py 2010-07-29 23:12:50 +0000
@@ -147,7 +147,6 @@
147 package_diffs = SQLMultipleJoin(147 package_diffs = SQLMultipleJoin(
148 'PackageDiff', joinColumn='to_source', orderBy="-date_requested")148 'PackageDiff', joinColumn='to_source', orderBy="-date_requested")
149149
150
151 @property150 @property
152 def builds(self):151 def builds(self):
153 """See `ISourcePackageRelease`."""152 """See `ISourcePackageRelease`."""
@@ -521,6 +520,15 @@
521 return DecoratedResultSet(results, operator.itemgetter(0)).one()520 return DecoratedResultSet(results, operator.itemgetter(0)).one()
522521
523 @property522 @property
523 def uploader(self):
524 """See `ISourcePackageRelease`"""
525 if self.source_package_recipe_build is not None:
526 return self.source_package_recipe_build.requester
527 if self.dscsigningkey is not None:
528 return self.dscsigningkey.owner
529 return None
530
531 @property
524 def change_summary(self):532 def change_summary(self):
525 """See ISourcePackageRelease"""533 """See ISourcePackageRelease"""
526 # this regex is copied from apt-listchanges.py courtesy of MDZ534 # this regex is copied from apt-listchanges.py courtesy of MDZ
527535
=== modified file 'lib/lp/soyuz/templates/archive-index.pt'
--- lib/lp/soyuz/templates/archive-index.pt 2010-03-24 16:54:56 +0000
+++ lib/lp/soyuz/templates/archive-index.pt 2010-07-29 23:12:50 +0000
@@ -280,7 +280,7 @@
280 </tal:newer_version>280 </tal:newer_version>
281 </td>281 </td>
282 <td tal:define="spr publishing/sourcepackagerelease;282 <td tal:define="spr publishing/sourcepackagerelease;
283 signer spr/dscsigningkey/owner/fmt:link|string:no signer">283 signer spr/uploader/fmt:link|string:no signer">
284 <span tal:replace="structure signer">Joe Bloggs</span>284 <span tal:replace="structure signer">Joe Bloggs</span>
285 <tal:date_published285 <tal:date_published
286 condition="publishing/datepublished">286 condition="publishing/datepublished">
287287
=== added file 'lib/lp/soyuz/tests/test_sourcepackagerelease.py'
--- lib/lp/soyuz/tests/test_sourcepackagerelease.py 1970-01-01 00:00:00 +0000
+++ lib/lp/soyuz/tests/test_sourcepackagerelease.py 2010-07-29 23:12:50 +0000
@@ -0,0 +1,32 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Test SourcePackageRelease."""
5
6__metaclass__ = type
7
8from canonical.testing import LaunchpadFunctionalLayer
9
10from lp.testing import TestCaseWithFactory
11
12
13class TestSourcePackageRelease(TestCaseWithFactory):
14
15 layer = LaunchpadFunctionalLayer
16
17 def test_uploader_no_uploader(self):
18 spr = self.factory.makeSourcePackageRelease()
19 self.assertIs(None, spr.uploader)
20
21 def test_uploader_dsc_package(self):
22 owner = self.factory.makePerson()
23 key = self.factory.makeGPGKey(owner)
24 spr = self.factory.makeSourcePackageRelease(dscsigningkey=key)
25 self.assertEqual(owner, spr.uploader)
26
27 def test_uploader_recipe(self):
28 recipe_build = self.factory.makeSourcePackageRecipeBuild()
29 recipe = recipe_build.recipe
30 spr = self.factory.makeSourcePackageRelease(
31 source_package_recipe_build=recipe_build)
32 self.assertEqual(recipe_build.requester, spr.uploader)
033
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-07-29 07:28:56 +0000
+++ lib/lp/testing/factory.py 2010-07-29 23:12:50 +0000
@@ -1051,7 +1051,8 @@
1051 CodeReviewNotificationLevel.NOEMAIL, subscribed_by)1051 CodeReviewNotificationLevel.NOEMAIL, subscribed_by)
10521052
1053 def makeDiff(self, diff_text=DIFF):1053 def makeDiff(self, diff_text=DIFF):
1054 return ProxyFactory(Diff.fromFile(StringIO(diff_text), len(diff_text)))1054 return ProxyFactory(
1055 Diff.fromFile(StringIO(diff_text), len(diff_text)))
10551056
1056 def makePreviewDiff(self, conflicts=u''):1057 def makePreviewDiff(self, conflicts=u''):
1057 diff = self.makeDiff()1058 diff = self.makeDiff()
@@ -2266,7 +2267,8 @@
2266 dsc_standards_version='3.6.2',2267 dsc_standards_version='3.6.2',
2267 dsc_format='1.0', dsc_binaries='foo-bin',2268 dsc_format='1.0', dsc_binaries='foo-bin',
2268 date_uploaded=UTC_NOW,2269 date_uploaded=UTC_NOW,
2269 source_package_recipe_build=None):2270 source_package_recipe_build=None,
2271 dscsigningkey=None):
2270 """Make a `SourcePackageRelease`."""2272 """Make a `SourcePackageRelease`."""
2271 if distroseries is None:2273 if distroseries is None:
2272 if source_package_recipe_build is not None:2274 if source_package_recipe_build is not None:
@@ -2325,7 +2327,7 @@
2325 changelog_entry=None,2327 changelog_entry=None,
2326 dsc=None,2328 dsc=None,
2327 copyright=self.getUniqueString(),2329 copyright=self.getUniqueString(),
2328 dscsigningkey=None,2330 dscsigningkey=dscsigningkey,
2329 dsc_maintainer_rfc822=maintainer_email,2331 dsc_maintainer_rfc822=maintainer_email,
2330 dsc_standards_version=dsc_standards_version,2332 dsc_standards_version=dsc_standards_version,
2331 dsc_format=dsc_format,2333 dsc_format=dsc_format,
@@ -2766,8 +2768,10 @@
2766unwrapped_types = (2768unwrapped_types = (
2767 DSCFile, InstanceType, MergeDirective2, Message, datetime, int, str, unicode)2769 DSCFile, InstanceType, MergeDirective2, Message, datetime, int, str, unicode)
27682770
2771
2769def is_security_proxied_or_harmless(obj):2772def is_security_proxied_or_harmless(obj):
2770 """Check that the given object is security wrapped or a harmless object."""2773 """Check that the given object is security wrapped or a harmless object.
2774 """
2771 if obj is None:2775 if obj is None:
2772 return True2776 return True
2773 if builtin_isinstance(obj, Proxy):2777 if builtin_isinstance(obj, Proxy):
@@ -2793,6 +2797,7 @@
27932797
2794 Whereever you see such a warning: fix it!2798 Whereever you see such a warning: fix it!
2795 """2799 """
2800
2796 def __init__(self):2801 def __init__(self):
2797 self._factory = BareLaunchpadObjectFactory()2802 self._factory = BareLaunchpadObjectFactory()
27982803