Merge lp:~cjwatson/launchpad/snap-build-title-store-name into lp:launchpad

Proposed by Colin Watson on 2018-10-04
Status: Merged
Merged at revision: 18788
Proposed branch: lp:~cjwatson/launchpad/snap-build-title-store-name
Merge into: lp:launchpad
Diff against target: 56 lines (+32/-3)
2 files modified
lib/lp/snappy/model/snapbuild.py (+7/-3)
lib/lp/snappy/tests/test_snapbuild.py (+25/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/snap-build-title-store-name
Reviewer Review Type Date Requested Status
William Grant code 2018-10-04 Approve on 2018-10-05
Review via email: mp+356134@code.launchpad.net

Commit message

Include Snap.store_name in SnapBuild.title if it differs from Snap.name.

Description of the change

This makes /builders more informative: in particular, build.snapcraft.io-generated snaps have opaque names, but their store_names are useful.

To post a comment you must log in.
William Grant (wgrant) :
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/snappy/model/snapbuild.py'
2--- lib/lp/snappy/model/snapbuild.py 2018-08-03 13:53:20 +0000
3+++ lib/lp/snappy/model/snapbuild.py 2018-10-04 13:17:41 +0000
4@@ -212,9 +212,13 @@
5 @property
6 def title(self):
7 das = self.distro_arch_series
8- name = self.snap.name
9- return "%s build of %s snap package in %s %s" % (
10- das.architecturetag, name, das.distroseries.distribution.name,
11+ snap_title = "%s snap package" % self.snap.name
12+ if (self.snap.store_name is not None and
13+ self.snap.store_name != self.snap.name):
14+ snap_title += " (%s)" % self.snap.store_name
15+ return "%s build of %s in %s %s" % (
16+ das.architecturetag, snap_title,
17+ das.distroseries.distribution.name,
18 das.distroseries.getSuite(self.pocket))
19
20 @property
21
22=== modified file 'lib/lp/snappy/tests/test_snapbuild.py'
23--- lib/lp/snappy/tests/test_snapbuild.py 2018-08-03 13:53:20 +0000
24+++ lib/lp/snappy/tests/test_snapbuild.py 2018-10-04 13:17:41 +0000
25@@ -100,6 +100,31 @@
26 self.assertProvides(self.build, IPackageBuild)
27 self.assertProvides(self.build, ISnapBuild)
28
29+ def test_title(self):
30+ # SnapBuild has an informative title.
31+ das = self.build.distro_arch_series
32+ self.assertIsNone(self.build.snap.store_name)
33+ self.assertEqual(
34+ "%s build of %s snap package in %s %s" % (
35+ das.architecturetag, self.build.snap.name,
36+ das.distroseries.distribution.name,
37+ das.distroseries.getSuite(self.build.pocket)),
38+ self.build.title)
39+ self.build.snap.store_name = self.build.snap.name
40+ self.assertEqual(
41+ "%s build of %s snap package in %s %s" % (
42+ das.architecturetag, self.build.snap.name,
43+ das.distroseries.distribution.name,
44+ das.distroseries.getSuite(self.build.pocket)),
45+ self.build.title)
46+ self.build.snap.store_name = self.factory.getUniqueUnicode()
47+ self.assertEqual(
48+ "%s build of %s snap package (%s) in %s %s" % (
49+ das.architecturetag, self.build.snap.name,
50+ self.build.snap.store_name, das.distroseries.distribution.name,
51+ das.distroseries.getSuite(self.build.pocket)),
52+ self.build.title)
53+
54 def test_queueBuild(self):
55 # SnapBuild can create the queue entry for itself.
56 bq = self.build.queueBuild()