Merge lp:~edwin-grubbs/launchpad/bug-430708-registry-windmill-layer into lp:launchpad

Proposed by Edwin Grubbs
Status: Merged
Approved by: Barry Warsaw
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~edwin-grubbs/launchpad/bug-430708-registry-windmill-layer
Merge into: lp:launchpad
Diff against target: 191 lines
3 files modified
Makefile (+1/-0)
lib/lp/registry/windmill/testing.py (+18/-0)
lib/lp/registry/windmill/tests/test_timeline_graph.py (+83/-60)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-430708-registry-windmill-layer
Reviewer Review Type Date Requested Status
Barry Warsaw (community) code Approve
Canonical Launchpad Engineering code Pending
Review via email: mp+13148@code.launchpad.net

Commit message

Move test_timeline_graph.py to lib/lp/registry/windmill and covert it to run under ./bin/test.

To post a comment you must log in.
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Summary
-------

Moved the test_timeline_graph.py to lib/lp/registry/windmill
and made the changes necessary to have it run by ./bin/test
instead of ./bin/lp-windmill.

I added very kludgy looking for-loops to the tests to eliminate
sporadic failures that were occuring from 5% to 10% of the time.

Tests
-----

./bin/test --layer=RegistryWindmillLayer

Demo and Q/A
------------

Not QA-able.

Lint
----

= Launchpad lint =

Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.

Linting changed files:
  Makefile
  lib/lp/registry/windmill/testing.py
  lib/lp/registry/windmill/tests/test_timeline_graph.py

Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :

Hi Barry,

Thanks for the review. Here is the incremental diff.

{{{
=== modified file 'lib/lp/registry/windmill/tests/test_timeline_graph.py'
--- lib/lp/registry/windmill/tests/test_timeline_graph.py 2009-10-09 21:40:20 +0000
+++ lib/lp/registry/windmill/tests/test_timeline_graph.py 2009-10-09 22:07:54 +0000
@@ -26,7 +26,11 @@
             option=u'style.display|none',
             timeout=u'8000')
         link_xpath = '//div/a[@href="/firefox/trunk"]'
- for i in range(0, 5):
+
+ # waits.forElement() is called multiple times because there
+ # were sporadic errors where waits.forElement() would succeed but
+ # the following assertNode() would fail 5% of the time.
+ for i in range(5):
             self.client.waits.forElement(xpath=link_xpath)
         self.client.asserts.assertNode(xpath=link_xpath)

@@ -54,7 +58,11 @@
             option=u'style.display|block',
             timeout=u'8000')
         self.client.waits.forElement(id=u'timeline-loading', timeout=u'20000')
- for i in range(0, 5):
+
+ # waits.forElementProperty() is called multiple times because there
+ # were sporadic errors where waits.forElement() would succeed but
+ # the following assertProperty() would fail 5% of the time.
+ for i in range(5):
             self.client.waits.forElementProperty(
                 id=u'timeline-loading',
                 option=u'style.display|none')
}}}

