Merge ~pappacena/launchpad:pending-builds-msg-fix into launchpad:master

Proposed by Thiago F. Pappacena
Status: Merged
Approved by: Colin Watson
Approved revision: e54b53897e2ade1c6c7a54034d00f2936a2f7b66
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~pappacena/launchpad:pending-builds-msg-fix
Merge into: launchpad:master
Diff against target: 77 lines (+43/-2)
2 files modified
lib/lp/soyuz/browser/tests/test_archive_packages.py (+37/-0)
lib/lp/soyuz/templates/archive-macros.pt (+6/-2)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+377010@code.launchpad.net

Commit message

Fixing singular message "A recent upload has resulted in 1 pending builds."

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) wrote :

This will work, but I'd like a slightly more idiomatic use of TAL, and it needs tests before it can be landed.

review: Needs Fixing
0015c19... by Thiago F. Pappacena

Merge branch 'pending-builds-msg-fix' of git+ssh://git.launchpad.net/~pappacena/launchpad into pending-builds-msg-fix

8ebb99f... by Thiago F. Pappacena

using macro for plural and adding tests

Revision history for this message
Colin Watson (cjwatson) wrote :

Mostly good, but let's make the test effective ...

review: Needs Fixing
e54b538... by Thiago F. Pappacena

fixing regex that tests pending builds message

Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/soyuz/browser/tests/test_archive_packages.py b/lib/lp/soyuz/browser/tests/test_archive_packages.py
2index c64ea8f..c199eec 100644
3--- a/lib/lp/soyuz/browser/tests/test_archive_packages.py
4+++ b/lib/lp/soyuz/browser/tests/test_archive_packages.py
5@@ -24,6 +24,7 @@ from zope.security.interfaces import Unauthorized
6 from zope.security.proxy import removeSecurityProxy
7
8 from lp.app.utilities.celebrities import ILaunchpadCelebrities
9+from lp.buildmaster.enums import BuildStatus
10 from lp.registry.interfaces.pocket import PackagePublishingPocket
11 from lp.services.beautifulsoup import BeautifulSoup4 as BeautifulSoup
12 from lp.services.webapp import canonical_url
13@@ -162,6 +163,42 @@ class TestPPAPackages(TestCaseWithFactory):
14 self.assertNotifications(
15 ppa, 'Publishing has been disabled for this archive.')
16
17+ def test_page_show_singular_pending_builds(self):
18+ ppa = self.factory.makeArchive()
19+ self.factory.makeBinaryPackageBuild(
20+ archive=ppa, status=BuildStatus.NEEDSBUILD)
21+ owner = login_person(ppa.owner)
22+ browser = self.getUserBrowser(
23+ canonical_url(ppa) + '/+packages', user=owner)
24+ html = browser.contents
25+ pending_build_exists = soupmatchers.HTMLContains(
26+ soupmatchers.Tag(
27+ 'pending build', 'p',
28+ text=re.compile(r'(?s).*(pending\s*build\.)')),
29+ )
30+ self.assertThat(
31+ html, pending_build_exists,
32+ 'Pending builds message was not found')
33+
34+ def test_page_show_plural_pending_builds(self):
35+ ppa = self.factory.makeArchive()
36+ self.factory.makeBinaryPackageBuild(
37+ archive=ppa, status=BuildStatus.NEEDSBUILD)
38+ self.factory.makeBinaryPackageBuild(
39+ archive=ppa, status=BuildStatus.NEEDSBUILD)
40+ owner = login_person(ppa.owner)
41+ browser = self.getUserBrowser(
42+ canonical_url(ppa) + '/+packages', user=owner)
43+ html = browser.contents
44+ pending_build_exists = soupmatchers.HTMLContains(
45+ soupmatchers.Tag(
46+ 'pending build', 'p',
47+ text=re.compile(r'(?s).*(pending\s*builds\.)')),
48+ )
49+ self.assertThat(
50+ html, pending_build_exists,
51+ 'Pending builds message was not found')
52+
53 def test_ppa_packages_menu_is_enabled(self):
54 joe = self.factory.makePerson()
55 ppa = self.factory.makeArchive()
56diff --git a/lib/lp/soyuz/templates/archive-macros.pt b/lib/lp/soyuz/templates/archive-macros.pt
57index 845eabf..7099c2f 100644
58--- a/lib/lp/soyuz/templates/archive-macros.pt
59+++ b/lib/lp/soyuz/templates/archive-macros.pt
60@@ -269,11 +269,15 @@ div.package-details {
61 failed</dd>
62 </dl>
63
64- <p tal:condition="view/build_counters/pending">
65+ <p tal:define="count view/build_counters/pending;
66+ singular string:build;
67+ plural string:builds"
68+ tal:condition="count">
69 A recent upload has resulted in
70 <span class="build-count pending"
71 tal:content="view/build_counters/pending">100</span>
72- pending builds.
73+ pending
74+ <metal:builds use-macro="context/@@+base-layout-macros/plural-message" />.
75 </p>
76 </div>
77 </metal:build_status_summary>