← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~xnox/launchpad:snap-request-builds-mimick-auto into launchpad:master

 

Dimitri John Ledkov has proposed merging ~xnox/launchpad:snap-request-builds-mimick-auto into launchpad:master.

Commit message:
snappy: Make requestbuild use auto-build archive and pocket defaults

Make request snap builds page for a snap, reuse auto-build archive & pocket, if set on the snap.

Proof of concept untested code, no tests added.

LP: #2028687

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #2028687 in Launchpad itself: "+requestbuilds and auto_builds are different by default"
  https://bugs.launchpad.net/launchpad/+bug/2028687

For more details, see:
https://code.launchpad.net/~xnox/launchpad/+git/launchpad/+merge/447665
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~xnox/launchpad:snap-request-builds-mimick-auto into launchpad:master.
diff --git a/lib/lp/snappy/browser/snap.py b/lib/lp/snappy/browser/snap.py
index b783dcd..96b7656 100644
--- a/lib/lp/snappy/browser/snap.py
+++ b/lib/lp/snappy/browser/snap.py
@@ -474,7 +474,8 @@ class SnapRequestBuildsView(LaunchpadFormView):
     def initial_values(self):
         """See `LaunchpadFormView`."""
         return {
-            "archive": (
+            "archive": self.context.auto_build_archive
+            or (
                 # XXX cjwatson 2019-02-04: In order to support non-Ubuntu
                 # bases, we'd need to store this as None and infer it based
                 # on the inferred distro series; but this will do for now.
@@ -483,7 +484,8 @@ class SnapRequestBuildsView(LaunchpadFormView):
                 else self.context.distro_series.main_archive
             ),
             "distro_arch_series": [],
-            "pocket": PackagePublishingPocket.UPDATES,
+            "pocket": self.context.auto_build_pocket
+            or PackagePublishingPocket.UPDATES,
             "channels": self.context.auto_build_channels,
         }
 
diff --git a/lib/lp/snappy/browser/tests/test_snap.py b/lib/lp/snappy/browser/tests/test_snap.py
index 2de0693..3b11e7c 100644
--- a/lib/lp/snappy/browser/tests/test_snap.py
+++ b/lib/lp/snappy/browser/tests/test_snap.py
@@ -2800,6 +2800,45 @@ class TestSnapRequestBuildsView(BaseTestSnapView):
             ),
         )
 
+    def test_request_builds_with_autobuild_archive(self):
+        # Ensure that auto_build_archive is used as default for builds
+        ppa = self.factory.makeArchive(
+            distribution=self.ubuntu, owner=self.person, name="snap-ppa"
+        )
+        login_person(self.person)
+        self.snap.auto_build_archive = ppa
+        browser = self.getViewBrowser(
+            self.snap, "+request-builds", user=self.person
+        )
+        browser.getControl("Request builds").click()
+
+        login_person(self.person)
+        [request] = self.snap.pending_build_requests
+        self.assertThat(
+            request,
+            MatchesStructure(
+                archive=Equals(ppa),
+            ),
+        )
+
+    def test_request_builds_with_autobuild_pocket(self):
+        # Ensure that auto_build_pocket is used as default for builds
+        login_person(self.person)
+        self.snap.auto_build_pocket = PackagePublishingPocket.SECURITY
+        browser = self.getViewBrowser(
+            self.snap, "+request-builds", user=self.person
+        )
+        browser.getControl("Request builds").click()
+
+        login_person(self.person)
+        [request] = self.snap.pending_build_requests
+        self.assertThat(
+            request,
+            MatchesStructure(
+                pocket=Equals(PackagePublishingPocket.SECURITY),
+            ),
+        )
+
     def test_request_builds_no_architectures_action(self):
         # Requesting a build with no architectures selected creates a
         # pending build request.

Follow ups