Merge lp:~salgado/launchpad/bug-515494 into lp:launchpad/db-devel

Proposed by Guilherme Salgado
Status: Merged
Merged at revision: not available
Proposed branch: lp:~salgado/launchpad/bug-515494
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~salgado/launchpad/bug-482235
Diff against target: 1469 lines (+215/-247)
38 files modified
lib/canonical/launchpad/windmill/testing/lpuser.py (+0/-2)
lib/canonical/twistedsupport/task.py (+2/-5)
lib/canonical/twistedsupport/tests/test_task.py (+7/-14)
lib/lp/bugs/windmill/tests/test_bug_also_affects_new_upstream.py (+4/-5)
lib/lp/bugs/windmill/tests/test_bug_commenting.py (+4/-5)
lib/lp/bugs/windmill/tests/test_bug_inline_subscriber.py (+4/-5)
lib/lp/bugs/windmill/tests/test_bug_me_too.py (+5/-4)
lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py (+4/-5)
lib/lp/bugs/windmill/tests/test_bug_tags_entry.py (+4/-5)
lib/lp/bugs/windmill/tests/test_filebug_dupe_finder.py (+4/-5)
lib/lp/bugs/windmill/tests/test_filebug_extra_options.py (+6/-7)
lib/lp/bugs/windmill/tests/test_mark_duplicate.py (+4/-5)
lib/lp/bugs/windmill/tests/test_official_bug_tags_management.py (+6/-7)
lib/lp/code/windmill/tests/test_branch_bugspeclinks.py (+6/-6)
lib/lp/code/windmill/tests/test_branch_popupdiff.py (+8/-7)
lib/lp/code/windmill/tests/test_branch_status.py (+6/-6)
lib/lp/code/windmill/tests/test_branch_subscriptions.py (+8/-8)
lib/lp/code/windmill/tests/test_branchmergeproposal_commitmessage.py (+7/-7)
lib/lp/code/windmill/tests/test_branchmergeproposal_review.py (+9/-8)
lib/lp/registry/windmill/tests/test_add_milestone.py (+3/-8)
lib/lp/registry/windmill/tests/test_datetime_picker.py (+5/-10)
lib/lp/registry/windmill/tests/test_person_picker.py (+5/-10)
lib/lp/registry/windmill/tests/test_plusnew_step1.py (+3/-8)
lib/lp/registry/windmill/tests/test_plusnew_step2.py (+5/-10)
lib/lp/registry/windmill/tests/test_product.py (+2/-2)
lib/lp/registry/windmill/tests/test_product_edit_people.py (+2/-2)
lib/lp/registry/windmill/tests/test_project_licenses.py (+5/-10)
lib/lp/registry/windmill/tests/test_team_index.py (+5/-10)
lib/lp/registry/windmill/tests/test_timeline_graph.py (+5/-10)
lib/lp/services/job/runner.py (+5/-1)
lib/lp/services/job/tests/test_runner.py (+20/-14)
lib/lp/soyuz/windmill/tests/test_archivesubscribersindex.py (+4/-5)
lib/lp/testing/__init__.py (+24/-0)
lib/lp/translations/windmill/tests/disabled_test_productseries_templates.py (+4/-5)
lib/lp/translations/windmill/tests/test_documentation_links.py (+4/-5)
lib/lp/translations/windmill/tests/test_import_queue.py (+8/-7)
lib/lp/translations/windmill/tests/test_languages.py (+4/-5)
lib/lp/translations/windmill/tests/test_serieslanguages.py (+4/-9)
To merge this branch: bzr merge lp:~salgado/launchpad/bug-515494
Reviewer Review Type Date Requested Status
Māris Fogels (community) Approve
Review via email: mp+18401@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guilherme Salgado (salgado) wrote :

New TestCase class (WindmillTestCase) for windmill tests, followed by an update to existing tests to make use of the new class

Revision history for this message
Māris Fogels (mars) wrote :

Hi Salgado,

This is an excellent refactoring! Thanks for doing it.

I have one suggestion for a comment, listed below. With that, r=mars.

@@ -535,6 +538,21 @@
             self.addCleanup(hosted_server.tearDown)

+class WindmillTestCase(TestCaseWithFactory):
+ """A TestCase class for Windmill tests.
+
+ It provides a WindmillTestClient (self.client) with Launchpad's front
+ page loaded.
+ """
+
+ suite_name = ''
+
+ def setUp(self):
+ TestCaseWithFactory.setUp(self)
+ self.client = WindmillTestClient(self.suite_name)
+ self.client.open('http://launchpad.dev:8085')

I think you need a comment before this line explaining why we need to open a new page using the browser. People hate waiting for pages to load, and some future dev may kill this line in the name of performance without realizing its true purpose.

