Merge lp:~blr/launchpad/golang-meta-import-buggy-productseries into lp:launchpad

Proposed by Kit Randel
Status: Merged
Merged at revision: 17607
Proposed branch: lp:~blr/launchpad/golang-meta-import-buggy-productseries
Merge into: lp:launchpad
Diff against target: 69 lines (+21/-11)
2 files modified
lib/lp/registry/browser/productseries.py (+1/-2)
lib/lp/registry/browser/tests/test_productseries_views.py (+20/-9)
To merge this branch: bzr merge lp:~blr/launchpad/golang-meta-import-buggy-productseries
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+263994@code.launchpad.net

Commit message

Render golang import only if series has default branch, not the series product's default.

To post a comment you must log in.
Revision history for this message
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/registry/browser/productseries.py'
2--- lib/lp/registry/browser/productseries.py 2015-07-06 00:00:55 +0000
3+++ lib/lp/registry/browser/productseries.py 2015-07-07 04:41:15 +0000
4@@ -386,8 +386,7 @@
5 """Meta string for golang remote import path.
6 See: https://golang.org/cmd/go/#hdr-Remote_import_paths
7 """
8- if (self.context.product.vcs == VCSType.BZR and
9- self.context.product.development_focus.branch):
10+ if self.context.product.vcs == VCSType.BZR and self.context.branch:
11 return (
12 "{hostname}/{product}/{series} bzr {root_url}{branch}").format(
13 hostname=config.vhost.mainsite.hostname,
14
15=== modified file 'lib/lp/registry/browser/tests/test_productseries_views.py'
16--- lib/lp/registry/browser/tests/test_productseries_views.py 2015-07-06 00:00:55 +0000
17+++ lib/lp/registry/browser/tests/test_productseries_views.py 2015-07-07 04:41:15 +0000
18@@ -35,20 +35,21 @@
19
20 def test_golang_meta_renders(self):
21 # ensure golang meta import path is rendered if project has
22- # bzr default vcs.
23+ # bzr default vcs and default branch set.
24 # See: https://golang.org/cmd/go/#hdr-Remote_import_paths
25 owner = self.factory.makePerson(name='zardoz')
26 product = self.factory.makeProduct(name='wapcaplet')
27+ series = self.factory.makeProductSeries(owner=owner, product=product,
28+ name='a-series')
29 branch = self.factory.makeBranch(product=product, name='a-branch',
30 owner=owner)
31- view = create_initialized_view(branch.product.development_focus,
32- '+index')
33- with person_logged_in(branch.product.owner):
34- branch.product.development_focus.branch = branch
35- branch.product.vcs = VCSType.BZR
36+ view = create_initialized_view(series, '+index')
37+ with person_logged_in(series.product.owner):
38+ series.branch = branch
39+ series.product.vcs = VCSType.BZR
40
41 golang_import = (
42- "{hostname}/wapcaplet/trunk bzr "
43+ "{hostname}/wapcaplet/a-series bzr "
44 "{root_url}~zardoz/wapcaplet/a-branch").format(
45 hostname=config.vhost.mainsite.hostname,
46 root_url=allvhosts.configs['mainsite'].rooturl,
47@@ -57,10 +58,20 @@
48 meta_tag = soupmatchers.Tag('go-import-meta', 'meta',
49 attrs={'name': 'go-import',
50 'content': golang_import})
51- browser = self.getViewBrowser(branch.product.development_focus,
52- '+index', user=branch.owner)
53+ browser = self.getViewBrowser(series, '+index',
54+ user=series.branch.owner)
55 self.assertThat(browser.contents, soupmatchers.HTMLContains(meta_tag))
56
57+ def test_golang_meta_no_default_branch(self):
58+ # ensure golang meta import path is not rendered if series has
59+ # no default branch.
60+ series = self.factory.makeProductSeries()
61+ view = create_initialized_view(series, '+index')
62+ with person_logged_in(series.product.owner):
63+ series.product.vcs = VCSType.BZR
64+
65+ self.assertEqual(None, view.golang_import_spec)
66+
67 def test_information_type_public(self):
68 # A ProductSeries view should include its information_type,
69 # which defaults to Public for new projects.