Revision history for this message
Barry Warsaw (barry) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2009-10-07 09:55:24 +0000
3+++ Makefile 2009-10-09 22:59:15 +0000
4@@ -92,6 +92,7 @@
5 @echo
6 bin/test $(VERBOSITY) --layer=BugsWindmillLayer
7 bin/test $(VERBOSITY) --layer=CodeWindmillLayer
8+ bin/test $(VERBOSITY) --layer=RegistryWindmillLayer
9 bin/test $(VERBOSITY) --layer=SoyuzWindmillLayer
10
11 jscheck_functest: build
12
13=== added directory 'lib/lp/registry/windmill'
14=== added file 'lib/lp/registry/windmill/__init__.py'
15=== added file 'lib/lp/registry/windmill/testing.py'
16--- lib/lp/registry/windmill/testing.py 1970-01-01 00:00:00 +0000
17+++ lib/lp/registry/windmill/testing.py 2009-10-09 22:59:15 +0000
18@@ -0,0 +1,18 @@
19+# Copyright 2009 Canonical Ltd. This software is licensed under the
20+# GNU Affero General Public License version 3 (see the file LICENSE).
21+
22+"""Registry-specific testing infrastructure for Windmill."""
23+
24+__metaclass__ = type
25+__all__ = [
26+ 'RegistryWindmillLayer',
27+ ]
28+
29+
30+from canonical.testing.layers import BaseWindmillLayer
31+
32+
33+class RegistryWindmillLayer(BaseWindmillLayer):
34+ """Layer for Registry Windmill tests."""
35+
36+ base_url = 'http://launchpad.dev:8085/'
37
38=== added directory 'lib/lp/registry/windmill/tests'
39=== added file 'lib/lp/registry/windmill/tests/__init__.py'
40=== renamed file 'lib/canonical/launchpad/windmill/tests/test_registry/test_timeline_graph.py' => 'lib/lp/registry/windmill/tests/test_timeline_graph.py'
41--- lib/canonical/launchpad/windmill/tests/test_registry/test_timeline_graph.py 2009-07-17 00:26:05 +0000
42+++ lib/lp/registry/windmill/tests/test_timeline_graph.py 2009-10-09 22:59:15 +0000
43@@ -1,65 +1,88 @@
44 # Copyright 2009 Canonical Ltd. This software is licensed under the
45 # GNU Affero General Public License version 3 (see the file LICENSE).
46
47+import unittest
48+
49 from windmill.authoring import WindmillTestClient
50
51-from canonical.launchpad.windmill.testing import lpuser
52-
53-
54-def test_timeline_graph():
55- """Test timeline graph on /$project/+timeline-graph page."""
56-
57- client = WindmillTestClient('TimelineGraph')
58-
59- client.open(url=u'http://launchpad.dev:8085/firefox/+timeline-graph')
60- client.waits.forElement(id=u'spinner', timeout=u'20000')
61- client.waits.forElementProperty(
62- id=u'spinner',
63- option=u'style.display|none',
64- timeout=u'8000')
65- client.asserts.assertNode(xpath='//div/a[@href="/firefox/trunk"]')
66-
67-def test_project_timeline_graph():
68- """Test that the timeline graph loads on /$project page."""
69-
70- client = WindmillTestClient('TimelineGraph')
71- client.open(url=u'http://launchpad.dev:8085/firefox')
72-
73- client.waits.forElement(id=u'timeline-loading', timeout=u'20000')
74- client.waits.forElementProperty(
75- id=u'timeline-iframe',
76- option=u'style.display|block',
77- timeout=u'8000')
78- client.asserts.assertProperty(
79- id=u'timeline-loading',
80- validator=u'style.display|none')
81-
82-def test_series_timeline_graph():
83- """Test that the timeline graph loads on /$project/$series page."""
84-
85- client = WindmillTestClient('TimelineGraph')
86- client.open(url=u'http://launchpad.dev:8085/firefox/trunk')
87-
88- client.waits.forElement(id=u'timeline-loading', timeout=u'20000')
89- client.waits.forElementProperty(
90- id=u'timeline-iframe',
91- option=u'style.display|block',
92- timeout=u'8000')
93- client.asserts.assertProperty(
94- id=u'timeline-loading',
95- validator=u'style.display|none')
96-
97-def test_all_series_timeline_graph():
98- """Test that the timeline graph loads on /$project/+series page."""
99-
100- client = WindmillTestClient('TimelineGraph')
101- client.open(url=u'http://launchpad.dev:8085/firefox/+series')
102-
103- client.waits.forElement(id=u'timeline-loading', timeout=u'20000')
104- client.waits.forElementProperty(
105- id=u'timeline-iframe',
106- option=u'style.display|block',
107- timeout=u'8000')
108- client.asserts.assertProperty(
109- id=u'timeline-loading',
110- validator=u'style.display|none')
111+from lp.registry.windmill.testing import RegistryWindmillLayer
112+from lp.testing import TestCaseWithFactory
113+
114+class TestTimelineGraph(TestCaseWithFactory):
115+
116+ layer = RegistryWindmillLayer
117+
118+ def setUp(self):
119+ self.client = WindmillTestClient('TimelineGraph')
120+
121+ def test_timeline_graph(self):
122+ """Test timeline graph on /$project/+timeline-graph page."""
123+
124+ self.client.open(
125+ url=u'http://launchpad.dev:8085/firefox/+timeline-graph')
126+ self.client.waits.forElement(id=u'spinner', timeout=u'20000')
127+ self.client.waits.forElementProperty(
128+ id=u'spinner',
129+ option=u'style.display|none',
130+ timeout=u'8000')
131+ link_xpath = '//div/a[@href="/firefox/trunk"]'
132+
133+ # waits.forElement() is called multiple times because there
134+ # were sporadic errors where waits.forElement() would succeed but
135+ # the following assertNode() would fail 5% of the time.
136+ for i in range(5):
137+ self.client.waits.forElement(xpath=link_xpath)
138+ self.client.asserts.assertNode(xpath=link_xpath)
139+
140+ def test_project_timeline_graph(self):
141+ """Test that the timeline graph loads on /$project page."""
142+
143+ self.client.open(url=u'http://launchpad.dev:8085/firefox')
144+
145+ self.client.waits.forElement(id=u'timeline-loading', timeout=u'20000')
146+ self.client.waits.forElementProperty(
147+ id=u'timeline-iframe',
148+ option=u'style.display|block',
149+ timeout=u'8000')
150+ self.client.asserts.assertProperty(
151+ id=u'timeline-loading',
152+ validator=u'style.display|none')
153+
154+ def test_series_timeline_graph(self):
155+ """Test that the timeline graph loads on /$project/$series page."""
156+
157+ self.client.open(url=u'http://launchpad.dev:8085/firefox/trunk')
158+
159+ self.client.waits.forElementProperty(
160+ id=u'timeline-iframe',
161+ option=u'style.display|block',
162+ timeout=u'8000')
163+ self.client.waits.forElement(id=u'timeline-loading', timeout=u'20000')
164+
165+ # waits.forElementProperty() is called multiple times because there
166+ # were sporadic errors where waits.forElement() would succeed but
167+ # the following assertProperty() would fail 5% of the time.
168+ for i in range(5):
169+ self.client.waits.forElementProperty(
170+ id=u'timeline-loading',
171+ option=u'style.display|none')
172+ self.client.asserts.assertProperty(
173+ id=u'timeline-loading',
174+ validator=u'style.display|none')
175+
176+ def test_all_series_timeline_graph(self):
177+ """Test that the timeline graph loads on /$project/+series page."""
178+
179+ self.client.open(url=u'http://launchpad.dev:8085/firefox/+series')
180+
181+ self.client.waits.forElement(id=u'timeline-loading', timeout=u'20000')
182+ self.client.waits.forElementProperty(
183+ id=u'timeline-iframe',
184+ option=u'style.display|block',
185+ timeout=u'8000')
186+ self.client.asserts.assertProperty(
187+ id=u'timeline-loading',
188+ validator=u'style.display|none')
189+
190+def test_suite():
191+ return unittest.TestLoader().loadTestsFromName(__name__)