Merge lp:~abentley/launchpad/remember-archive into lp:launchpad

Proposed by Aaron Bentley on 2010-05-18
Status: Merged
Merged at revision: 10922
Proposed branch: lp:~abentley/launchpad/remember-archive
Merge into: lp:launchpad
Diff against target: 80 lines (+28/-2)
4 files modified
lib/lp/code/browser/sourcepackagerecipe.py (+5/-1)
lib/lp/code/browser/tests/test_sourcepackagerecipe.py (+12/-1)
lib/lp/code/interfaces/sourcepackagerecipe.py (+3/-0)
lib/lp/code/model/sourcepackagerecipe.py (+8/-0)
To merge this branch: bzr merge lp:~abentley/launchpad/remember-archive
Reviewer Review Type Date Requested Status
Paul Hummer (community) code 2010-05-18 Approve on 2010-05-19
Review via email: mp+25564@code.launchpad.net

Commit Message

recipe build requests use last-built archive as default

Description of the Change

= Summary =
Fix bug #582489:source package recipe builds should remember last-used archive

== Proposed fix ==
See above

== Pre-implementation notes ==
Discussed with rockstar

== Implementation details ==
None

== Tests ==
bin/test -t test_request_builds_archive test_sourcepackagerecipe

== Demo and Q/A ==
Create a source package recipe, and request a build. (You'll also need at
least two PPAs.) The first archive should be selected. Choose a different
one. Request a new build. The previously-selected archive should now be
selected.

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  lib/lp/code/browser/sourcepackagerecipe.py
  lib/lp/code/model/sourcepackagerecipe.py
  lib/lp/code/browser/tests/test_sourcepackagerecipe.py
  lib/lp/code/interfaces/sourcepackagerecipe.py

== Pylint notices ==

(Bogus warning)

lib/lp/code/interfaces/sourcepackagerecipe.py
    150: [C0322, ISourcePackageRecipe.requestBuild] Operator not preceded by a space
    distroseries=Reference(schema=IDistroSeries),
    ^
    )
    @export_write_operation()
    def requestBuild(archive, distroseries, requester, pocket):

To post a comment you must log in.
Paul Hummer (rockstar) :
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/code/browser/sourcepackagerecipe.py'
2--- lib/lp/code/browser/sourcepackagerecipe.py 2010-05-07 20:01:34 +0000
3+++ lib/lp/code/browser/sourcepackagerecipe.py 2010-05-26 19:27:30 +0000
4@@ -191,7 +191,11 @@
5
6 The distroseries function as defaults for requesting a build.
7 """
8- return {'distros': self.context.distroseries}
9+ initial_values = {'distros': self.context.distroseries}
10+ build = self.context.getLastBuild()
11+ if build is not None:
12+ initial_values['archive'] = build.archive
13+ return initial_values
14
15 class schema(Interface):
16 """Schema for requesting a build."""
17
18=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipe.py'
19--- lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-05-20 03:10:49 +0000
20+++ lib/lp/code/browser/tests/test_sourcepackagerecipe.py 2010-05-26 19:27:30 +0000
21@@ -20,7 +20,8 @@
22 DatabaseFunctionalLayer, LaunchpadFunctionalLayer)
23 from lp.buildmaster.interfaces.buildbase import BuildStatus
24 from lp.code.browser.sourcepackagerecipe import (
25- SourcePackageRecipeView, SourcePackageRecipeBuildView
26+ SourcePackageRecipeView, SourcePackageRecipeRequestBuildsView,
27+ SourcePackageRecipeBuildView
28 )
29 from lp.code.interfaces.sourcepackagerecipe import MINIMAL_RECIPE_TEXT
30 from lp.soyuz.model.processor import ProcessorFamily
31@@ -329,6 +330,16 @@
32 # Secret Squirrel is checked by default.
33 self.assertEqual(['Secret Squirrel', 'Woody'], build_distros)
34
35+ def test_request_builds_archive(self):
36+ recipe = self.factory.makeSourcePackageRecipe()
37+ ppa2 = self.factory.makeArchive(
38+ displayname='Secret PPA', owner=self.chef, name='ppa2')
39+ view = SourcePackageRecipeRequestBuildsView(recipe, None)
40+ self.assertIs(None, view.initial_values.get('archive'))
41+ self.factory.makeSourcePackageRecipeBuild(recipe=recipe, archive=ppa2)
42+ self.assertEqual(ppa2, view.initial_values.get('archive'))
43+
44+
45
46 class TestSourcePackageRecipeBuildView(BrowserTestCase):
47 """Test behaviour of SourcePackageReciptBuildView."""
48
49=== modified file 'lib/lp/code/interfaces/sourcepackagerecipe.py'
50--- lib/lp/code/interfaces/sourcepackagerecipe.py 2010-05-14 20:27:23 +0000
51+++ lib/lp/code/interfaces/sourcepackagerecipe.py 2010-05-26 19:27:30 +0000
52@@ -168,6 +168,9 @@
53 False, select all builds that are not pending.
54 """
55
56+ def getLastBuild(self):
57+ """Return the the most recent build of this recipe."""
58+
59 def destroySelf():
60 """Remove this SourcePackageRecipe from the database.
61
62
63=== modified file 'lib/lp/code/model/sourcepackagerecipe.py'
64--- lib/lp/code/model/sourcepackagerecipe.py 2010-05-18 19:14:16 +0000
65+++ lib/lp/code/model/sourcepackagerecipe.py 2010-05-26 19:27:30 +0000
66@@ -177,6 +177,14 @@
67 result.order_by(Desc(SourcePackageRecipeBuild.datebuilt))
68 return result
69
70+ def getLastBuild(self):
71+ """See `ISourcePackageRecipeBuild`."""
72+ store = Store.of(self)
73+ result = store.find(
74+ SourcePackageRecipeBuild, SourcePackageRecipeBuild.recipe == self)
75+ result.order_by(Desc(SourcePackageRecipeBuild.datebuilt))
76+ return result.first()
77+
78 def getMedianBuildDuration(self):
79 """Return the median duration of builds of this recipe."""
80 store = IStore(self)