Merge lp:~rockstar/launchpad/clean-code-windmill-tests into lp:launchpad

Proposed by Paul Hummer on 2010-01-14
Status: Merged
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/clean-code-windmill-tests
Merge into: lp:launchpad
Prerequisite: lp:~rockstar/launchpad/fix-windmill-canonicalurl
Diff against target: 298 lines (+75/-94)
7 files modified
lib/lp/bugs/feed/bug.py (+1/-1)
lib/lp/code/browser/summary.py (+1/-1)
lib/lp/code/windmill/tests/test_branch_bugspeclinks.py (+4/-3)
lib/lp/code/windmill/tests/test_branch_status.py (+3/-2)
lib/lp/code/windmill/tests/test_branch_subscriptions.py (+2/-4)
lib/lp/code/windmill/tests/test_branchmergeproposal_review.py (+64/-5)
lib/lp/code/windmill/tests/test_merge_proposal_commenting.py (+0/-78)
To merge this branch: bzr merge lp:~rockstar/launchpad/clean-code-windmill-tests
Reviewer Review Type Date Requested Status
Tim Penhey (community) 2010-01-14 Approve on 2010-01-14
Review via email: mp+17360@code.launchpad.net
To post a comment you must log in.
Paul Hummer (rockstar) wrote :

Hi there-

  This branch just cleans up the code windmill tests. They were starting to
get out of hand. Deryck and I talked about ways to organize windmill tests
while in Dallas, and this is what I've come up with based on what we talked
about. I figured I'd do this now, since it was trivial, so that the code
windmill tests didn't get out of hand and dis-organized (like pagetests often
do). There were no real code changes, just renames and consolidations of
files, and updating docstrings.

  As well, I noticed some import violations which I took the liberty of fixing.
Nothing major, just some import changes.

Cheers,
Paul

Tim Penhey (thumper) wrote :

Fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/feed/bug.py'
2--- lib/lp/bugs/feed/bug.py 2010-01-12 21:12:12 +0000
3+++ lib/lp/bugs/feed/bug.py 2010-01-15 03:36:20 +0000
4@@ -24,11 +24,11 @@
5 BugsBugTaskSearchListingView, BugTargetView)
6 from lp.registry.browser.person import (
7 PersonRelatedBugTaskSearchListingView)
8-from lp.registry.interfaces.person import IPerson
9 from lp.bugs.interfaces.bug import IBug, IBugSet
10 from lp.bugs.interfaces.bugtarget import IHasBugs
11 from lp.bugs.interfaces.bugtask import IBugTaskSet
12 from lp.bugs.interfaces.malone import IMaloneApplication
13+from lp.registry.interfaces.person import IPerson
14 from canonical.lazr.feed import (
15 FeedBase, FeedEntry, FeedPerson, FeedTypedData, MINUTES)
16
17
18=== modified file 'lib/lp/code/browser/summary.py'
19--- lib/lp/code/browser/summary.py 2010-01-12 20:56:18 +0000
20+++ lib/lp/code/browser/summary.py 2010-01-15 03:36:20 +0000
21@@ -13,10 +13,10 @@
22 from canonical.launchpad import _
23 from canonical.launchpad.webapp.publisher import LaunchpadView
24
25-from lp.services.browser_helpers import get_plural_text
26 from lp.code.interfaces.branch import DEFAULT_BRANCH_STATUS_IN_LISTING
27 from lp.code.interfaces.branchcollection import IBranchCollection
28 from lp.code.interfaces.revisioncache import IRevisionCache
29+from lp.services.browser_helpers import get_plural_text
30
31
32 class BranchCountSummaryView(LaunchpadView):
33
34=== renamed file 'lib/lp/code/windmill/tests/test_branch_links.py' => 'lib/lp/code/windmill/tests/test_branch_bugspeclinks.py'
35--- lib/lp/code/windmill/tests/test_branch_links.py 2010-01-13 02:26:05 +0000
36+++ lib/lp/code/windmill/tests/test_branch_bugspeclinks.py 2010-01-15 03:36:20 +0000
37@@ -1,7 +1,7 @@
38 # Copyright 2009 Canonical Ltd. This software is licensed under the
39 # GNU Affero General Public License version 3 (see the file LICENSE).
40
41-"""Test for branch links."""
42+"""Test for links between branches and bugs or specs."""
43
44 __metaclass__ = type
45 __all__ = []
46@@ -16,7 +16,8 @@
47 from lp.testing import TestCaseWithFactory
48
49
50-class TestBranchLinks(TestCaseWithFactory):
51+class TestBranchBugLinks(TestCaseWithFactory):
52+ """Test the links between branches and bugs."""
53
54 layer = CodeWindmillLayer
55
56@@ -36,7 +37,7 @@
57 client.asserts.assertNotNode(id=u'buglink-' + bug)
58
59 def test_inline_branch_bug_link_unlink(self):
60- """Test branch bug links."""
61+ """Link a bug from the branch page."""
62 client = WindmillTestClient("Branch bug links")
63
64 lpuser.FOO_BAR.ensure_login(client)
65
66=== renamed file 'lib/lp/code/windmill/tests/test_popup_diff.py' => 'lib/lp/code/windmill/tests/test_branch_popupdiff.py'
67=== renamed file 'lib/lp/code/windmill/tests/test_branch_index.py' => 'lib/lp/code/windmill/tests/test_branch_status.py'
68--- lib/lp/code/windmill/tests/test_branch_index.py 2010-01-12 23:42:50 +0000
69+++ lib/lp/code/windmill/tests/test_branch_status.py 2010-01-15 03:36:20 +0000
70@@ -1,7 +1,7 @@
71 # Copyright 2009 Canonical Ltd. This software is licensed under the
72 # GNU Affero General Public License version 3 (see the file LICENSE).
73
74-"""Test for the main branch page."""
75+"""Tests for branch statuses."""
76
77 __metaclass__ = type
78 __all__ = []
79@@ -20,11 +20,12 @@
80
81
82 class TestBranchStatus(TestCaseWithFactory):
83+ """Test setting branch status."""
84
85 layer = CodeWindmillLayer
86
87 def test_inline_branch_status_setting(self):
88- """Test branch bug links."""
89+ """Set the status of a branch."""
90 eric = self.factory.makePerson(
91 name="eric", displayname="Eric the Viking", password="test",
92 email="eric@example.com")
93
94=== modified file 'lib/lp/code/windmill/tests/test_branch_subscriptions.py'
95--- lib/lp/code/windmill/tests/test_branch_subscriptions.py 2010-01-12 23:42:50 +0000
96+++ lib/lp/code/windmill/tests/test_branch_subscriptions.py 2010-01-15 03:36:20 +0000
97@@ -23,8 +23,7 @@
98 layer = CodeWindmillLayer
99
100 def test_branch_subscription_ajax_load(self):
101- """Test branch subscriptions loaded via ajax.
102- """
103+ """Subscribe to a branch from the branch page."""
104
105 client = WindmillTestClient("Branch Subscription Ajax Load Test")
106
107@@ -60,8 +59,7 @@
108 validator=u'No subscribers.')
109
110 def test_team_edit_subscription_ajax_load(self):
111- """Test that team subscriptions are editable through the ajax portlet.
112- """
113+ """Unsubscribe a team from the branch."""
114
115 client = WindmillTestClient("Branch Subscription Ajax Load Test")
116
117
118=== renamed file 'lib/lp/code/windmill/tests/test_branch_merge_proposal.py' => 'lib/lp/code/windmill/tests/test_branchmergeproposal_commitmessage.py'
119=== renamed file 'lib/lp/code/windmill/tests/test_code_review.py' => 'lib/lp/code/windmill/tests/test_branchmergeproposal_review.py'
120--- lib/lp/code/windmill/tests/test_code_review.py 2010-01-13 01:55:29 +0000
121+++ lib/lp/code/windmill/tests/test_branchmergeproposal_review.py 2010-01-15 03:36:20 +0000
122@@ -7,23 +7,32 @@
123
124 import unittest
125
126+import transaction
127 import windmill
128 from windmill.authoring import WindmillTestClient
129
130+from canonical.launchpad.webapp import canonical_url
131 from canonical.launchpad.windmill.testing import lpuser
132 from canonical.launchpad.windmill.testing.widgets import (
133 search_and_select_picker_widget)
134+from canonical.uuid import generate_uuid
135 from lp.code.windmill.testing import CodeWindmillLayer
136-from lp.testing import TestCaseWithFactory
137-
138-
139-class TestCodeReview(TestCaseWithFactory):
140+from lp.testing import login_person, TestCaseWithFactory
141+
142+WAIT_PAGELOAD = u'30000'
143+WAIT_ELEMENT_COMPLETE = u'30000'
144+WAIT_CHECK_CHANGE = u'1000'
145+ADD_COMMENT_BUTTON = (
146+ u'//input[@id="field.actions.add" and @class="button js-action"]')
147+
148+
149+class TestRequestReview(TestCaseWithFactory):
150 """Test the javascript functions of code review."""
151
152 layer = CodeWindmillLayer
153
154 def test_inline_request_a_reviewer(self):
155- """Test inline request a reviewer."""
156+ """Request a review."""
157
158 client = WindmillTestClient("Code review")
159
160@@ -48,5 +57,55 @@
161 client.waits.forElement(id=u'review-mark', timeout=u'10000')
162
163
164+class TestReviewCommenting(TestCaseWithFactory):
165+ """Test commenting and reviewing on a merge proposal."""
166+
167+ layer = CodeWindmillLayer
168+
169+ def open_proposal_page(self, client, proposal):
170+ transaction.commit()
171+ client.open(url=canonical_url(proposal))
172+ client.waits.forPageLoad(timeout=WAIT_PAGELOAD)
173+
174+ def test_merge_proposal_commenting(self):
175+ """Comment on a merge proposal."""
176+ client = WindmillTestClient('Code review commenting')
177+ lpuser.NO_PRIV.ensure_login(client)
178+
179+ proposal = self.factory.makeBranchMergeProposal()
180+ self.open_proposal_page(client, proposal)
181+ client.waits.forElement(xpath=ADD_COMMENT_BUTTON)
182+ # Generate a unique piece of text, so we can run the test multiple
183+ # times, without resetting the db.
184+ new_comment_text = generate_uuid()
185+ client.type(text=new_comment_text, id="field.comment")
186+ client.click(xpath=ADD_COMMENT_BUTTON)
187+ # A PRE inside a boardCommentBody, itself somewhere in the
188+ # #conversation
189+ client.waits.forElement(
190+ xpath='//div[@id="conversation"]//div[@class="boardCommentBody"]'
191+ '/pre[contains(., "%s")]' % new_comment_text)
192+
193+ def test_merge_proposal_replying(self):
194+ """Reply to a review comment."""
195+ client = WindmillTestClient('Code review commenting')
196+ lpuser.NO_PRIV.ensure_login(client)
197+ proposal = self.factory.makeBranchMergeProposal()
198+ login_person(proposal.registrant)
199+ proposal.createComment(proposal.registrant, 'hello', 'content')
200+ self.open_proposal_page(client, proposal)
201+ REPLY_LINK_XPATH = '//a[contains(., "Reply")]'
202+ client.waits.forElement(xpath=REPLY_LINK_XPATH)
203+ client.click(xpath=REPLY_LINK_XPATH)
204+ client.waits.sleep(milliseconds=10)
205+ client.asserts.assertValue(id="field.comment", validator="> content")
206+ new_comment_text = "My reply"
207+ client.type(text=new_comment_text, id="field.comment")
208+ client.click(xpath=ADD_COMMENT_BUTTON)
209+ client.waits.forElement(
210+ xpath='//div[@id="conversation"]//div[@class="boardCommentBody"]'
211+ '/pre[contains(., "%s")]' % new_comment_text)
212+
213+
214 def test_suite():
215 return unittest.TestLoader().loadTestsFromName(__name__)
216
217=== removed file 'lib/lp/code/windmill/tests/test_merge_proposal_commenting.py'
218--- lib/lp/code/windmill/tests/test_merge_proposal_commenting.py 2010-01-13 22:59:12 +0000
219+++ lib/lp/code/windmill/tests/test_merge_proposal_commenting.py 1970-01-01 00:00:00 +0000
220@@ -1,78 +0,0 @@
221-# Copyright 2009 Canonical Ltd. This software is licensed under the
222-# GNU Affero General Public License version 3 (see the file LICENSE).
223-
224-"""Test for the inline commenting UI."""
225-
226-__metaclass__ = type
227-__all__ = []
228-
229-import unittest
230-
231-import transaction
232-from windmill.authoring import WindmillTestClient
233-
234-from canonical.launchpad.webapp import canonical_url
235-from canonical.launchpad.windmill.testing import lpuser
236-from canonical.uuid import generate_uuid
237-from lp.code.windmill.testing import CodeWindmillLayer
238-from lp.testing import login_person, TestCaseWithFactory
239-
240-WAIT_PAGELOAD = u'30000'
241-WAIT_ELEMENT_COMPLETE = u'30000'
242-WAIT_CHECK_CHANGE = u'1000'
243-ADD_COMMENT_BUTTON = (
244- u'//input[@id="field.actions.add" and @class="button js-action"]')
245-
246-
247-class TestMergeProposalCommenting(TestCaseWithFactory):
248-
249- layer = CodeWindmillLayer
250-
251-
252- def open_proposal_page(self, client, proposal):
253- transaction.commit()
254- client.open(url=canonical_url(proposal))
255- client.waits.forPageLoad(timeout=WAIT_PAGELOAD)
256-
257- def test_merge_proposal_commenting(self):
258- """Test commenting on merge proposals."""
259- client = WindmillTestClient('Code review commenting')
260- lpuser.NO_PRIV.ensure_login(client)
261-
262- proposal = self.factory.makeBranchMergeProposal()
263- self.open_proposal_page(client, proposal)
264- client.waits.forElement(xpath=ADD_COMMENT_BUTTON)
265- # Generate a unique piece of text, so we can run the test multiple
266- # times, without resetting the db.
267- new_comment_text = generate_uuid()
268- client.type(text=new_comment_text, id="field.comment")
269- client.click(xpath=ADD_COMMENT_BUTTON)
270- # A PRE inside a boardCommentBody, itself somewhere in the
271- # #conversation
272- client.waits.forElement(
273- xpath='//div[@id="conversation"]//div[@class="boardCommentBody"]'
274- '/pre[contains(., "%s")]' % new_comment_text)
275-
276- def test_merge_proposal_replying(self):
277- """Replying to code review comments works."""
278- client = WindmillTestClient('Code review commenting')
279- lpuser.NO_PRIV.ensure_login(client)
280- proposal = self.factory.makeBranchMergeProposal()
281- login_person(proposal.registrant)
282- proposal.createComment(proposal.registrant, 'hello', 'content')
283- self.open_proposal_page(client, proposal)
284- REPLY_LINK_XPATH = '//a[contains(., "Reply")]'
285- client.waits.forElement(xpath=REPLY_LINK_XPATH)
286- client.click(xpath=REPLY_LINK_XPATH)
287- client.waits.sleep(milliseconds=10)
288- client.asserts.assertValue(id="field.comment", validator="> content")
289- new_comment_text = "My reply"
290- client.type(text=new_comment_text, id="field.comment")
291- client.click(xpath=ADD_COMMENT_BUTTON)
292- client.waits.forElement(
293- xpath='//div[@id="conversation"]//div[@class="boardCommentBody"]'
294- '/pre[contains(., "%s")]' % new_comment_text)
295-
296-
297-def test_suite():
298- return unittest.TestLoader().loadTestsFromName(__name__)