Maris

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/windmill/testing/lpuser.py'
2--- lib/canonical/launchpad/windmill/testing/lpuser.py 2010-02-02 11:39:22 +0000
3+++ lib/canonical/launchpad/windmill/testing/lpuser.py 2009-10-27 13:01:29 +0000
4@@ -19,8 +19,6 @@
5
6 def ensure_login(self, client):
7 """Ensure that this user is logged on the page under windmill."""
8- # Refresh the page to make sure we're not fooled by a stale one.
9- client.refresh()
10 client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
11 result = client.asserts.assertNode(
12 name=u'loginpage_submit_login', assertion=False)
13
14=== modified file 'lib/canonical/twistedsupport/task.py'
15--- lib/canonical/twistedsupport/task.py 2009-11-11 07:13:52 +0000
16+++ lib/canonical/twistedsupport/task.py 2010-02-02 11:39:24 +0000
17@@ -1,5 +1,6 @@
18 # Copyright 2009 Canonical Ltd. This software is licensed under the
19 # GNU Affero General Public License version 3 (see the file LICENSE).
20+# pylint: disable-msg=E0211,E0213
21
22 """Tools for managing long-running or difficult tasks with Twisted."""
23
24@@ -350,13 +351,9 @@
25 self._log_state('_taskEnded')
26 self._worker_count -= 1
27 self._log_state('_taskEnded', 'Decremented')
28- if self._worker_count == 0:
29- self._log_state('_taskEnded', 'No workers, stopping.')
30- self._stop()
31- elif self._worker_count < self._worker_limit:
32+ if self._worker_count < self._worker_limit:
33 self._log_state('_taskEnded', 'Too few workers, asking for more.')
34 self._task_source.start(self)
35 else:
36 # We're over the worker limit, nothing we can do.
37 self._log_state('_taskEnded', 'Hit limit, doing nothing.')
38- pass
39
40=== modified file 'lib/canonical/twistedsupport/tests/test_task.py'
41--- lib/canonical/twistedsupport/tests/test_task.py 2009-08-07 00:33:44 +0000
42+++ lib/canonical/twistedsupport/tests/test_task.py 2010-02-02 11:39:24 +0000
43@@ -1,5 +1,6 @@
44 # Copyright 2009 Canonical Ltd. This software is licensed under the
45 # GNU Affero General Public License version 3 (see the file LICENSE).
46+# pylint: disable-msg=E0211,E0213
47
48 """Tests for our task support."""
49
50@@ -358,7 +359,7 @@
51 class LoggingConsumer:
52 def __init__(self):
53 self._task_production_failed_calls = []
54- def taskStarted(slf, task):
55+ def taskStarted(self, task):
56 self.fail("taskStarted should not be called.")
57 def taskProductionFailed(self, reason):
58 self._task_production_failed_calls.append(reason)
59@@ -448,16 +449,6 @@
60 d.addCallback(log.append)
61 self.assertEqual([], log)
62
63- def test_consumer_finishes_when_tasks_done(self):
64- # `consume` returns a Deferred that fires when no more tasks are
65- # running.
66- consumer = self.makeConsumer()
67- task_log = []
68- d = consumer.consume(LoggingSource([]))
69- d.addCallback(task_log.append)
70- consumer.taskStarted(lambda: None)
71- self.assertEqual([None], task_log)
72-
73 def test_consumer_finishes_if_no_tasks_found(self):
74 # `consume` returns a Deferred that fires if no tasks are found when
75 # no tasks are running.
76@@ -519,15 +510,17 @@
77 consumer.noTasksFound()
78 self.assertEqual(0, log.count('stop'))
79
80- def test_source_stopped_when_tasks_done(self):
81- # When no more tasks are running, we stop the task source.
82+ def test_source_started_when_all_tasks_done(self):
83+ # When no more tasks are running, we start the task source so it has
84+ # one more chance to give us work.
85 consumer = self.makeConsumer()
86 log = []
87 consumer.consume(LoggingSource(log))
88 del log[:]
89 # Finishes immediately, all tasks are done.
90 consumer.taskStarted(lambda: None)
91- self.assertEqual(1, log.count('stop'))
92+ self.assertEqual(2, log.count(('start', consumer)))
93+ self.assertEqual(0, log.count('stop'))
94
95 def test_taskStarted_before_consume_raises_error(self):
96 # taskStarted can only be called after we have started consuming. This
97
98=== modified file 'lib/lp/bugs/windmill/tests/test_bug_also_affects_new_upstream.py'
99--- lib/lp/bugs/windmill/tests/test_bug_also_affects_new_upstream.py 2009-12-11 13:54:45 +0000
100+++ lib/lp/bugs/windmill/tests/test_bug_also_affects_new_upstream.py 2010-02-02 11:39:24 +0000
101@@ -3,21 +3,20 @@
102
103 import unittest
104
105-from windmill.authoring import WindmillTestClient
106-
107 from canonical.launchpad.windmill.testing.widgets import (
108 FormPickerWidgetTest)
109 from canonical.launchpad.windmill.testing import lpuser, constants
110 from canonical.launchpad.windmill.testing.widgets import search_picker_widget
111 from lp.bugs.windmill.testing import BugsWindmillLayer
112-from lp.testing import TestCaseWithFactory
113+from lp.testing import WindmillTestCase
114
115 CHOOSE_AFFECTED_URL = ('http://bugs.launchpad.dev:8085/tomcat/+bug/3/'
116 '+choose-affected-product')
117
118-class TestBugAlsoAffects(TestCaseWithFactory):
119+class TestBugAlsoAffects(WindmillTestCase):
120
121 layer = BugsWindmillLayer
122+ suite_name = 'test_bug_also_affects_register_link'
123
124 test_bug_also_affects_picker = FormPickerWidgetTest(
125 name='test_bug_also_affects',
126@@ -37,7 +36,7 @@
127 """
128
129 choose_link_id = 'show-widget-field-product'
130- client = WindmillTestClient('test_bug_also_affects_register_link')
131+ client = self.client
132
133 # Open a bug page and wait for it to finish loading.
134 client.open(url=CHOOSE_AFFECTED_URL)
135
136=== modified file 'lib/lp/bugs/windmill/tests/test_bug_commenting.py'
137--- lib/lp/bugs/windmill/tests/test_bug_commenting.py 2009-09-15 08:58:30 +0000
138+++ lib/lp/bugs/windmill/tests/test_bug_commenting.py 2010-02-02 11:39:24 +0000
139@@ -8,12 +8,10 @@
140
141 import unittest
142
143-from windmill.authoring import WindmillTestClient
144-
145 from canonical.launchpad.windmill.testing import lpuser
146 from canonical.uuid import generate_uuid
147 from lp.bugs.windmill.testing import BugsWindmillLayer
148-from lp.testing import TestCaseWithFactory
149+from lp.testing import WindmillTestCase
150
151 WAIT_PAGELOAD = u'30000'
152 WAIT_ELEMENT_COMPLETE = u'30000'
153@@ -22,13 +20,14 @@
154 u'//input[@id="field.actions.save" and @class="button js-action"]')
155
156
157-class TestBugCommenting(TestCaseWithFactory):
158+class TestBugCommenting(WindmillTestCase):
159
160 layer = BugsWindmillLayer
161+ suite_name = 'Bug commenting'
162
163 def test_bug_commenting(self):
164 """Test commenting on bugs."""
165- client = WindmillTestClient('Bug commenting')
166+ client = self.client
167 lpuser.NO_PRIV.ensure_login(client)
168
169 client.open(url='http://bugs.launchpad.dev:8085/bugs/1')
170
171=== modified file 'lib/lp/bugs/windmill/tests/test_bug_inline_subscriber.py'
172--- lib/lp/bugs/windmill/tests/test_bug_inline_subscriber.py 2009-12-18 20:59:15 +0000
173+++ lib/lp/bugs/windmill/tests/test_bug_inline_subscriber.py 2010-02-02 11:39:24 +0000
174@@ -3,21 +3,20 @@
175
176 import unittest
177
178-from windmill.authoring import WindmillTestClient
179-
180 from canonical.launchpad.windmill.testing import lpuser
181 from canonical.launchpad.windmill.testing.constants import (
182 PAGE_LOAD, FOR_ELEMENT, SLEEP)
183 from lp.bugs.windmill.testing import BugsWindmillLayer
184-from lp.testing import TestCaseWithFactory
185+from lp.testing import WindmillTestCase
186
187 BUG_URL = u'http://bugs.launchpad.dev:8085/bugs/%s'
188 SUBSCRIPTION_LINK = u'//div[@id="portlet-subscribers"]/div/div/a'
189 PERSON_LINK = u'//div[@id="subscribers-links"]/div/a[@name="%s"]'
190
191-class TestInlineSubscribing(TestCaseWithFactory):
192+class TestInlineSubscribing(WindmillTestCase):
193
194 layer = BugsWindmillLayer
195+ suite_name = 'Inline bug page subscribers test'
196
197 def test_inline_subscriber(self):
198 """Test inline subscribing on bugs pages.
199@@ -25,7 +24,7 @@
200 This test makes sure that subscribing and unsubscribing
201 from a bug works inline on a bug page.
202 """
203- client = WindmillTestClient('Inline bug page subscribers test')
204+ client = self.client
205
206 # Open a bug page and wait for it to finish loading.
207 client.open(url=BUG_URL % 11)
208
209=== modified file 'lib/lp/bugs/windmill/tests/test_bug_me_too.py'
210--- lib/lp/bugs/windmill/tests/test_bug_me_too.py 2010-01-20 15:56:19 +0000
211+++ lib/lp/bugs/windmill/tests/test_bug_me_too.py 2010-02-02 11:39:24 +0000
212@@ -5,11 +5,11 @@
213
214 import unittest
215
216-from windmill.authoring import WindmillTestClient, WindmillTestClientException
217+from windmill.authoring import WindmillTestClientException
218
219 from canonical.launchpad.windmill.testing import lpuser, constants
220 from lp.bugs.windmill.testing import BugsWindmillLayer
221-from lp.testing import TestCaseWithFactory
222+from lp.testing import WindmillTestCase
223
224 AFFECTS_ME_TOO_XPATH = u"//span[@id='affectsmetoo']"
225 DYNAMIC_SPAN_XPATH = AFFECTS_ME_TOO_XPATH + u"/span[@class='dynamic']"
226@@ -39,9 +39,10 @@
227 return decorator
228
229
230-class TestMeToo(TestCaseWithFactory):
231+class TestMeToo(WindmillTestCase):
232
233 layer = BugsWindmillLayer
234+ suite_name = 'Bug "me too" test'
235
236 def test_me_too(self):
237 """Test the "this bug affects me too" options on bug pages.
238@@ -49,7 +50,7 @@
239 This test ensures that, with Javascript enabled, the "me too"
240 status can be edited in-page.
241 """
242- client = WindmillTestClient('Bug "me too" test')
243+ client = self.client
244
245 # Open bug 11 and wait for it to finish loading.
246 client.open(
247
248=== modified file 'lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py'
249--- lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py 2009-11-08 22:43:09 +0000
250+++ lib/lp/bugs/windmill/tests/test_bug_privacy_settings.py 2010-02-02 11:39:23 +0000
251@@ -3,11 +3,9 @@
252
253 import unittest
254
255-from windmill.authoring import WindmillTestClient
256-
257 from canonical.launchpad.windmill.testing import lpuser, constants
258 from lp.bugs.windmill.testing import BugsWindmillLayer
259-from lp.testing import TestCaseWithFactory
260+from lp.testing import WindmillTestCase
261
262 BUG_URL = u'http://bugs.launchpad.dev:8085/bugs/15'
263 MAIN_FORM_ELEMENT = u'//div[@id="privacy-form-container"]/table'
264@@ -29,9 +27,10 @@
265 SECURITY_MESSAGE = u'security-message'
266
267
268-class TestSecurityOverlay(TestCaseWithFactory):
269+class TestSecurityOverlay(WindmillTestCase):
270
271 layer = BugsWindmillLayer
272+ suite_name = "Bug privacy settings test"
273
274 def test_security_settings_form_overlay(self):
275 """Test the change of the privacy settings on bug pages.
276@@ -40,7 +39,7 @@
277 is public[private]" on a bug page uses the formoverlay to update the
278 flags "private" and "security vulnerability".
279 """
280- client = WindmillTestClient("Bug privacy settings test")
281+ client = self.client
282
283 # Open a bug page and wait for it to finish loading.
284 client.open(url=BUG_URL)
285
286=== modified file 'lib/lp/bugs/windmill/tests/test_bug_tags_entry.py'
287--- lib/lp/bugs/windmill/tests/test_bug_tags_entry.py 2010-01-13 23:58:37 +0000
288+++ lib/lp/bugs/windmill/tests/test_bug_tags_entry.py 2010-02-02 11:39:24 +0000
289@@ -9,22 +9,21 @@
290 import transaction
291 import unittest
292
293-from windmill.authoring import WindmillTestClient
294-
295 from canonical.launchpad.webapp import canonical_url
296 from canonical.launchpad.windmill.testing import constants, lpuser
297 from lp.bugs.windmill.testing import BugsWindmillLayer
298-from lp.testing import TestCaseWithFactory
299+from lp.testing import WindmillTestCase
300
301 from zope.security.proxy import removeSecurityProxy
302
303-class TestBugTagsEntry(TestCaseWithFactory):
304+class TestBugTagsEntry(WindmillTestCase):
305
306 layer = BugsWindmillLayer
307+ suite_name = 'Bug tags entry test'
308
309 def test_bug_tags_entry(self):
310 """Test bug tags inline, auto-completing UI."""
311- client = WindmillTestClient('Bug tags entry test')
312+ client = self.client
313
314 # First, we add some official tags to test with
315
316
317=== modified file 'lib/lp/bugs/windmill/tests/test_filebug_dupe_finder.py'
318--- lib/lp/bugs/windmill/tests/test_filebug_dupe_finder.py 2010-01-29 15:21:38 +0000
319+++ lib/lp/bugs/windmill/tests/test_filebug_dupe_finder.py 2010-02-02 11:39:24 +0000
320@@ -3,11 +3,9 @@
321
322 import unittest
323
324-from windmill.authoring import WindmillTestClient
325-
326 from canonical.launchpad.windmill.testing import lpuser, constants
327 from lp.bugs.windmill.testing import BugsWindmillLayer
328-from lp.testing import TestCaseWithFactory
329+from lp.testing import WindmillTestCase
330
331 FILEBUG_URL = 'http://bugs.launchpad.dev:8085/firefox/+filebug'
332
333@@ -28,9 +26,10 @@
334 BUG_INFO_HIDDEN = 'style.height|0px'
335 BUG_INFO_SHOWN_JS = 'element.style.height != "0px"'
336
337-class TestDupeFinder(TestCaseWithFactory):
338+class TestDupeFinder(WindmillTestCase):
339
340 layer = BugsWindmillLayer
341+ suite_name = "Duplicate bug finder test"
342
343 def test_duplicate_finder(self):
344 """Test the +filebug duplicate finder.
345@@ -39,7 +38,7 @@
346 duplicates for a bug, with an expander that allows the user to view
347 more information if they wish.
348 """
349- client = WindmillTestClient("Duplicate bug finder test")
350+ client = self.client
351
352 # Go to the +filebug page for Firefox
353 client.open(url=FILEBUG_URL)
354
355=== modified file 'lib/lp/bugs/windmill/tests/test_filebug_extra_options.py'
356--- lib/lp/bugs/windmill/tests/test_filebug_extra_options.py 2009-12-18 14:22:51 +0000
357+++ lib/lp/bugs/windmill/tests/test_filebug_extra_options.py 2010-02-02 11:39:24 +0000
358@@ -3,16 +3,15 @@
359
360 import unittest
361
362-from windmill.authoring import WindmillTestClient
363-
364 from canonical.launchpad.windmill.testing import lpuser, constants
365 from lp.bugs.windmill.testing import BugsWindmillLayer
366-from lp.testing import TestCaseWithFactory
367-
368-
369-class TestFilebugExtras(TestCaseWithFactory):
370+from lp.testing import WindmillTestCase
371+
372+
373+class TestFilebugExtras(WindmillTestCase):
374
375 layer = BugsWindmillLayer
376+ suite_name = "File bug extra options test"
377
378 def test_filebug_extra_options(self):
379 """Test the extra options area on +filebug pages.
380@@ -20,7 +19,7 @@
381 This test ensures that, with Javascript enabled, the extra options
382 expander starts closed, and contains several fields when opened.
383 """
384- client = WindmillTestClient("File bug extra options test")
385+ client = self.client
386
387 # Open a +filebug page and wait for it to finish loading.
388 client.open(url=u'http://bugs.launchpad.dev:8085/firefox/+filebug')
389
390=== modified file 'lib/lp/bugs/windmill/tests/test_mark_duplicate.py'
391--- lib/lp/bugs/windmill/tests/test_mark_duplicate.py 2009-11-04 18:52:18 +0000
392+++ lib/lp/bugs/windmill/tests/test_mark_duplicate.py 2010-02-02 11:39:24 +0000
393@@ -8,11 +8,9 @@
394
395 import unittest
396
397-from windmill.authoring import WindmillTestClient
398-
399 from canonical.launchpad.windmill.testing import constants, lpuser
400 from lp.bugs.windmill.testing import BugsWindmillLayer
401-from lp.testing import TestCaseWithFactory
402+from lp.testing import WindmillTestCase
403
404 MAIN_FORM_ELEMENT = u'//div[@id="duplicate-form-container"]/table'
405 FORM_NOT_VISIBLE = (
406@@ -24,9 +22,10 @@
407 '//button[@name="field.actions.change"]')
408
409
410-class TestMarkDuplicate(TestCaseWithFactory):
411+class TestMarkDuplicate(WindmillTestCase):
412
413 layer = BugsWindmillLayer
414+ suite_name = "Bug mark duplicate test"
415
416 def test_mark_duplicate_form_overlay(self):
417 """Test the mark duplicate action on bug pages.
418@@ -35,7 +34,7 @@
419 link on a bug page uses the formoverlay to update the duplicateof
420 field via the api.
421 """
422- client = WindmillTestClient("Bug mark duplicate test")
423+ client = self.client
424
425 # Open a bug page and wait for it to finish loading
426 client.open(url=u'http://bugs.launchpad.dev:8085/bugs/15')
427
428=== modified file 'lib/lp/bugs/windmill/tests/test_official_bug_tags_management.py'
429--- lib/lp/bugs/windmill/tests/test_official_bug_tags_management.py 2009-12-15 11:40:15 +0000
430+++ lib/lp/bugs/windmill/tests/test_official_bug_tags_management.py 2010-02-02 11:39:23 +0000
431@@ -8,20 +8,19 @@
432
433 import unittest
434
435-from windmill.authoring import WindmillTestClient
436-
437 from canonical.launchpad.windmill.testing import constants, lpuser
438 from lp.bugs.windmill.testing import BugsWindmillLayer
439-from lp.testing import TestCaseWithFactory
440-
441-
442-class TestOfficialBugTags(TestCaseWithFactory):
443+from lp.testing import WindmillTestCase
444+
445+
446+class TestOfficialBugTags(WindmillTestCase):
447
448 layer = BugsWindmillLayer
449+ suite_name = 'Official bug tags management test'
450
451 def test_official_bug_tags_management(self):
452 """Test the official bug tags management interface."""
453- client = WindmillTestClient('Official bug tags management test')
454+ client = self.client
455
456 # Firefox is a product - an official bug tags target.
457
458
459=== modified file 'lib/lp/code/windmill/tests/test_branch_bugspeclinks.py'
460--- lib/lp/code/windmill/tests/test_branch_bugspeclinks.py 2010-01-14 07:46:09 +0000
461+++ lib/lp/code/windmill/tests/test_branch_bugspeclinks.py 2010-02-02 11:39:23 +0000
462@@ -9,17 +9,17 @@
463 import unittest
464
465 import windmill
466-from windmill.authoring import WindmillTestClient
467
468 from canonical.launchpad.windmill.testing import lpuser
469 from lp.code.windmill.testing import CodeWindmillLayer
470-from lp.testing import TestCaseWithFactory
471-
472-
473-class TestBranchBugLinks(TestCaseWithFactory):
474+from lp.testing import WindmillTestCase
475+
476+
477+class TestBranchBugLinks(WindmillTestCase):
478 """Test the links between branches and bugs."""
479
480 layer = CodeWindmillLayer
481+ suite_name = "Branch bug links"
482
483 def link_bug_and_assert_success(self, client, bug):
484 """Link a bug to the branch currently viewed by the client."""
485@@ -38,7 +38,7 @@
486
487 def test_inline_branch_bug_link_unlink(self):
488 """Link a bug from the branch page."""
489- client = WindmillTestClient("Branch bug links")
490+ client = self.client
491
492 lpuser.FOO_BAR.ensure_login(client)
493
494
495=== modified file 'lib/lp/code/windmill/tests/test_branch_popupdiff.py'
496--- lib/lp/code/windmill/tests/test_branch_popupdiff.py 2010-01-14 07:46:09 +0000
497+++ lib/lp/code/windmill/tests/test_branch_popupdiff.py 2010-02-02 11:39:24 +0000
498@@ -10,14 +10,13 @@
499 import unittest
500
501 import windmill
502-from windmill.authoring import WindmillTestClient
503
504 from canonical.launchpad.windmill.testing.constants import PAGE_LOAD
505 from canonical.launchpad.windmill.testing.lpuser import login_person
506 from lp.bugs.windmill.testing import BugsWindmillLayer
507 from lp.code.tests.helpers import make_erics_fooix_project
508 from lp.code.windmill.testing import CodeWindmillLayer
509-from lp.testing import TestCaseWithFactory
510+from lp.testing import WindmillTestCase
511
512
513 POPUP_DIFF = (
514@@ -42,14 +41,15 @@
515 u'//ul[@class="yui-picker-results"]//span[@class="yui-picker-result-title"]')
516
517
518-#class TestPopupOnBranchPage(TestCaseWithFactory):
519+#class TestPopupOnBranchPage(WindmillTestCase):
520 # """Test the popup diff."""
521 #
522 # layer = CodeWindmillLayer
523+# name = "Branch popup diffs"
524 #
525 # def test_branch_popup_diff(self):
526 # """Test branch diff popups."""
527-# client = WindmillTestClient("Branch popup diffs")
528+# client = self.client
529 # make_erics_fooix_project(self.factory)
530 # transaction.commit()
531 #
532@@ -72,17 +72,18 @@
533 # client.asserts.assertNotNode(xpath=VISIBLE_DIFF)
534
535
536-class TestPopupOnBugPage(TestCaseWithFactory):
537+class TestPopupOnBugPage(WindmillTestCase):
538 """Test the popup diff for bug pages.
539
540 Need this to be in the BugsWindmillLayer to run from the right subdomain.
541 """
542
543 layer = BugsWindmillLayer
544+ name = "Bug popup diffs"
545
546 def test_bug_popup_diff(self):
547 """Test bug page diff popups."""
548- client = WindmillTestClient("Bug popup diffs")
549+ client = self.client
550 objs = make_erics_fooix_project(self.factory)
551 bug = self.factory.makeBug(product=objs['fooix'])
552 bug.linkBranch(objs['proposed'], objs['fred'])
553@@ -108,7 +109,7 @@
554
555 def test_newly_linked_branch_diff_popup(self):
556 """Make sure a new branch linked has a js-action popup."""
557- client = WindmillTestClient("Bug popup diffs")
558+ client = self.client
559 objs = make_erics_fooix_project(self.factory)
560 bug = self.factory.makeBug(product=objs['fooix'])
561 transaction.commit()
562
563=== modified file 'lib/lp/code/windmill/tests/test_branch_status.py'
564--- lib/lp/code/windmill/tests/test_branch_status.py 2010-01-14 07:46:09 +0000
565+++ lib/lp/code/windmill/tests/test_branch_status.py 2010-02-02 11:39:24 +0000
566@@ -10,19 +10,19 @@
567 import unittest
568
569 import windmill
570-from windmill.authoring import WindmillTestClient
571
572 from canonical.launchpad.windmill.testing.constants import (
573 FOR_ELEMENT, PAGE_LOAD, SLEEP)
574 from canonical.launchpad.windmill.testing.lpuser import login_person
575 from lp.code.windmill.testing import CodeWindmillLayer
576-from lp.testing import TestCaseWithFactory
577-
578-
579-class TestBranchStatus(TestCaseWithFactory):
580+from lp.testing import WindmillTestCase
581+
582+
583+class TestBranchStatus(WindmillTestCase):
584 """Test setting branch status."""
585
586 layer = CodeWindmillLayer
587+ suite_name = "Branch status setting"
588
589 def test_inline_branch_status_setting(self):
590 """Set the status of a branch."""
591@@ -32,7 +32,7 @@
592 branch = self.factory.makeBranch(owner=eric)
593 transaction.commit()
594
595- client = WindmillTestClient("Branch status setting")
596+ client = self.client
597
598 start_url = (
599 windmill.settings['TEST_URL'] + branch.unique_name)
600
601=== modified file 'lib/lp/code/windmill/tests/test_branch_subscriptions.py'
602--- lib/lp/code/windmill/tests/test_branch_subscriptions.py 2010-01-14 07:46:09 +0000
603+++ lib/lp/code/windmill/tests/test_branch_subscriptions.py 2010-02-02 11:39:24 +0000
604@@ -9,23 +9,23 @@
605 import unittest
606
607 import windmill
608-from windmill.authoring import WindmillTestClient
609
610 from canonical.launchpad.windmill.testing import lpuser
611 from lp.code.windmill.testing import CodeWindmillLayer
612-from lp.testing import TestCaseWithFactory
613-
614-
615-
616-class TestBranchSubscriptions(TestCaseWithFactory):
617+from lp.testing import WindmillTestCase
618+
619+
620+
621+class TestBranchSubscriptions(WindmillTestCase):
622 """Test subscriptions to branches."""
623
624 layer = CodeWindmillLayer
625+ suite_name = "Branch Subscription Ajax Load Test"
626
627 def test_branch_subscription_ajax_load(self):
628 """Subscribe to a branch from the branch page."""
629
630- client = WindmillTestClient("Branch Subscription Ajax Load Test")
631+ client = self.client
632
633 lpuser.FOO_BAR.ensure_login(client)
634
635@@ -61,7 +61,7 @@
636 def test_team_edit_subscription_ajax_load(self):
637 """Unsubscribe a team from the branch."""
638
639- client = WindmillTestClient("Branch Subscription Ajax Load Test")
640+ client = self.client
641
642 lpuser.SAMPLE_PERSON.ensure_login(client)
643
644
645=== modified file 'lib/lp/code/windmill/tests/test_branchmergeproposal_commitmessage.py'
646--- lib/lp/code/windmill/tests/test_branchmergeproposal_commitmessage.py 2010-01-14 07:46:09 +0000
647+++ lib/lp/code/windmill/tests/test_branchmergeproposal_commitmessage.py 2010-02-02 11:39:24 +0000
648@@ -9,14 +9,12 @@
649 import transaction
650 import unittest
651
652-from windmill.authoring import WindmillTestClient
653-
654 from canonical.launchpad.webapp import canonical_url
655 from canonical.launchpad.windmill.testing.constants import (
656 FOR_ELEMENT, PAGE_LOAD, SLEEP)
657 from canonical.launchpad.windmill.testing.lpuser import login_person
658 from lp.code.windmill.testing import CodeWindmillLayer
659-from lp.testing import TestCaseWithFactory
660+from lp.testing import WindmillTestCase
661
662
663 EDIT_COMMIT_LINK = u'//a[contains(@href, "+edit-commit-message")]'
664@@ -31,9 +29,10 @@
665 u'//div[@id="edit-commit-message"]//div[@class="yui-editable_text-text"]')
666
667
668-class TestCommitMessage(TestCaseWithFactory):
669+class TestCommitMessage(WindmillTestCase):
670
671 layer = CodeWindmillLayer
672+ suite_name = "Commit message editing."
673
674 def test_set_commit_message(self):
675 """Test the commit message multiline editor."""
676@@ -43,7 +42,7 @@
677 bmp = self.factory.makeBranchMergeProposal(registrant=eric)
678 transaction.commit()
679
680- client = WindmillTestClient("Commit message editing.")
681+ client = self.client
682
683 login_person(eric, "test", client)
684
685@@ -70,9 +69,10 @@
686 xpath=COMMIT_MESSAGE_TEXT, validator=message)
687
688
689-class TestQueueStatus(TestCaseWithFactory):
690+class TestQueueStatus(WindmillTestCase):
691
692 layer = CodeWindmillLayer
693+ suite_name = "Queue status setting"
694
695 def test_inline_queue_status_setting(self):
696 """Test setting the queue_status with the ChoiceWidget."""
697@@ -84,7 +84,7 @@
698 merge_proposal = second_branch.addLandingTarget(mike, branch)
699 transaction.commit()
700
701- client = WindmillTestClient("Queue status setting")
702+ client = self.client
703
704 merge_url = canonical_url(merge_proposal)
705 client.open(url=merge_url)
706
707=== modified file 'lib/lp/code/windmill/tests/test_branchmergeproposal_review.py'
708--- lib/lp/code/windmill/tests/test_branchmergeproposal_review.py 2010-01-15 03:11:08 +0000
709+++ lib/lp/code/windmill/tests/test_branchmergeproposal_review.py 2010-02-02 11:39:24 +0000
710@@ -9,7 +9,6 @@
711
712 import transaction
713 import windmill
714-from windmill.authoring import WindmillTestClient
715
716 from canonical.launchpad.webapp import canonical_url
717 from canonical.launchpad.windmill.testing import lpuser
718@@ -17,7 +16,7 @@
719 search_and_select_picker_widget)
720 from canonical.uuid import generate_uuid
721 from lp.code.windmill.testing import CodeWindmillLayer
722-from lp.testing import login_person, TestCaseWithFactory
723+from lp.testing import login_person, WindmillTestCase
724
725 WAIT_PAGELOAD = u'30000'
726 WAIT_ELEMENT_COMPLETE = u'30000'
727@@ -26,15 +25,16 @@
728 u'//input[@id="field.actions.add" and @class="button js-action"]')
729
730
731-class TestRequestReview(TestCaseWithFactory):
732+class TestRequestReview(WindmillTestCase):
733 """Test the javascript functions of code review."""
734
735 layer = CodeWindmillLayer
736+ suite_name = "Code review"
737
738 def test_inline_request_a_reviewer(self):
739 """Request a review."""
740
741- client = WindmillTestClient("Code review")
742+ client = self.client
743
744 lpuser.FOO_BAR.ensure_login(client)
745
746@@ -57,10 +57,11 @@
747 client.waits.forElement(id=u'review-mark', timeout=u'10000')
748
749
750-class TestReviewCommenting(TestCaseWithFactory):
751+class TestReviewCommenting(WindmillTestCase):
752 """Test commenting and reviewing on a merge proposal."""
753
754 layer = CodeWindmillLayer
755+ suite_name = 'Code review commenting'
756
757 def open_proposal_page(self, client, proposal):
758 transaction.commit()
759@@ -69,7 +70,7 @@
760
761 def test_merge_proposal_commenting(self):
762 """Comment on a merge proposal."""
763- client = WindmillTestClient('Code review commenting')
764+ client = self.client
765 lpuser.NO_PRIV.ensure_login(client)
766
767 proposal = self.factory.makeBranchMergeProposal()
768@@ -88,7 +89,7 @@
769
770 def test_merge_proposal_replying(self):
771 """Reply to a review comment."""
772- client = WindmillTestClient('Code review commenting')
773+ client = self.client
774 lpuser.NO_PRIV.ensure_login(client)
775 proposal = self.factory.makeBranchMergeProposal()
776 login_person(proposal.registrant)
777@@ -108,7 +109,7 @@
778
779 def test_merge_proposal_reviewing(self):
780 """Comment on a merge proposal."""
781- client = WindmillTestClient('Code review commenting')
782+ client = self.client
783 lpuser.NO_PRIV.ensure_login(client)
784
785 proposal = self.factory.makeBranchMergeProposal()
786
787=== modified file 'lib/lp/registry/windmill/tests/test_add_milestone.py'
788--- lib/lp/registry/windmill/tests/test_add_milestone.py 2010-01-14 23:00:30 +0000
789+++ lib/lp/registry/windmill/tests/test_add_milestone.py 2010-02-02 11:39:24 +0000
790@@ -11,10 +11,8 @@
791
792 from canonical.launchpad.windmill.testing import lpuser
793
794-from windmill.authoring import WindmillTestClient
795-
796 from lp.registry.windmill.testing import RegistryWindmillLayer
797-from lp.testing import TestCaseWithFactory
798+from lp.testing import WindmillTestCase
799
800
801 def test_inline_add_milestone(client, url, name=None, suite='milestone',
802@@ -83,14 +81,11 @@
803 xpath="//*[@id='code-name']/dd", validator=code_name)
804
805
806-class TestAddMilestone(TestCaseWithFactory):
807+class TestAddMilestone(WindmillTestCase):
808 """Test form overlay widget for adding a milestone."""
809
810 layer = RegistryWindmillLayer
811-
812- def setUp(self):
813- super(TestAddMilestone, self).setUp()
814- self.client = WindmillTestClient('AddMilestone')
815+ suite_name = 'AddMilestone'
816
817 def test_adding_milestone_on_addrelease_page(self):
818 test_inline_add_milestone(
819
820=== modified file 'lib/lp/registry/windmill/tests/test_datetime_picker.py'
821--- lib/lp/registry/windmill/tests/test_datetime_picker.py 2010-01-11 21:15:38 +0000
822+++ lib/lp/registry/windmill/tests/test_datetime_picker.py 2010-02-02 11:39:24 +0000
823@@ -8,22 +8,17 @@
824
825 import unittest
826
827-from windmill.authoring import WindmillTestClient
828-
829 from canonical.launchpad.windmill.testing import lpuser
830
831 from lp.registry.windmill.testing import RegistryWindmillLayer
832-from lp.testing import TestCaseWithFactory
833-
834-
835-class TestDateTimeCalendarWidget(TestCaseWithFactory):
836+from lp.testing import WindmillTestCase
837+
838+
839+class TestDateTimeCalendarWidget(WindmillTestCase):
840 """Test datetime calendar widget."""
841
842 layer = RegistryWindmillLayer
843-
844- def setUp(self):
845- super(TestDateTimeCalendarWidget, self).setUp()
846- self.client = WindmillTestClient('DateTimeCalendarWidget')
847+ suite_name = 'DateTimeCalendarWidget'
848
849 def test_datetime_calendar_widget(self):
850 """Test the calendar widget's general functionality.
851
852=== modified file 'lib/lp/registry/windmill/tests/test_person_picker.py'
853--- lib/lp/registry/windmill/tests/test_person_picker.py 2010-02-02 11:39:22 +0000
854+++ lib/lp/registry/windmill/tests/test_person_picker.py 2010-02-02 11:39:24 +0000
855@@ -8,21 +8,16 @@
856
857 import unittest
858
859-from windmill.authoring import WindmillTestClient
860-
861 from canonical.launchpad.windmill.testing import constants, lpuser
862
863 from lp.registry.windmill.testing import RegistryWindmillLayer
864-from lp.testing import TestCaseWithFactory
865-
866-
867-class TesPersonPickerWidget(TestCaseWithFactory):
868+from lp.testing import WindmillTestCase
869+
870+
871+class TesPersonPickerWidget(WindmillTestCase):
872
873 layer = RegistryWindmillLayer
874-
875- def setUp(self):
876- super(TesPersonPickerWidget, self).setUp()
877- self.client = WindmillTestClient('PersonPickerWidget')
878+ suite_name = 'PersonPickerWidget'
879
880 def test_person_picker_widget(self):
881 client = self.client
882
883=== modified file 'lib/lp/registry/windmill/tests/test_plusnew_step1.py'
884--- lib/lp/registry/windmill/tests/test_plusnew_step1.py 2010-01-11 21:15:38 +0000
885+++ lib/lp/registry/windmill/tests/test_plusnew_step1.py 2010-02-02 11:39:24 +0000
886@@ -8,24 +8,19 @@
887
888 import unittest
889
890-from windmill.authoring import WindmillTestClient
891-
892 from canonical.launchpad.windmill.testing import lpuser
893
894 from lp.registry.windmill.testing import RegistryWindmillLayer
895-from lp.testing import TestCaseWithFactory
896+from lp.testing import WindmillTestCase
897
898 BACKSPACE = u'\x08'
899
900
901-class TestNewProjectStep1(TestCaseWithFactory):
902+class TestNewProjectStep1(WindmillTestCase):
903 """Test form for creating a new project."""
904
905 layer = RegistryWindmillLayer
906-
907- def setUp(self):
908- super(TestNewProjectStep1, self).setUp()
909- self.client = WindmillTestClient('TestNewProjectStep1')
910+ suite_name = 'TestNewProjectStep1'
911
912 def test_projects_plusnew_text_fields(self):
913 """Test the text fields on step 1 of projects/+new page.
914
915=== modified file 'lib/lp/registry/windmill/tests/test_plusnew_step2.py'
916--- lib/lp/registry/windmill/tests/test_plusnew_step2.py 2010-01-11 21:15:38 +0000
917+++ lib/lp/registry/windmill/tests/test_plusnew_step2.py 2010-02-02 11:39:24 +0000
918@@ -8,22 +8,17 @@
919
920 import unittest
921
922-from windmill.authoring import WindmillTestClient
923-
924 from canonical.launchpad.windmill.testing import lpuser
925
926 from lp.registry.windmill.testing import RegistryWindmillLayer
927-from lp.testing import TestCaseWithFactory
928-
929-
930-class TestNewProjectStep2(TestCaseWithFactory):
931+from lp.testing import WindmillTestCase
932+
933+
934+class TestNewProjectStep2(WindmillTestCase):
935 """Test form for creating a new project."""
936
937 layer = RegistryWindmillLayer
938-
939- def setUp(self):
940- super(TestNewProjectStep2, self).setUp()
941- self.client = WindmillTestClient('TestNewProjectStep2')
942+ suite_name = 'TestNewProjectStep2'
943
944 def test_projects_plusnew_step_two(self):
945 """Test the dynamic aspects of step 2 of projects/+new page.
946
947=== modified file 'lib/lp/registry/windmill/tests/test_product.py'
948--- lib/lp/registry/windmill/tests/test_product.py 2009-12-11 20:06:36 +0000
949+++ lib/lp/registry/windmill/tests/test_product.py 2010-02-02 11:39:24 +0000
950@@ -11,9 +11,9 @@
951 from canonical.launchpad.windmill.testing import lpuser, widgets
952
953 from lp.registry.windmill.testing import RegistryWindmillLayer
954-from lp.testing import TestCaseWithFactory
955+from lp.testing import WindmillTestCase
956
957-class TestProductIndexPage(TestCaseWithFactory):
958+class TestProductIndexPage(WindmillTestCase):
959 """Test product index page."""
960
961 layer = RegistryWindmillLayer
962
963=== modified file 'lib/lp/registry/windmill/tests/test_product_edit_people.py'
964--- lib/lp/registry/windmill/tests/test_product_edit_people.py 2009-12-11 20:06:36 +0000
965+++ lib/lp/registry/windmill/tests/test_product_edit_people.py 2010-02-02 11:39:24 +0000
966@@ -12,9 +12,9 @@
967 FormPickerWidgetTest)
968
969 from lp.registry.windmill.testing import RegistryWindmillLayer
970-from lp.testing import TestCaseWithFactory
971+from lp.testing import WindmillTestCase
972
973-class TestProductEditPeople(TestCaseWithFactory):
974+class TestProductEditPeople(WindmillTestCase):
975 """Test picker +edit-people page."""
976
977 layer = RegistryWindmillLayer
978
979=== modified file 'lib/lp/registry/windmill/tests/test_project_licenses.py'
980--- lib/lp/registry/windmill/tests/test_project_licenses.py 2010-01-15 18:45:16 +0000
981+++ lib/lp/registry/windmill/tests/test_project_licenses.py 2010-02-02 11:39:23 +0000
982@@ -8,22 +8,17 @@
983
984 import unittest
985
986-from windmill.authoring import WindmillTestClient
987-
988 from canonical.launchpad.windmill.testing import lpuser
989
990 from lp.registry.windmill.testing import RegistryWindmillLayer
991-from lp.testing import TestCaseWithFactory
992-
993-
994-class TestProjectLicenses(TestCaseWithFactory):
995+from lp.testing import WindmillTestCase
996+
997+
998+class TestProjectLicenses(WindmillTestCase):
999 """Test project licenses picker."""
1000
1001 layer = RegistryWindmillLayer
1002-
1003- def setUp(self):
1004- TestCaseWithFactory.setUp(self)
1005- self.client = WindmillTestClient('TestProjectLicenses')
1006+ suite_name = 'TestProjectLicenses'
1007
1008 def test_project_licenses(self):
1009 """Test the dynamic aspects of the project license picker."""
1010
1011=== modified file 'lib/lp/registry/windmill/tests/test_team_index.py'
1012--- lib/lp/registry/windmill/tests/test_team_index.py 2010-01-11 21:15:38 +0000
1013+++ lib/lp/registry/windmill/tests/test_team_index.py 2010-02-02 11:39:24 +0000
1014@@ -8,24 +8,19 @@
1015
1016 import unittest
1017
1018-from windmill.authoring import WindmillTestClient
1019-
1020 from canonical.launchpad.windmill.testing import lpuser
1021 from canonical.launchpad.windmill.testing.widgets import (
1022 search_and_select_picker_widget)
1023
1024 from lp.registry.windmill.testing import RegistryWindmillLayer
1025-from lp.testing import TestCaseWithFactory
1026-
1027-
1028-class TestTeamIndex(TestCaseWithFactory):
1029+from lp.testing import WindmillTestCase
1030+
1031+
1032+class TestTeamIndex(WindmillTestCase):
1033 """Test team index page."""
1034
1035 layer = RegistryWindmillLayer
1036-
1037- def setUp(self):
1038- super(TestTeamIndex, self).setUp()
1039- self.client = WindmillTestClient(__name__)
1040+ suite_name = __name__
1041
1042 def test_addmember(self):
1043 self.client.open(
1044
1045=== modified file 'lib/lp/registry/windmill/tests/test_timeline_graph.py'
1046--- lib/lp/registry/windmill/tests/test_timeline_graph.py 2010-01-11 21:15:38 +0000
1047+++ lib/lp/registry/windmill/tests/test_timeline_graph.py 2010-02-02 11:39:24 +0000
1048@@ -8,20 +8,15 @@
1049
1050 import unittest
1051
1052-from windmill.authoring import WindmillTestClient
1053-
1054 from lp.registry.windmill.testing import RegistryWindmillLayer
1055-from lp.testing import TestCaseWithFactory
1056-
1057-
1058-class TestTimelineGraph(TestCaseWithFactory):
1059+from lp.testing import WindmillTestCase
1060+
1061+
1062+class TestTimelineGraph(WindmillTestCase):
1063 """Test timeline graph widget."""
1064
1065 layer = RegistryWindmillLayer
1066-
1067- def setUp(self):
1068- super(TestTimelineGraph, self).setUp()
1069- self.client = WindmillTestClient('TimelineGraph')
1070+ suite_name = 'TimelineGraph'
1071
1072 def test_timeline_graph(self):
1073 """Test timeline graph on /$project/+timeline-graph page."""
1074
1075=== modified file 'lib/lp/services/job/runner.py'
1076--- lib/lp/services/job/runner.py 2010-01-07 05:03:46 +0000
1077+++ lib/lp/services/job/runner.py 2010-02-02 11:39:24 +0000
1078@@ -16,6 +16,7 @@
1079
1080
1081 import contextlib
1082+import logging
1083 import os
1084 from signal import getsignal, SIGCHLD, SIGHUP, signal
1085 import sys
1086@@ -324,7 +325,10 @@
1087
1088 def doConsumer(self):
1089 """Create a ParallelLimitedTaskConsumer for this job type."""
1090- consumer = ParallelLimitedTaskConsumer(1)
1091+ logger = logging.getLogger('gloop')
1092+ logger.addHandler(logging.StreamHandler(sys.stdout))
1093+ logger.setLevel(logging.DEBUG)
1094+ consumer = ParallelLimitedTaskConsumer(1, logger=None)
1095 return consumer.consume(self.getTaskSource())
1096
1097 def runAll(self):
1098
1099=== modified file 'lib/lp/services/job/tests/test_runner.py'
1100--- lib/lp/services/job/tests/test_runner.py 2010-01-11 14:26:54 +0000
1101+++ lib/lp/services/job/tests/test_runner.py 2010-02-02 11:39:23 +0000
1102@@ -259,25 +259,28 @@
1103 @classmethod
1104 def iterReady(cls):
1105 if not cls.done:
1106- yield StuckJob()
1107+ yield StuckJob(1)
1108+ yield StuckJob(2)
1109 cls.done = True
1110
1111 @staticmethod
1112 def get(id):
1113- return StuckJob()
1114+ return StuckJob(id)
1115
1116- def __init__(self):
1117- self.id = 1
1118+ def __init__(self, id):
1119+ self.id = id
1120 self.job = Job()
1121
1122 def acquireLease(self):
1123- # Must be enough time for the setup to complete and runJobHandleError
1124- # to be called. 7 was the minimum that worked on my computer.
1125- # -- abentley
1126- return self.job.acquireLease(10)
1127+ if self.id == 2:
1128+ lease_length = 1
1129+ else:
1130+ lease_length = 10000
1131+ return self.job.acquireLease(lease_length)
1132
1133 def run(self):
1134- sleep(30)
1135+ if self.id == 2:
1136+ sleep(30)
1137
1138
1139 class StuckJobProcess(JobRunnerProcess):
1140@@ -301,13 +304,16 @@
1141
1142 layer = LaunchpadZopelessLayer
1143
1144- # XXX: salgado, 2010-01-11, bug=505913: Disabled because of intermittent
1145- # failures.
1146- def disabled_test_timeout(self):
1147- """When a job exceeds its lease, an exception is raised."""
1148+ def test_timeout(self):
1149+ """When a job exceeds its lease, an exception is raised.
1150+
1151+ Unfortunately, timeouts include the time it takes for the zope
1152+ machinery to start up, so we run a job that will not time out first,
1153+ followed by a job that is sure to time out.
1154+ """
1155 logger = ListLogger()
1156 runner = TwistedJobRunner.runFromSource(StuckJob, logger)
1157- self.assertEqual([], runner.completed_jobs)
1158+ self.assertEqual(1, len(runner.completed_jobs))
1159 self.assertEqual(1, len(runner.incomplete_jobs))
1160 oops = errorlog.globalErrorUtility.getLastOopsReport()
1161 expected = [
1162
1163=== modified file 'lib/lp/soyuz/windmill/tests/test_archivesubscribersindex.py'
1164--- lib/lp/soyuz/windmill/tests/test_archivesubscribersindex.py 2009-11-09 20:50:49 +0000
1165+++ lib/lp/soyuz/windmill/tests/test_archivesubscribersindex.py 2010-02-02 11:39:24 +0000
1166@@ -9,8 +9,6 @@
1167 import transaction
1168 import unittest
1169
1170-from windmill.authoring import WindmillTestClient
1171-
1172 from zope.component import getUtility
1173
1174 from canonical.launchpad.ftests import login, logout
1175@@ -18,7 +16,7 @@
1176 from canonical.launchpad.windmill.testing import constants
1177 from lp.registry.interfaces.distribution import IDistributionSet
1178 from lp.soyuz.windmill.testing import SoyuzWindmillLayer
1179-from lp.testing import TestCaseWithFactory
1180+from lp.testing import WindmillTestCase
1181
1182 ADD_ACCESS_LINK = u'//a[@class="js-action sprite add"]'
1183 CHOOSE_SUBSCRIBER_LINK = u'//a[@id="show-widget-field-subscriber"]'
1184@@ -31,9 +29,10 @@
1185 MESSAGE_WINDOW = u'//div[@class="informational message"]'
1186
1187
1188-class TestArchiveSubscribersIndex(TestCaseWithFactory):
1189+class TestArchiveSubscribersIndex(WindmillTestCase):
1190
1191 layer = SoyuzWindmillLayer
1192+ suite_name = 'Adding private PPA subscribers.'
1193
1194 def setUp(self):
1195 """Create a private PPA."""
1196@@ -57,7 +56,7 @@
1197
1198 def test_add_subscriber(self):
1199 """Test adding a private PPA subscriber.."""
1200- client = WindmillTestClient('Adding private PPA subscribers.')
1201+ client = self.client
1202
1203 self.lpuser.ensure_login(client)
1204
1205
1206=== modified file 'lib/lp/testing/__init__.py'
1207--- lib/lp/testing/__init__.py 2010-01-20 03:19:44 +0000
1208+++ lib/lp/testing/__init__.py 2010-02-02 11:39:24 +0000
1209@@ -27,6 +27,7 @@
1210 # it from Zope.
1211 'verifyObject',
1212 'validate_mock_class',
1213+ 'WindmillTestCase',
1214 'with_anonymous_login',
1215 ]
1216
1217@@ -54,6 +55,8 @@
1218
1219 from twisted.python.util import mergeFunctionMetadata
1220
1221+from windmill.authoring import WindmillTestClient
1222+
1223 from zope.component import getUtility
1224 import zope.event
1225 from zope.interface.verify import verifyClass, verifyObject
1226@@ -535,6 +538,27 @@
1227 self.addCleanup(hosted_server.tearDown)
1228
1229
1230+class WindmillTestCase(TestCaseWithFactory):
1231+ """A TestCase class for Windmill tests.
1232+
1233+ It provides a WindmillTestClient (self.client) with Launchpad's front
1234+ page loaded.
1235+ """
1236+
1237+ suite_name = ''
1238+
1239+ def setUp(self):
1240+ TestCaseWithFactory.setUp(self)
1241+ self.client = WindmillTestClient(self.suite_name)
1242+ # Load the front page to make sure we don't get fooled by stale pages
1243+ # left by the previous test. (For some reason, when you create a new
1244+ # WindmillTestClient you get a new session and everything, but if you
1245+ # do anything before you open() something you'd be operating on the
1246+ # page that was last accessed by the previous test, which is the cause
1247+ # of things like https://launchpad.net/bugs/515494)
1248+ self.client.open(url=u'http://launchpad.dev:8085')
1249+
1250+
1251 def capture_events(callable_obj, *args, **kwargs):
1252 """Capture the events emitted by a callable.
1253
1254
1255=== modified file 'lib/lp/translations/windmill/tests/disabled_test_productseries_templates.py'
1256--- lib/lp/translations/windmill/tests/disabled_test_productseries_templates.py 2009-12-16 13:08:49 +0000
1257+++ lib/lp/translations/windmill/tests/disabled_test_productseries_templates.py 2010-02-02 11:39:24 +0000
1258@@ -6,16 +6,15 @@
1259 __metaclass__ = type
1260 __all__ = []
1261
1262-from windmill.authoring import WindmillTestClient
1263-
1264 from canonical.launchpad.windmill.testing import lpuser
1265 from lp.translations.windmill.testing import TranslationsWindmillLayer
1266-from lp.testing import TestCaseWithFactory
1267+from lp.testing import WindmillTestCase
1268
1269-class EnableActionLinksTest(TestCaseWithFactory):
1270+class EnableActionLinksTest(WindmillTestCase):
1271 """Test that action links are enabled on mouseover."""
1272
1273 layer = TranslationsWindmillLayer
1274+ suite_name = "Template links activation"
1275
1276 MAX_ROW = 2
1277
1278@@ -47,7 +46,7 @@
1279 * simulates moving the mouse cursor off the table row;
1280 * verifies that the action links of the row are deactivated;
1281 """
1282- client = WindmillTestClient("Template links activation")
1283+ client = self.client
1284 url = ('http://translations.launchpad.dev:8085/evolution/trunk/'
1285 '+templates')
1286 user = lpuser.TRANSLATIONS_ADMIN
1287
1288=== modified file 'lib/lp/translations/windmill/tests/test_documentation_links.py'
1289--- lib/lp/translations/windmill/tests/test_documentation_links.py 2009-11-13 15:00:15 +0000
1290+++ lib/lp/translations/windmill/tests/test_documentation_links.py 2010-02-02 11:39:24 +0000
1291@@ -6,18 +6,17 @@
1292 __metaclass__ = type
1293 __all__ = []
1294
1295-from windmill.authoring import WindmillTestClient
1296-
1297 from canonical.launchpad.windmill.testing import lpuser
1298 from lp.translations.windmill.testing import TranslationsWindmillLayer
1299-from lp.testing import TestCaseWithFactory
1300+from lp.testing import WindmillTestCase
1301
1302 from zope.security.proxy import removeSecurityProxy
1303
1304-class DocumentationLinksTest(TestCaseWithFactory):
1305+class DocumentationLinksTest(WindmillTestCase):
1306 """Test that the documentation links on translation pages work."""
1307
1308 layer = TranslationsWindmillLayer
1309+ suite_name = "Translation documentation links"
1310
1311 def createPOTemplateWithPOTMsgSets(self, productseries, name,
1312 number_of_potmsgsets):
1313@@ -37,7 +36,7 @@
1314 * makes sure it's hidden when you stay on the same translation;
1315 * makes sure it's shown again when you go to a different translation.
1316 """
1317- client = WindmillTestClient("Translation documentation links")
1318+ client = self.client
1319
1320 start_url = 'http://translations.launchpad.dev:8085/'
1321 user = lpuser.TRANSLATIONS_ADMIN
1322
1323=== modified file 'lib/lp/translations/windmill/tests/test_import_queue.py'
1324--- lib/lp/translations/windmill/tests/test_import_queue.py 2009-11-20 09:05:19 +0000
1325+++ lib/lp/translations/windmill/tests/test_import_queue.py 2010-02-02 11:39:24 +0000
1326@@ -8,7 +8,6 @@
1327
1328 import transaction
1329
1330-from windmill.authoring import WindmillTestClient
1331 from zope.component import getUtility
1332 from zope.security.proxy import removeSecurityProxy
1333
1334@@ -19,12 +18,13 @@
1335 from lp.translations.interfaces.translationimportqueue import (
1336 ITranslationImportQueue)
1337 from lp.translations.windmill.testing import TranslationsWindmillLayer
1338-from lp.testing import TestCaseWithFactory
1339+from lp.testing import WindmillTestCase
1340
1341-class ImportQueueEntryTest(TestCaseWithFactory):
1342+class ImportQueueEntryTest(WindmillTestCase):
1343 """Test that the entries in the import queue can switch types."""
1344
1345 layer = TranslationsWindmillLayer
1346+ suite_name = 'Translations import queue entry'
1347
1348 FIELDS = {
1349 'POT': [
1350@@ -73,7 +73,7 @@
1351
1352 def test_import_queue_entry(self):
1353 """Tests that import queue entry fields behave correctly."""
1354- client = WindmillTestClient('Translations import queue entry')
1355+ client = self.client
1356 start_url = 'http://translations.launchpad.dev:8085/+imports/1'
1357 user = lpuser.TRANSLATIONS_ADMIN
1358 # Go to import queue page logged in as translations admin.
1359@@ -105,14 +105,15 @@
1360 IMPORT_STATUS_1 = IMPORT_STATUS % 1
1361 OPEN_CHOICELIST = u"//div[contains(@class, 'yui-ichoicelist-content')]"
1362
1363-class ImportQueueStatusTest(TestCaseWithFactory):
1364+class ImportQueueStatusTest(WindmillTestCase):
1365 """Test that the entries in the import queue can switch types."""
1366
1367 layer = TranslationsWindmillLayer
1368+ suite_name = 'Translations import queue status'
1369
1370 def test_import_queue_status_admin(self):
1371 """Tests that the admin can use the status picker."""
1372- client = WindmillTestClient('Translations import queue status')
1373+ client = self.client
1374 queue_url = self.layer.base_url+'/+imports'
1375 user = lpuser.TRANSLATIONS_ADMIN
1376 # Go to import queue page logged in as translations admin.
1377@@ -138,7 +139,7 @@
1378
1379 def test_import_queue_status_nopriv(self):
1380 """Tests that a none-admin will have less choices."""
1381- client = WindmillTestClient('Translations import queue status')
1382+ client = self.client
1383 queue_url = self.layer.base_url+'/+imports'
1384 hubert = self.factory.makePerson(
1385 name="hubert", displayname="Hubert Hunt", password="test",
1386
1387=== modified file 'lib/lp/translations/windmill/tests/test_languages.py'
1388--- lib/lp/translations/windmill/tests/test_languages.py 2009-12-17 12:21:53 +0000
1389+++ lib/lp/translations/windmill/tests/test_languages.py 2010-02-02 11:39:24 +0000
1390@@ -6,12 +6,10 @@
1391 __metaclass__ = type
1392 __all__ = []
1393
1394-from windmill.authoring import WindmillTestClient
1395-
1396 from canonical.launchpad.windmill.testing.constants import (
1397 PAGE_LOAD, SLEEP)
1398 from lp.translations.windmill.testing import TranslationsWindmillLayer
1399-from lp.testing import TestCaseWithFactory
1400+from lp.testing import WindmillTestCase
1401
1402 INPUT_FIELD = (u"//div[contains(@class,'searchform')]"+
1403 u"//input[@id='field.search_lang']")
1404@@ -21,10 +19,11 @@
1405 UNSEEN_VALIDATOR = 'className|unseen'
1406
1407
1408-class LanguagesFilterTest(TestCaseWithFactory):
1409+class LanguagesFilterTest(WindmillTestCase):
1410 """Test that filtering on the +languages page works."""
1411
1412 layer = TranslationsWindmillLayer
1413+ suite_name = 'Languages filter'
1414
1415 def _enter_filter_string(self, filterstring):
1416 self.client.type(xpath=INPUT_FIELD, text=filterstring)
1417@@ -50,7 +49,7 @@
1418 Mende, because it contains a 'de' but the language code does not,
1419 French, because neither its name nor language code contain 'de'.
1420 """
1421- self.client = WindmillTestClient('Languages filter')
1422+ client = self.client
1423 start_url = 'http://translations.launchpad.dev:8085/+languages'
1424 # Go to the languages page
1425 self.client.open(url=start_url)
1426
1427=== modified file 'lib/lp/translations/windmill/tests/test_serieslanguages.py'
1428--- lib/lp/translations/windmill/tests/test_serieslanguages.py 2009-12-21 07:28:24 +0000
1429+++ lib/lp/translations/windmill/tests/test_serieslanguages.py 2010-02-02 11:39:24 +0000
1430@@ -6,27 +6,22 @@
1431 __metaclass__ = type
1432 __all__ = []
1433
1434-import transaction
1435-
1436-from windmill.authoring import WindmillTestClient
1437-from zope.component import getUtility
1438-
1439 from canonical.launchpad.windmill.testing.constants import (
1440 PAGE_LOAD, SLEEP)
1441 from canonical.launchpad.windmill.testing import lpuser
1442-from canonical.launchpad.windmill.testing.lpuser import login_person
1443 from lp.translations.windmill.testing import TranslationsWindmillLayer
1444-from lp.testing import TestCaseWithFactory
1445+from lp.testing import WindmillTestCase
1446
1447 LANGUAGE=(u"//table[@id='languagestats']/descendant::a[text()='%s']"
1448 u"/parent::td/parent::tr")
1449 UNSEEN_VALIDATOR='className|unseen'
1450
1451
1452-class LanguagesSeriesTest(TestCaseWithFactory):
1453+class LanguagesSeriesTest(WindmillTestCase):
1454 """Tests for serieslanguages."""
1455
1456 layer = TranslationsWindmillLayer
1457+ suite_name = 'SeriesLanguages Tables'
1458
1459 def _toggle_languages_visiblity(self):
1460 self.client.click(id="toggle-languages-visibility")
1461@@ -48,7 +43,7 @@
1462 The test cannot fully cover all languages so we just test with a
1463 person having Catalan and Spanish as preferred languages.
1464 """
1465- self.client = WindmillTestClient('SeriesLanguages Tables')
1466+ client = self.client
1467 start_url = 'http://translations.launchpad.dev:8085/ubuntu'
1468 user = lpuser.TRANSLATIONS_ADMIN
1469 # Go to the distribution languages page

Subscribers

People subscribed via source and target branches

to status/vote changes: