Merge lp:~edwin-grubbs/launchpad/bug-495067-move-windmill-tests into lp:launchpad/db-devel

Proposed by Edwin Grubbs
Status: Merged
Merged at revision: not available
Proposed branch: lp:~edwin-grubbs/launchpad/bug-495067-move-windmill-tests
Merge into: lp:launchpad/db-devel
Diff against target: 1455 lines (+699/-452)
18 files modified
database/schema/security.cfg (+3/-0)
lib/canonical/launchpad/javascript/lp/comment.js (+0/-1)
lib/canonical/launchpad/windmill/testing/widgets.py (+5/-3)
lib/lp/code/browser/codereviewcomment.py (+4/-3)
lib/lp/code/templates/branchmergeproposal-index.pt (+62/-27)
lib/lp/registry/browser/product.py (+1/-1)
lib/lp/registry/browser/team.py (+4/-2)
lib/lp/registry/templates/milestone-index.pt (+2/-2)
lib/lp/registry/templates/product-new.pt (+1/-1)
lib/lp/registry/windmill/tests/test_add_milestone.py (+86/-87)
lib/lp/registry/windmill/tests/test_datetime_picker.py (+70/-52)
lib/lp/registry/windmill/tests/test_plusnew_step1.py (+65/-41)
lib/lp/registry/windmill/tests/test_plusnew_step2.py (+90/-61)
lib/lp/registry/windmill/tests/test_product.py (+43/-21)
lib/lp/registry/windmill/tests/test_product_edit_people.py (+38/-17)
lib/lp/registry/windmill/tests/test_project_licenses.py (+144/-124)
lib/lp/registry/windmill/tests/test_timeline_graph.py (+6/-0)
lib/lp/translations/tests/test_translationimportqueue.py (+75/-9)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-495067-move-windmill-tests
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+16057@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Edwin Grubbs (edwin-grubbs) wrote :
Download full text (13.1 KiB)

Summary
-------

Moved the remaining registry windmill tests from
lib/canonical/launchpad/windmill/tests to lib/lp/registry/windmill/tests.

Implementation details
----------------------

Most of the changes just involve boilerplate to convert the tests
to unittests, indenting functions that became methods, and replacing
client with self.client.

I've included a smaller diff below of the changes that were made to fix
regressions since these tests had not been automatically run. I also
encountered authentication problems with the lpuser module's
ensure_login() method. Some of the tests use helper functions from a
different module that creates a new windmill client each time the
function is called. I assume there is something in the initialization of
the new client that invalidates the cookie from the last client,
therefore, I have to load a page in the new client before calling
ensure_login() so that it can find the "Login" link, otherwise it
assumes it is still logged in just fine.

lib/lp/registry/browser/product.py
    The windmill test was using foo.bar instead of the owner of the
    project, so it seemed better to fix this by allowing anyone with
    launchpad.Edit access to be able to see the programming language
    fields inline editing icon.

lib/lp/registry/templates/milestone-index.pt
lib/lp/registry/windmill/tests/test_add_milestone.py
    Creating a release now takes you to the milestone/release index
    page instead of the series index page. The ids were added to
    simplify the tests.

lib/lp/registry/templates/product-new.pt
    node.attach() was replaced with node.on(), so this functionality
    was actually broken in production.

lib/lp/registry/windmill/tests/test_plusnew_step1.py
lib/lp/registry/windmill/tests/test_plusnew_step2.py
lib/lp/registry/windmill/tests/test_product.py
lib/lp/registry/windmill/tests/test_project_licenses.py

Tests
-----

./bin/test -vv --layer=RegistryWindmillLayer

{{{

=== modified file 'lib/canonical/launchpad/windmill/testing/widgets.py'
--- lib/canonical/launchpad/windmill/testing/widgets.py 2009-10-29 14:23:16 +0000
+++ lib/canonical/launchpad/windmill/testing/widgets.py 2009-12-11 00:22:50 +0000
@@ -60,10 +60,10 @@
         * reloads and verifies that the new value sticked.
         """
         client = WindmillTestClient(self.suite)
+ client.open(url=self.url)

         self.user.ensure_login(client)

- client.open(url=self.url)
         client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
         widget_base = u"//%s[@id='%s']" % (self.widget_tag, self.widget_id)
         client.waits.forElement(
@@ -298,13 +298,15 @@

     def __call__(self):
         client = WindmillTestClient(self.suite)
- self.user.ensure_login(client)

         # Load page.
         client.open(url=self.url)
- client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
+
+ self.user.ensure_login(client)

         # Click on "Choose" link to show picker for the given field.
+ client.waits.forElement(
+ id=self.choose_link_id, timeout=constants.PAGE_LOAD)
         client.click(id=self.choose_link_id)

         # Search picker.

=== modified file 'lib/lp/regis...

Revision history for this message
Curtis Hovey (sinzui) wrote :

This must have been to most boring diff I have ever read.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'database/schema/security.cfg'
--- database/schema/security.cfg 2009-12-02 13:08:18 +0000
+++ database/schema/security.cfg 2009-12-11 20:25:26 +0000
@@ -1216,6 +1216,9 @@
1216public.libraryfilecontent = SELECT, INSERT1216public.libraryfilecontent = SELECT, INSERT
12171217
1218# rosetta auto imports1218# rosetta auto imports
1219public.pofile = SELECT
1220public.potemplate = SELECT
1221public.translationgroup = SELECT
1219public.translationimportqueueentry = SELECT, INSERT, UPDATE1222public.translationimportqueueentry = SELECT, INSERT, UPDATE
12201223
1221# Closing bugs.1224# Closing bugs.
12221225
=== modified file 'lib/canonical/launchpad/javascript/lp/comment.js'
--- lib/canonical/launchpad/javascript/lp/comment.js 2009-11-26 19:54:52 +0000
+++ lib/canonical/launchpad/javascript/lp/comment.js 2009-12-11 20:25:26 +0000
@@ -361,7 +361,6 @@
361 },361 },
362 renderUI: function() {362 renderUI: function() {
363 CodeReviewComment.superclass.renderUI.apply(this);363 CodeReviewComment.superclass.renderUI.apply(this);
364 Y.one('#inline-add-comment').setStyle('display', 'block');
365 },364 },
366 /**365 /**
367 * Implementation of Widget.bindUI: Bind events to methods.366 * Implementation of Widget.bindUI: Bind events to methods.
368367
=== modified file 'lib/canonical/launchpad/windmill/testing/widgets.py'
--- lib/canonical/launchpad/windmill/testing/widgets.py 2009-10-29 14:23:16 +0000
+++ lib/canonical/launchpad/windmill/testing/widgets.py 2009-12-11 20:25:26 +0000
@@ -60,10 +60,10 @@
60 * reloads and verifies that the new value sticked.60 * reloads and verifies that the new value sticked.
61 """61 """
62 client = WindmillTestClient(self.suite)62 client = WindmillTestClient(self.suite)
63 client.open(url=self.url)
6364
64 self.user.ensure_login(client)65 self.user.ensure_login(client)
6566
66 client.open(url=self.url)
67 client.waits.forPageLoad(timeout=constants.PAGE_LOAD)67 client.waits.forPageLoad(timeout=constants.PAGE_LOAD)
68 widget_base = u"//%s[@id='%s']" % (self.widget_tag, self.widget_id)68 widget_base = u"//%s[@id='%s']" % (self.widget_tag, self.widget_id)
69 client.waits.forElement(69 client.waits.forElement(
@@ -298,13 +298,15 @@
298298
299 def __call__(self):299 def __call__(self):
300 client = WindmillTestClient(self.suite)300 client = WindmillTestClient(self.suite)
301 self.user.ensure_login(client)
302301
303 # Load page.302 # Load page.
304 client.open(url=self.url)303 client.open(url=self.url)
305 client.waits.forPageLoad(timeout=constants.PAGE_LOAD)304
305 self.user.ensure_login(client)
306306
307 # Click on "Choose" link to show picker for the given field.307 # Click on "Choose" link to show picker for the given field.
308 client.waits.forElement(
309 id=self.choose_link_id, timeout=constants.PAGE_LOAD)
308 client.click(id=self.choose_link_id)310 client.click(id=self.choose_link_id)
309311
310 # Search picker.312 # Search picker.
311313
=== removed directory 'lib/canonical/launchpad/windmill/tests'
=== removed file 'lib/canonical/launchpad/windmill/tests/__init__.py'
=== removed directory 'lib/canonical/launchpad/windmill/tests/test_registry'
=== removed file 'lib/canonical/launchpad/windmill/tests/test_registry/__init__.py'
=== modified file 'lib/lp/code/browser/codereviewcomment.py'
--- lib/lp/code/browser/codereviewcomment.py 2009-10-29 23:51:08 +0000
+++ lib/lp/code/browser/codereviewcomment.py 2009-12-11 20:25:26 +0000
@@ -204,7 +204,7 @@
204204
205 class MyDropWidget(DropdownWidget):205 class MyDropWidget(DropdownWidget):
206 "Override the default no-value display name to -Select-."206 "Override the default no-value display name to -Select-."
207 _messageNoValue = '-Select-'207 _messageNoValue = 'Comment only'
208208
209 schema = IEditCodeReviewComment209 schema = IEditCodeReviewComment
210210
@@ -251,10 +251,11 @@
251 @action('Save Comment', name='add')251 @action('Save Comment', name='add')
252 def add_action(self, action, data):252 def add_action(self, action, data):
253 """Create the comment..."""253 """Create the comment..."""
254 vote = data.get('vote')
255 review_type = data.get('review_type')
254 comment = self.branch_merge_proposal.createComment(256 comment = self.branch_merge_proposal.createComment(
255 self.user, subject=None, content=data['comment'],257 self.user, subject=None, content=data['comment'],
256 parent=self.reply_to, vote=data['vote'],258 parent=self.reply_to, vote=vote, review_type=review_type)
257 review_type=data['review_type'])
258259
259 @property260 @property
260 def next_url(self):261 def next_url(self):
261262
=== modified file 'lib/lp/code/templates/branchmergeproposal-index.pt'
--- lib/lp/code/templates/branchmergeproposal-index.pt 2009-11-26 23:36:50 +0000
+++ lib/lp/code/templates/branchmergeproposal-index.pt 2009-12-11 20:25:26 +0000
@@ -21,6 +21,24 @@
21 #commit-message, #edit-commit-message {21 #commit-message, #edit-commit-message {
22 margin: 1em 0 0 0;22 margin: 1em 0 0 0;
23 }23 }
24 #add-comment-form {
25 max-width: 60em;
26 padding-bottom: 3em;
27 }
28 #add-comment-form textarea{
29 width: 100%;
30 max-width: inherit;
31 }
32 #add-comment-form .actions {
33 float: right;
34 margin: 0 -0.5em;
35 }
36 #add-comment-review-fields {
37 margin-top: 1em;
38 }
39 #add-comment-review-fields div {
40 display: inline;
41 }
24 /* A page-specific fix for inline text are editing to line up box. */42 /* A page-specific fix for inline text are editing to line up box. */
25 #edit-commit-message .yui-ieditor-input { top: 0; }43 #edit-commit-message .yui-ieditor-input { top: 0; }
26 </style>44 </style>
@@ -92,6 +110,12 @@
92 </div>110 </div>
93111
94 <div class="yui-g">112 <div class="yui-g">
113 <tal:not-logged-in condition="not: view/user">
114 <div align="center" id="add-comment-login-first">
115 To post a comment you must <a href="+login">log in</a>.
116 </div>
117 </tal:not-logged-in>
118
95 <div tal:define="link menu/add_comment"119 <div tal:define="link menu/add_comment"
96 tal:condition="link/enabled"120 tal:condition="link/enabled"
97 tal:content="structure link/render">121 tal:content="structure link/render">
@@ -101,20 +125,27 @@
101 <div id="conversation"125 <div id="conversation"
102 tal:content="structure view/conversation/@@+render"/>126 tal:content="structure view/conversation/@@+render"/>
103 </div>127 </div>
104 <!-- Hide inline commenting if YUI isn't used. -->128
105 <div id="inline-add-comment" style="display: none">129 <tal:logged-in condition="view/user">
106 <tal:comment replace="structure context/@@+comment/++form++" />130 <div tal:define="comment_form nocall:context/@@+comment;
107 <div class="actions" id="launchpad-form-actions">131 dummy comment_form/initialize">
108 <input type="submit" id="field.actions.add" name="field.actions.add" value="Save Comment" class="button" />132 <h2 id="add-comment">Add comment</h2>
109 </div>133 <form action="+comment"
110 </div>134 method="post"
111135 enctype="multipart/form-data"
112 <script type="text/javascript">136 accept-charset="UTF-8"
113 LPS.use('lp.comment', function(Y) {137 id="add-comment-form">
114 var comment = new Y.lp.CodeReviewComment();138 <tal:comment-input replace="structure comment_form/widgets/comment"/>
115 comment.render();139 <div id="add-comment-review-fields">
116 })140 Review: <tal:review replace="structure comment_form/widgets/vote"/>
117 </script>141 Review type: <tal:review replace="structure comment_form/widgets/review_type"/>
142 <div class="actions"
143 tal:content="structure comment_form/actions/field.actions.add/render" />
144 </div>
145 </form>
146 </div>
147 </tal:logged-in>
148
118 <div class="yui-g">149 <div class="yui-g">
119 <div class="yui-u first">150 <div class="yui-u first">
120 <div id="source-revisions"151 <div id="source-revisions"
@@ -159,21 +190,25 @@
159 string:&lt;script id='codereview-script' type='text/javascript'&gt;" />190 string:&lt;script id='codereview-script' type='text/javascript'&gt;" />
160 conf = <tal:status-config replace="view/status_config" />191 conf = <tal:status-config replace="view/status_config" />
161 <!--192 <!--
162 LPS.use('io-base', 'code.codereview', 'code.branchmergeproposal',193 LPS.use('io-base', 'code.codereview', 'code.branchmergeproposal', 'lp.comment',
163 function(Y) {194 function(Y) {
164195
165196 Y.on('load', function() {
166 if(Y.UA.ie) {197 var logged_in = LP.client.links['me'] !== undefined;
167 return;198
168 }199 if (logged_in) {
169200 var comment = new Y.lp.CodeReviewComment();
170 Y.on('domready', function() {201 comment.render();
171 Y.code.codereview.connect_links();202
172 Y.code.branchmergeproposal.connect_status(conf);203 if(Y.UA.ie) {
173 });204 return;
174205 }
175 (new Y.codereview.NumberToggle()).render();206
176207 Y.code.codereview.connect_links();
208 Y.code.branchmergeproposal.connect_status(conf);
209 }
210 (new Y.codereview.NumberToggle()).render();
211 }, window);
177 });212 });
178 -->213 -->
179<tal:script replace="structure string:&lt;/script&gt;" />214<tal:script replace="structure string:&lt;/script&gt;" />
180215
=== modified file 'lib/lp/registry/browser/product.py'
--- lib/lp/registry/browser/product.py 2009-12-05 18:37:28 +0000
+++ lib/lp/registry/browser/product.py 2009-12-11 20:25:26 +0000
@@ -778,7 +778,7 @@
778 **additional_arguments)778 **additional_arguments)
779 self.show_programming_languages = bool(779 self.show_programming_languages = bool(
780 self.context.programminglang or780 self.context.programminglang or
781 self.user == self.context.owner)781 check_permission('launchpad.Edit', self.context))
782782
783 @property783 @property
784 def show_license_status(self):784 def show_license_status(self):
785785
=== modified file 'lib/lp/registry/browser/team.py'
--- lib/lp/registry/browser/team.py 2009-12-01 22:09:05 +0000
+++ lib/lp/registry/browser/team.py 2009-12-11 20:25:26 +0000
@@ -901,7 +901,6 @@
901 return None901 return None
902902
903903
904
905class ProposedTeamMembersEditView(LaunchpadFormView):904class ProposedTeamMembersEditView(LaunchpadFormView):
906 schema = Interface905 schema = Interface
907 label = 'Proposed team members'906 label = 'Proposed team members'
@@ -915,7 +914,10 @@
915 status = TeamMembershipStatus.APPROVED914 status = TeamMembershipStatus.APPROVED
916 elif action == "decline":915 elif action == "decline":
917 status = TeamMembershipStatus.DECLINED916 status = TeamMembershipStatus.DECLINED
918 elif action == "hold":917 else:
918 # The action is "hold" or no action was specified for this
919 # person, which could happen if the set of proposed members
920 # changed while the form was being processed.
919 continue921 continue
920922
921 self.context.setMembershipData(923 self.context.setMembershipData(
922924
=== modified file 'lib/lp/registry/templates/milestone-index.pt'
--- lib/lp/registry/templates/milestone-index.pt 2009-11-15 19:37:56 +0000
+++ lib/lp/registry/templates/milestone-index.pt 2009-12-11 20:25:26 +0000
@@ -53,12 +53,12 @@
53 tal:condition="view/milestone/series_target" /></dd>53 tal:condition="view/milestone/series_target" /></dd>
54 </dl>54 </dl>
5555
56 <dl>56 <dl id="version">
57 <dt>Version:</dt>57 <dt>Version:</dt>
58 <dd><tal:version replace="context/name" /></dd>58 <dd><tal:version replace="context/name" /></dd>
59 </dl>59 </dl>
6060
61 <dl>61 <dl id="code-name">
62 <dt>Code name:</dt>62 <dt>Code name:</dt>
63 <dd>63 <dd>
64 <tal:code-name replace="view/milestone/code_name" />64 <tal:code-name replace="view/milestone/code_name" />
6565
=== modified file 'lib/lp/registry/templates/product-new.pt'
--- lib/lp/registry/templates/product-new.pt 2009-12-03 18:33:22 +0000
+++ lib/lp/registry/templates/product-new.pt 2009-12-11 20:25:26 +0000
@@ -100,7 +100,7 @@
100 url_field.on('keyup', function(e) {100 url_field.on('keyup', function(e) {
101 if (url_field.get('value') == '') {101 if (url_field.get('value') == '') {
102 /* The user cleared the URL field; turn on autofill. */102 /* The user cleared the URL field; turn on autofill. */
103 name_field.attach('keyup', autofill);103 name_field.on('keyup', autofill);
104 }104 }
105 else {105 else {
106 /* Honor the user's URL; turn off autofill. */106 /* Honor the user's URL; turn off autofill. */
107107
=== renamed file 'lib/canonical/launchpad/windmill/tests/test_registry/test_add_milestone.py' => 'lib/lp/registry/windmill/tests/test_add_milestone.py'
--- lib/canonical/launchpad/windmill/tests/test_registry/test_add_milestone.py 2009-06-25 05:30:52 +0000
+++ lib/lp/registry/windmill/tests/test_add_milestone.py 2009-12-11 20:25:26 +0000
@@ -7,95 +7,94 @@
7__all__ = []7__all__ = []
88
9import time9import time
10import unittest
1011
11from canonical.launchpad.windmill.testing import lpuser12from canonical.launchpad.windmill.testing import lpuser
1213
13from windmill.authoring import WindmillTestClient14from windmill.authoring import WindmillTestClient
1415
1516from lp.registry.windmill.testing import RegistryWindmillLayer
16class InlineAddMilestoneForReleaseTest:17from lp.testing import TestCaseWithFactory
17 """Test adding a milestone inline."""18
1819
19 def __init__(self, name=None,20def test_inline_add_milestone(client, url, name=None, suite='milestone',
20 url='http://launchpad.dev:8085/bzr/trunk/+addrelease',21 user=lpuser.FOO_BAR):
21 suite='milestone', user=lpuser.FOO_BAR):22 """Test the form overlay for adding a milestone.
22 """Create a new InlineAddMilestoneForReleaseTest.23
2324 :param name: Name of the test.
24 :param name: Name of the test.25 :param url: Starting url.
25 :param url: Starting url.26 :param suite: The suite in which this test is part of.
26 :param suite: The suite in which this test is part of.27 :param user: The user who should be logged in.
27 :param user: The user who should be logged in.28 """
28 """29 # Ensure that the milestone name doesn't conflict with previous
29 self.url = url30 # test runs, and test that it correctly lowercases the name.
30 if name is None:31 milestone_name = u'FOObar%x' % int(time.time())
31 self.__name__ = 'test_%s_add_milestone' % suite32 code_name = u'code-%s' % milestone_name
32 else:33
33 self.__name__ = name34 user.ensure_login(client)
34 self.suite = suite35 client.open(url=url)
35 self.user = user36 client.waits.forPageLoad(timeout=u'20000')
36 self.client = None37
3738 client.waits.forElement(
38 def __call__(self):39 id=u'field.milestone_for_release', timeout=u'8000')
39 """Tests creating new milestone for a release."""40
40 # Ensure that the milestone name doesn't conflict with previous41 # Click the "Create milestone" link.
41 # test runs, and test that it correctly lowercases the name.42 client.click(id=u'create-milestone-link')
42 milestone_name = u'FOObar%x' % int(time.time())43
43 code_name = u'code-%s' % milestone_name44 # Submit milestone form.
4445 client.waits.forElement(id=u'field.name', timeout=u'8000')
45 self.client = WindmillTestClient(self.suite)46 client.type(id='field.name', text=milestone_name)
4647 client.type(id='field.code_name', text=code_name)
47 self.user.ensure_login(self.client)48 client.type(id='field.dateexpected', text=u"2004-01-05")
48 self.client.open(url=self.url)49 client.type(id='field.summary', text=u"foo bar")
49 self.client.waits.forPageLoad(timeout=u'20000')50 client.click(id=u'formoverlay-add-milestone')
5051
51 self.client.waits.forElement(id=u'field.milestone_for_release',52 # Verify that the milestone was added to the SELECT input,
52 timeout=u'8000')53 # and that it is now selected.
5354 client.waits.sleep(milliseconds='1000')
54 # Click the "Create milestone" link.55 client.asserts.assertSelected(id="field.milestone_for_release",
55 self.client.click(id=u'create-milestone-link')56 validator=milestone_name.lower())
5657
57 # Submit milestone form.58 # Verify error message when trying to create a milestone with a
58 self.client.waits.forElement(id=u'field.name', timeout=u'8000')59 # conflicting name.
59 self.client.type(id='field.name', text=milestone_name)60 client.click(id=u'create-milestone-link')
60 self.client.type(id='field.code_name', text=code_name)61 client.waits.forElement(id=u'field.name', timeout=u'8000')
61 self.client.type(id='field.dateexpected', text=u"2004-01-05")62 client.type(id='field.name', text=milestone_name)
62 self.client.type(id='field.summary', text=u"foo bar")63 client.click(id=u'formoverlay-add-milestone')
63 self.client.click(id=u'formoverlay-add-milestone')64 client.asserts.assertTextIn(
6465 classname='yui-lazr-formoverlay-errors',
65 # Verify that the milestone was added to the SELECT input,66 validator='The name %s is already used' % milestone_name.lower())
66 # and that it is now selected.67 client.click(classname='close-button')
67 self.client.waits.sleep(milliseconds='1000')68
68 self.client.asserts.assertSelected(id="field.milestone_for_release",69 # Submit product release form.
69 validator=milestone_name.lower())70 client.select(id='field.milestone_for_release',
7071 val=milestone_name.lower())
71 # Verify error message when trying to create a milestone with a72 client.type(id='field.datereleased', text=u"2004-02-22")
72 # conflicting name.73 client.click(id=u'field.actions.create')
73 self.client.click(id=u'create-milestone-link')74 client.waits.forPageLoad(timeout=u'20000')
74 self.client.waits.forElement(id=u'field.name', timeout=u'8000')75
75 self.client.type(id='field.name', text=milestone_name)76 # Verify that the release was created.
76 self.client.click(id=u'formoverlay-add-milestone')77 client.waits.forElement(id="version")
77 self.client.asserts.assertText(78 client.asserts.assertText(
78 id='milestone-error',79 xpath="//*[@id='version']/dd", validator=milestone_name.lower())
79 validator='The name %s is already used' % milestone_name.lower())80 client.asserts.assertText(
80 self.client.click(classname='close-button')81 xpath="//*[@id='code-name']/dd", validator=code_name)
8182
82 # Submit product release form.83
83 self.client.select(id='field.milestone_for_release',84class TestAddMilestone(TestCaseWithFactory):
84 val=milestone_name.lower())85 """Test form overlay widget for adding a milestone."""
85 self.client.type(id='field.datereleased', text=u"2004-02-22")86
86 self.client.click(id=u'field.actions.create')87 layer = RegistryWindmillLayer
87 self.client.waits.forPageLoad(timeout=u'20000')88
8889 def setUp(self):
89 # Verify that the release was created.90 self.client = WindmillTestClient('AddMilestone')
90 milestone_xpath = (91
91 "//table[@id='series_trunk']//a[@href='/bzr/+milestone/%s']"92 def test_adding_milestone_on_addrelease_page(self):
92 % milestone_name.lower())93 test_inline_add_milestone(
93 self.client.waits.forElement(xpath=milestone_xpath, timeout=u'8000')94 self.client,
94 self.client.asserts.assertText(95 url='http://launchpad.dev:8085/bzr/trunk/+addrelease',
95 xpath=milestone_xpath, validator=milestone_name.lower())96 name='test_inline_add_milestone_for_release')
96 self.client.asserts.assertText(97
97 xpath=milestone_xpath, validator=code_name)98
9899def test_suite():
99100 return unittest.TestLoader().loadTestsFromName(__name__)
100test_inline_add_milestone_for_release = InlineAddMilestoneForReleaseTest(
101 name='test_inline_add_milestone_for_release')
102101
=== renamed file 'lib/canonical/launchpad/windmill/tests/test_registry/test_datetime_picker.py' => 'lib/lp/registry/windmill/tests/test_datetime_picker.py'
--- lib/canonical/launchpad/windmill/tests/test_registry/test_datetime_picker.py 2009-06-25 05:30:52 +0000
+++ lib/lp/registry/windmill/tests/test_datetime_picker.py 2009-12-11 20:25:26 +0000
@@ -6,57 +6,75 @@
6__metaclass__ = type6__metaclass__ = type
7__all__ = []7__all__ = []
88
9import unittest
10
11from windmill.authoring import WindmillTestClient
12
9from canonical.launchpad.windmill.testing import lpuser13from canonical.launchpad.windmill.testing import lpuser
1014
11from windmill.authoring import WindmillTestClient15from lp.registry.windmill.testing import RegistryWindmillLayer
1216from lp.testing import TestCaseWithFactory
13def test_datetime_calendar_widget():17
14 """Test the calendar widget's general functionality.18
1519class TestDateTimeCalendarWidget(TestCaseWithFactory):
16 This test ensures that, with Javascript enabled, an input field20 """Test datetime calendar widget."""
17 with the 'yui-calendar' class will get an extra 'choose...' link21
18 which opens up a calendar widget. The extra class 'withtime' is22 layer = RegistryWindmillLayer
19 used to optionally include time fields.23
20 """24 def setUp(self):
21 client = WindmillTestClient("Datetime calendar widget test")25 self.client = WindmillTestClient('DateTimeCalendarWidget')
22 lpuser.SAMPLE_PERSON.ensure_login(client)26
2327 def test_datetime_calendar_widget(self):
24 # Open a new sprint page and wait for it to finish loading.28 """Test the calendar widget's general functionality.
25 client.open(url=u'http://blueprints.launchpad.dev:8085/sprints/+new')29
26 client.waits.forPageLoad(timeout=u'20000')30 This test ensures that, with Javascript enabled, an input field
27 client.waits.forElement(link=u'Choose...', timeout=u'8000')31 with the 'yui-calendar' class will get an extra 'choose...' link
2832 which opens up a calendar widget. The extra class 'withtime' is
29 # Enter a date directly in the field first (which will ensure33 used to optionally include time fields.
30 # the calendar widget opens with this date.)34 """
31 client.click(id=u'field.time_starts')35 lpuser.SAMPLE_PERSON.ensure_login(self.client)
32 client.type(text=u'2009-05-08 10:04', id=u'field.time_starts')36
3337 # Open a new sprint page and wait for it to finish loading.
34 # Open the calendar widget38 self.client.open(
35 client.click(link=u'Choose...')39 url=u'http://blueprints.launchpad.dev:8085/sprints/+new')
3640 self.client.waits.forPageLoad(timeout=u'20000')
37 # Initially choose the 21st of May 2009 and verify that the input41 self.client.waits.forElement(link=u'Choose...', timeout=u'8000')
38 # field's value has changed.42
39 client.click(link=u'21')43 # Enter a date directly in the field first (which will ensure
40 client.asserts.assertValue(validator=u'2009-05-21 10:04',44 # the calendar widget opens with this date.)
41 id=u'field.time_starts')45 self.client.click(id=u'field.time_starts')
4246 self.client.type(text=u'2009-05-08 10:04', id=u'field.time_starts')
43 # Navigate to the next month, select the 9th, enter a time of 10:3047
44 # and click the close/confirm button, then verify the correct value48 # Open the calendar widget
45 # is in the field.49 self.client.click(link=u'Choose...')
46 client.click(link=u'Next Month (June 2009)')50
47 client.click(link=u'9')51 # Initially choose the 21st of May 2009 and verify that the input
48 client.type(52 # field's value has changed.
49 xpath=(u"//div[@id='calendar_container-field.time_starts']"53 self.client.click(link=u'21')
50 u"/div[2]/input"),54 self.client.asserts.assertValue(
51 text=u'10')55 validator=u'2009-05-21 10:04', id=u'field.time_starts')
5256
53 client.type(57 # Navigate to the next month, select the 9th, enter a time of 10:30
54 xpath=(u"//div[@id='calendar_container-field.time_starts']"58 # and click the close/confirm button, then verify the correct value
55 u"/div[2]/input[2]"),59 # is in the field.
56 text=u'30')60 self.client.click(link=u'Next Month (June 2009)')
5761 self.client.click(link=u'9')
58 client.click(xpath=(u"//div[@id='calendar_container-field.time_starts']"62 self.client.type(
59 u"/div[2]/button"))63 xpath=(u"//div[@id='calendar_container-field.time_starts']"
60 client.asserts.assertValue(validator=u'2009-06-09 10:30',64 u"/div[2]/input"),
61 id=u'field.time_starts')65 text=u'10')
6266
67 self.client.type(
68 xpath=(u"//div[@id='calendar_container-field.time_starts']"
69 u"/div[2]/input[2]"),
70 text=u'30')
71
72 self.client.click(
73 xpath=(u"//div[@id='calendar_container-field.time_starts']"
74 u"/div[2]/button"))
75 self.client.asserts.assertValue(
76 validator=u'2009-06-09 10:30', id=u'field.time_starts')
77
78
79def test_suite():
80 return unittest.TestLoader().loadTestsFromName(__name__)
6381
=== renamed file 'lib/canonical/launchpad/windmill/tests/test_registry/test_plusnew_step1.py' => 'lib/lp/registry/windmill/tests/test_plusnew_step1.py'
--- lib/canonical/launchpad/windmill/tests/test_registry/test_plusnew_step1.py 2009-06-25 05:30:52 +0000
+++ lib/lp/registry/windmill/tests/test_plusnew_step1.py 2009-12-11 20:25:26 +0000
@@ -1,48 +1,72 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test form for creating a new project."""
5
6__metaclass__ = type
7__all__ = []
8
9import unittest
10
4from windmill.authoring import WindmillTestClient11from windmill.authoring import WindmillTestClient
512
6from canonical.launchpad.windmill.testing import lpuser13from canonical.launchpad.windmill.testing import lpuser
714
815from lp.registry.windmill.testing import RegistryWindmillLayer
9def test_projects_plusnew_text_fields():16from lp.testing import TestCaseWithFactory
10 """Test the text fields on step 1 of projects/+new page.17
1118BACKSPACE = u'\x08'
12 On step 1 of the wizard, the URL field gets autofilled from the Name19
13 field. Also, the URL field will not accept invalid characters.20
14 """21class TestNewProjectStep1(TestCaseWithFactory):
15 client = WindmillTestClient('projects/+new step one dynamism')22 """Test form for creating a new project."""
16 lpuser.SAMPLE_PERSON.ensure_login(client)23
1724 layer = RegistryWindmillLayer
18 # Perform step 1 of the project registration, using information that will25
19 # yield search results.26 def setUp(self):
20 client.open(url=u'http://launchpad.dev:8085/projects/+new')27 self.client = WindmillTestClient('TestNewProjectStep1')
21 client.waits.forPageLoad(timeout=u'20000')28
2229 def test_projects_plusnew_text_fields(self):
23 client.type(text=u'dolphin', id='field.displayname')30 """Test the text fields on step 1 of projects/+new page.
24 # The field is forced to lower case by a CSS text-transform, but that's31
25 # presentation and not testable. However, the field /is/ autofilled from32 On step 1 of the wizard, the URL field gets autofilled from the Name
26 # the displayname field, and this we can test.33 field. Also, the URL field will not accept invalid characters.
27 client.asserts.assertValue(34 """
28 id=u'field.name',35 # Perform step 1 of the project registration, using information
29 validator=u'dolphin')36 # that will yield search results.
30 # If we type into the Name field something that contains some trailing37 self.client.open(url=u'http://launchpad.dev:8085/projects/+new')
31 # invalid characters, they don't end up in the URL field.38
32 client.type(text=u'dol@phin', id='field.displayname')39 lpuser.SAMPLE_PERSON.ensure_login(self.client)
33 client.asserts.assertValue(40
34 id=u'field.name',41 self.client.waits.forElement(id='field.displayname')
35 validator=u'dol')42 self.client.type(text=u'dolphin', id='field.displayname')
36 # Typing directly into the URL field prevents the autofilling.43
37 client.type(text=u'mongoose', id='field.name')44 # The field is forced to lower case by a CSS text-transform, but
38 client.type(text=u'dingo', id='field.displayname')45 # that's presentation and not testable. However, the field /is/
39 client.asserts.assertValue(46 # autofilled from the displayname field, and this we can test.
40 id=u'field.name',47 self.client.asserts.assertValue(
41 validator=u'mongoose')48 id=u'field.name',
42 # But once we clear the URL field, autofilling is re-enabled. Type a49 validator=u'dolphin')
43 # backspace character to trigger this.50 # If we type into the Name field something that contains some trailing
44 client.type(text=u'\x08', id='field.name')51 # invalid characters, they don't end up in the URL field.
45 client.type(text='hyena', id='field.displayname')52 self.client.type(text=u'dol@phin', id='field.displayname')
46 client.asserts.assertValue(53 self.client.asserts.assertValue(
47 id=u'field.name',54 id=u'field.name',
48 validator=u'hyena')55 validator=u'dol')
56 # Typing directly into the URL field prevents the autofilling.
57 self.client.type(text=u'mongoose', id='field.name')
58 self.client.type(text=u'dingo', id='field.displayname')
59 self.client.asserts.assertValue(
60 id=u'field.name',
61 validator=u'mongoose')
62 # But once we clear the URL field, autofilling is re-enabled. Type a
63 # backspace character to trigger this.
64 self.client.type(text=BACKSPACE, id='field.name')
65 self.client.type(text='hyena', id='field.displayname')
66 self.client.asserts.assertValue(
67 id=u'field.name',
68 validator=u'hyena')
69
70
71def test_suite():
72 return unittest.TestLoader().loadTestsFromName(__name__)
4973
=== renamed file 'lib/canonical/launchpad/windmill/tests/test_registry/test_plusnew_step2.py' => 'lib/lp/registry/windmill/tests/test_plusnew_step2.py'
--- lib/canonical/launchpad/windmill/tests/test_registry/test_plusnew_step2.py 2009-07-21 17:14:29 +0000
+++ lib/lp/registry/windmill/tests/test_plusnew_step2.py 2009-12-11 20:25:26 +0000
@@ -1,68 +1,97 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test for form for creating a project."""
5
6__metaclass__ = type
7__all__ = []
8
9import unittest
10
4from windmill.authoring import WindmillTestClient11from windmill.authoring import WindmillTestClient
512
6from canonical.launchpad.windmill.testing import lpuser13from canonical.launchpad.windmill.testing import lpuser
714
815from lp.registry.windmill.testing import RegistryWindmillLayer
9def test_projects_plusnew_step_two():16from lp.testing import TestCaseWithFactory
10 """Test the dynamic aspects of step 2 of projects/+new page.17
1118
12 When the project being registered matches existing projects, the step two19class TestNewProjectStep2(TestCaseWithFactory):
13 page has some extra javascript-y goodness. At the start, there's a 'No'20 """Test form for creating a new project."""
14 button that hides the search results and reveals the rest of the project21
15 registration form. After that, there's a href that toggles between22 layer = RegistryWindmillLayer
16 revealing the search results and hiding them.23
17 """24 def setUp(self):
18 client = WindmillTestClient('projects/+new step two dynamism')25 self.client = WindmillTestClient('TestNewProjectStep2')
19 lpuser.SAMPLE_PERSON.ensure_login(client)26
2027 def test_projects_plusnew_step_two(self):
21 # Perform step 1 of the project registration, using information that will28 """Test the dynamic aspects of step 2 of projects/+new page.
22 # yield search results.29
23 client.open(url=u'http://launchpad.dev:8085/projects/+new')30 When the project being registered matches existing projects, the
24 client.waits.forPageLoad(timeout=u'20000')31 step two page has some extra javascript-y goodness. At the
2532 start, there's a 'No' button that hides the search results and
26 client.type(text=u'Badgers', id='field.displayname')33 reveals the rest of the project registration form. After that,
27 client.type(text=u'badgers', id='field.name')34 there's a href that toggles between revealing the search results
28 client.type(text=u"There's the Badger", id='field.title')35 and hiding them.
29 client.type(text=u'Badgers ate my firefox', id='field.summary')36 """
30 client.click(id=u'field.actions.continue')37
31 client.waits.forPageLoad(timeout=u'20000')38 # Perform step 1 of the project registration, using information
32 # The h2 heading indicates that a search was performed.39 # that will yield search results.
33 client.asserts.assertText(40 self.client.open(url=u'http://launchpad.dev:8085/projects/+new')
34 id=u'step-title',41
35 validator=u'Check for duplicate projects')42 lpuser.SAMPLE_PERSON.ensure_login(self.client)
36 # Clicking on the "No" button hides the button and search results, reveals43
37 # the form widgets, and reveals an href link for toggling the search44 self.client.waits.forElement(id='field.displayname', timeout=u'20000')
38 # results. It also changes the h2 title to something more appropriate.45 self.client.type(text=u'Badgers', id='field.displayname')
39 client.click(id=u'registration-details-buttons')46 self.client.type(text=u'badgers', id='field.name')
40 client.asserts.assertText(47 self.client.type(text=u"There's the Badger", id='field.title')
41 id=u'step-title',48 self.client.type(text=u'Badgers ate my firefox', id='field.summary')
42 validator=u'Registration details')49 self.client.click(id=u'field.actions.continue')
43 # The className for hidden elements is lazr-closed because it's set by50 self.client.waits.forPageLoad(timeout=u'20000')
44 # the slide-in effect. For slide-out elements, it's lazr-opened.51 # The h2 heading indicates that a search was performed.
45 client.asserts.assertProperty(52 self.client.asserts.assertTextIn(
46 id='search-results', validator='className|lazr-closed')53 id=u'step-title',
47 client.asserts.assertProperty(54 validator=u'Check for duplicate projects')
48 id=u'launchpad-form-widgets',55
49 validator='className|lazr-opened')56 # Clicking on the "No" button hides the button and search
50 client.asserts.assertNotProperty(57 # results, reveals the form widgets, and reveals an href link
51 id=u'search-results-expander',58 # for toggling the search results. It also changes the h2 title
52 validator='className|unseen')59 # to something more appropriate.
53 # Clicking on the href expands the search results.60 self.client.click(id=u'registration-details-buttons')
54 client.click(id='search-results-expander')61 self.client.asserts.assertTextIn(
55 client.waits.forElement(62 id=u'step-title',
56 xpath='//*[@id="search-results" and contains(@class, "lazr-opened")]',63 validator=u'Registration details')
57 milliseconds=u'1000')64
58 client.asserts.assertProperty(65 # The className for hidden elements is lazr-closed because it's
59 id=u'search-results',66 # set by the slide-in effect. For slide-out elements, it's
60 validator='className|lazr-opened')67 # lazr-opened.
61 # Clicking it again hides the results.68 self.client.asserts.assertProperty(
62 client.click(id='search-results-expander')69 id='search-results', validator='className|lazr-closed')
63 client.waits.forElement(70 self.client.asserts.assertProperty(
64 xpath='//*[@id="search-results" and contains(@class, "lazr-closed")]',71 id=u'launchpad-form-widgets',
65 milliseconds=u'1000')72 validator='className|lazr-opened')
66 client.asserts.assertProperty(73 self.client.asserts.assertNotProperty(
67 id=u'search-results',74 id=u'search-results-expander',
68 validator='className|lazr-closed')75 validator='className|unseen')
76 # Clicking on the href expands the search results.
77 self.client.click(id='search-results-expander')
78 self.client.waits.forElement(
79 xpath='//*[@id="search-results" '
80 'and contains(@class, "lazr-opened")]',
81 milliseconds=u'1000')
82 self.client.asserts.assertProperty(
83 id=u'search-results',
84 validator='className|lazr-opened')
85 # Clicking it again hides the results.
86 self.client.click(id='search-results-expander')
87 self.client.waits.forElement(
88 xpath='//*[@id="search-results" '
89 'and contains(@class, "lazr-closed")]',
90 milliseconds=u'1000')
91 self.client.asserts.assertProperty(
92 id=u'search-results',
93 validator='className|lazr-closed')
94
95
96def test_suite():
97 return unittest.TestLoader().loadTestsFromName(__name__)
6998
=== renamed file 'lib/canonical/launchpad/windmill/tests/test_registry/test_product.py' => 'lib/lp/registry/windmill/tests/test_product.py'
--- lib/canonical/launchpad/windmill/tests/test_registry/test_product.py 2009-07-17 00:26:05 +0000
+++ lib/lp/registry/windmill/tests/test_product.py 2009-12-11 20:25:26 +0000
@@ -1,24 +1,46 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4from canonical.launchpad.windmill.testing import lpuser4"""Test product index page."""
5from canonical.launchpad.windmill.testing import widgets5
66__metaclass__ = type
7test_title_inline_edit = widgets.InlineEditorWidgetTest(7__all__ = []
8 url='http://launchpad.dev:8085/firefox',8
9 widget_id='product-title',9import unittest
10 expected_value='Mozilla Firefox',10
11 new_value='The awesome Mozilla Firefox',11from canonical.launchpad.windmill.testing import lpuser, widgets
12 name='test_title_inline_edit',12
13 suite=__name__,13from lp.registry.windmill.testing import RegistryWindmillLayer
14 user=lpuser.SAMPLE_PERSON)14from lp.testing import TestCaseWithFactory
1515
16test_programming_languages_edit = widgets.InlineEditorWidgetTest(16class TestProductIndexPage(TestCaseWithFactory):
17 url='http://launchpad.dev:8085/firefox',17 """Test product index page."""
18 widget_id='programminglang',18
19 widget_tag='span',19 layer = RegistryWindmillLayer
20 expected_value='Not yet specified',20
21 new_value='C++',21 def test_title_inline_edit(self):
22 name='test_proglang_inline_edit',22 test = widgets.InlineEditorWidgetTest(
23 suite=__name__,23 url='http://launchpad.dev:8085/firefox',
24 user=lpuser.SAMPLE_PERSON)24 widget_id='product-title',
25 expected_value='Mozilla Firefox',
26 new_value='The awesome Mozilla Firefox',
27 name='test_title_inline_edit',
28 suite=__name__,
29 user=lpuser.SAMPLE_PERSON)
30 test()
31
32 def test_programming_languages_edit(self):
33 test = widgets.InlineEditorWidgetTest(
34 url='http://launchpad.dev:8085/firefox',
35 widget_id='programminglang',
36 widget_tag='span',
37 expected_value='Not yet specified',
38 new_value='C++',
39 name='test_proglang_inline_edit',
40 suite=__name__,
41 user=lpuser.SAMPLE_PERSON)
42 test()
43
44
45def test_suite():
46 return unittest.TestLoader().loadTestsFromName(__name__)
2547
=== renamed file 'lib/canonical/launchpad/windmill/tests/test_registry/test_product_edit_people.py' => 'lib/lp/registry/windmill/tests/test_product_edit_people.py'
--- lib/canonical/launchpad/windmill/tests/test_registry/test_product_edit_people.py 2009-07-17 00:26:05 +0000
+++ lib/lp/registry/windmill/tests/test_product_edit_people.py 2009-12-11 20:25:26 +0000
@@ -1,23 +1,44 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test picker on +edit-people page."""
5
6__metaclass__ = type
7__all__ = []
8
9import unittest
10
4from canonical.launchpad.windmill.testing.widgets import (11from canonical.launchpad.windmill.testing.widgets import (
5 FormPickerWidgetTest)12 FormPickerWidgetTest)
613
714from lp.registry.windmill.testing import RegistryWindmillLayer
8test_product_edit_people_driver = FormPickerWidgetTest(15from lp.testing import TestCaseWithFactory
9 name='test_product_edit_people_driver',16
10 url='http://launchpad.dev:8085/firefox/+edit-people',17class TestProductEditPeople(TestCaseWithFactory):
11 short_field_name='driver',18 """Test picker +edit-people page."""
12 search_text='Perell\xc3\xb3',19
13 result_index=1,20 layer = RegistryWindmillLayer
14 new_value='carlos')21
1522 def test_product_edit_people_driver(self):
16test_product_edit_people_owner = FormPickerWidgetTest(23 test = FormPickerWidgetTest(
17 name='test_product_edit_people_owner',24 name='test_product_edit_people_driver',
18 url='http://launchpad.dev:8085/firefox/+edit-people',25 url='http://launchpad.dev:8085/firefox/+edit-people',
19 short_field_name='owner',26 short_field_name='driver',
20 search_text='guadamen',27 search_text='Perell\xc3\xb3',
21 result_index=1,28 result_index=1,
22 new_value='guadamen')29 new_value='carlos')
2330 test()
31
32 def test_product_edit_people_owner(self):
33 test = FormPickerWidgetTest(
34 name='test_product_edit_people_owner',
35 url='http://launchpad.dev:8085/firefox/+edit-people',
36 short_field_name='owner',
37 search_text='guadamen',
38 result_index=1,
39 new_value='guadamen')
40 test()
41
42
43def test_suite():
44 return unittest.TestLoader().loadTestsFromName(__name__)
2445
=== renamed file 'lib/canonical/launchpad/windmill/tests/test_registry/test_project_licenses.py' => 'lib/lp/registry/windmill/tests/test_project_licenses.py'
--- lib/canonical/launchpad/windmill/tests/test_registry/test_project_licenses.py 2009-07-17 02:25:09 +0000
+++ lib/lp/registry/windmill/tests/test_project_licenses.py 2009-12-11 20:25:26 +0000
@@ -1,131 +1,151 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test project licenses picker."""
5
6__metaclass__ = type
7__all__ = []
8
9import unittest
10
4from windmill.authoring import WindmillTestClient11from windmill.authoring import WindmillTestClient
512
6from canonical.launchpad.windmill.testing import lpuser13from canonical.launchpad.windmill.testing import lpuser
714
815from lp.registry.windmill.testing import RegistryWindmillLayer
9def test_project_licenses():16from lp.testing import TestCaseWithFactory
10 """Test the dynamic aspects of the project license picker."""17
11 client = WindmillTestClient('firefox/+edit license picking')18
12 lpuser.SAMPLE_PERSON.ensure_login(client)19class TestProjectLicenses(TestCaseWithFactory):
1320 """Test project licenses picker."""
14 # The firefox project is as good as any.21
15 client.open(url=u'http://launchpad.dev:8085/firefox/+edit')22 layer = RegistryWindmillLayer
16 client.waits.forPageLoad(timeout=u'20000')23
1724 def setUp(self):
18 # The Recommended table is visible.25 self.client = WindmillTestClient('TestProjectLicenses')
19 client.asserts.assertProperty(26
20 id=u'recommended',27 def test_project_licenses(self):
21 validator='className|lazr-opened')28 """Test the dynamic aspects of the project license picker."""
22 # But the More table is not.29 # The firefox project is as good as any.
23 client.asserts.assertProperty(30 self.client.open(url=u'http://launchpad.dev:8085/firefox/+edit')
24 id=u'more',31 self.client.waits.forPageLoad(timeout=u'20000')
25 validator='className|lazr-closed')32
26 # Neither is the Other choices.33 lpuser.SAMPLE_PERSON.ensure_login(self.client)
27 client.asserts.assertProperty(34
28 id=u'special',35 # The Recommended table is visible.
29 validator='className|lazr-closed')36 self.client.waits.forElementProperty(
3037 id=u'recommended',
31 # Clicking on the link exposes the More section though.38 option='className|lazr-opened')
32 client.click(id='more-expand')39 # But the More table is not.
33 client.waits.sleep(milliseconds=u'1000')40 self.client.asserts.assertProperty(
34 client.asserts.assertProperty(41 id=u'more',
35 id=u'more',42 validator='className|lazr-closed')
36 validator='className|lazr-opened')43 # Neither is the Other choices.
3744 self.client.asserts.assertProperty(
38 # As does clicking on the Other choices section.45 id=u'special',
39 client.click(id='special-expand')46 validator='className|lazr-closed')
40 client.waits.sleep(milliseconds=u'1000')47
41 client.asserts.assertProperty(48 # Clicking on the link exposes the More section though.
42 id=u'special',49 self.client.click(id='more-expand')
43 validator='className|lazr-opened')50 self.client.waits.forElementProperty(
4451 id=u'more',
45 # Clicking on any opened link closes the section.52 option='className|lazr-opened')
46 client.click(id='recommended-expand')53
47 client.asserts.assertProperty(54 # As does clicking on the Other choices section.
48 id=u'recommended',55 self.client.click(id='special-expand')
49 validator='className|lazr-closed')56 self.client.waits.forElementProperty(
5057 id=u'special',
51 # The license details box starts out hidden.58 option='className|lazr-opened')
52 client.asserts.assertProperty(59
53 id=u'license-details',60 # Clicking on any opened link closes the section.
54 validator='className|lazr-closed')61 self.client.click(id='recommended-expand')
5562 self.client.waits.forElementProperty(
56 # But clicking on one of the Other/* licenses exposes it.63 id=u'recommended',
57 client.click(id='field.licenses.26')64 option='className|lazr-closed')
58 client.asserts.assertProperty(65
59 id=u'license-details',66 # The license details box starts out hidden.
60 validator='className|lazr-opened')67 self.client.asserts.assertProperty(
6168 id=u'license-details',
62 # Clicking on Other/Proprietary exposes the additional commercial69 validator='className|lazr-closed')
63 # licensing details.70
64 client.asserts.assertProperty(71 # But clicking on one of the Other/* licenses exposes it.
65 id=u'proprietary',72 self.client.click(id='field.licenses.26')
66 validator='className|lazr-closed')73 self.client.asserts.assertProperty(
6774 id=u'license-details',
68 client.click(id='field.licenses.25')75 validator='className|lazr-opened')
69 client.asserts.assertProperty(76
70 id=u'license-details',77 # Clicking on Other/Proprietary exposes the additional commercial
71 validator='className|lazr-opened')78 # licensing details.
72 client.asserts.assertProperty(79 self.client.asserts.assertProperty(
73 id=u'proprietary',80 id=u'proprietary',
74 validator='className|lazr-opened')81 validator='className|lazr-closed')
7582
76 # Only when all Other/* items are unchecked does the details box get83 self.client.click(id='field.licenses.25')
77 # hidden.84 self.client.asserts.assertProperty(
78 client.click(id='field.licenses.26')85 id=u'license-details',
79 client.asserts.assertProperty(86 validator='className|lazr-opened')
80 id=u'license-details',87 self.client.asserts.assertProperty(
81 validator='className|lazr-opened')88 id=u'proprietary',
8289 validator='className|lazr-opened')
83 client.click(id='field.licenses.25')90
84 client.asserts.assertProperty(91 # Only when all Other/* items are unchecked does the details box get
85 id=u'license-details',92 # hidden.
86 validator='className|lazr-closed')93 self.client.click(id='field.licenses.26')
87 client.asserts.assertProperty(94 self.client.asserts.assertProperty(
88 id=u'proprietary',95 id=u'license-details',
89 validator='className|lazr-closed')96 validator='className|lazr-opened')
9097
91 # Clicking on "I haven't specified..." unchecks everything and closes the98 self.client.click(id='field.licenses.25')
92 # details box, but leaves the sections opened.99 self.client.waits.forElementProperty(
93 client.click(id='field.licenses.25')100 id=u'license-details',
94 client.asserts.assertProperty(101 option='className|lazr-closed')
95 id=u'license-details',102 self.client.asserts.assertProperty(
96 validator='className|lazr-opened')103 id=u'proprietary',
97104 validator='className|lazr-closed')
98 client.asserts.assertChecked(105
99 id=u'field.licenses.25')106 # Clicking on "I haven't specified..." unchecks everything and
100107 # closes the details box, but leaves the sections opened.
101 client.click(id='license_pending')108
102 client.asserts.assertNotChecked(109 self.client.click(id='field.licenses.25')
103 id=u'field.licenses.25')110 self.client.waits.forElementProperty(
104 111 id=u'license-details',
105 client.asserts.assertProperty(112 option='className|lazr-opened')
106 id=u'license-details',113
107 validator='className|lazr-closed')114 self.client.asserts.assertChecked(
108115 id=u'field.licenses.25')
109 # Submitting the form with items checked ensures that the next time the116
110 # page is visited, those sections will be open. The Recommended section117 self.client.click(id='license_pending')
111 # is always open.118 self.client.asserts.assertNotChecked(
112119 id=u'field.licenses.25')
113 client.click(id='field.licenses.25')120
114 client.type(id='field.license_info', text='Foo bar')121 self.client.asserts.assertProperty(
115 client.click(id='field.licenses.3')122 id=u'license-details',
116 client.click(id='field.actions.change')123 validator='className|lazr-closed')
117 client.waits.forPageLoad(timeout=u'20000')124
118125 # Submitting the form with items checked ensures that the next
119 client.open(url=u'http://launchpad.dev:8085/firefox/+edit')126 # time the page is visited, those sections will be open. The
120 client.waits.forPageLoad(timeout=u'20000')127 # Recommended section is always open.
121128
122 client.asserts.assertProperty(129 self.client.click(id='field.licenses.25')
123 id=u'more',130 self.client.type(id='field.license_info', text='Foo bar')
124 validator='className|lazr-opened')131 self.client.click(id='field.licenses.3')
125 # Neither is the Other choices.132 self.client.click(id='field.actions.change')
126 client.asserts.assertProperty(133 self.client.waits.forPageLoad(timeout=u'20000')
127 id=u'special',134
128 validator='className|lazr-opened')135 self.client.open(url=u'http://launchpad.dev:8085/firefox/+edit')
129 client.asserts.assertProperty(136 self.client.waits.forPageLoad(timeout=u'20000')
130 id=u'license-details',137
131 validator='className|lazr-opened')138 self.client.asserts.assertProperty(
139 id=u'more',
140 validator='className|lazr-opened')
141 # Neither is the Other choices.
142 self.client.asserts.assertProperty(
143 id=u'special',
144 validator='className|lazr-opened')
145 self.client.asserts.assertProperty(
146 id=u'license-details',
147 validator='className|lazr-opened')
148
149
150def test_suite():
151 return unittest.TestLoader().loadTestsFromName(__name__)
132152
=== modified file 'lib/lp/registry/windmill/tests/test_timeline_graph.py'
--- lib/lp/registry/windmill/tests/test_timeline_graph.py 2009-10-29 13:40:37 +0000
+++ lib/lp/registry/windmill/tests/test_timeline_graph.py 2009-12-11 20:25:26 +0000
@@ -1,6 +1,11 @@
1# Copyright 2009 Canonical Ltd. This software is licensed under the1# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Test for timeline graph widget."""
5
6__metaclass__ = type
7__all__ = []
8
4import unittest9import unittest
510
6from windmill.authoring import WindmillTestClient11from windmill.authoring import WindmillTestClient
@@ -9,6 +14,7 @@
9from lp.testing import TestCaseWithFactory14from lp.testing import TestCaseWithFactory
1015
11class TestTimelineGraph(TestCaseWithFactory):16class TestTimelineGraph(TestCaseWithFactory):
17 """Test timeline graph widget."""
1218
13 layer = RegistryWindmillLayer19 layer = RegistryWindmillLayer
1420
1521
=== modified file 'lib/lp/translations/tests/test_translationimportqueue.py'
--- lib/lp/translations/tests/test_translationimportqueue.py 2009-11-19 11:24:43 +0000
+++ lib/lp/translations/tests/test_translationimportqueue.py 2009-12-11 20:25:26 +0000
@@ -5,6 +5,7 @@
55
6__metaclass__ = type6__metaclass__ = type
77
8import transaction
8import unittest9import unittest
910
10from zope.component import getUtility11from zope.component import getUtility
@@ -17,25 +18,27 @@
17from canonical.testing import LaunchpadZopelessLayer18from canonical.testing import LaunchpadZopelessLayer
1819
1920
20class TestTranslationImportQueueEntryStatus(TestCaseWithFactory):21class TestCanSetStatusBase(TestCaseWithFactory):
21 """Test handling of the status of a queue entry."""22 """Base for tests that check that canSetStatus works ."""
2223
23 layer = LaunchpadZopelessLayer24 layer = LaunchpadZopelessLayer
25 dbuser = None
26 entry = None
2427
25 def setUp(self):28 def setUp(self):
26 """Set up context to test in."""29 """Set up context to test in."""
27 super(TestTranslationImportQueueEntryStatus, self).setUp()30 super(TestCanSetStatusBase, self).setUp()
2831
29 self.queue = getUtility(ITranslationImportQueue)32 self.queue = getUtility(ITranslationImportQueue)
30 self.rosetta_experts = (33 self.rosetta_experts = (
31 getUtility(ILaunchpadCelebrities).rosetta_experts)34 getUtility(ILaunchpadCelebrities).rosetta_experts)
32 self.productseries = self.factory.makeProductSeries()35 self.productseries = self.factory.makeProductSeries()
33 self.uploaderperson = self.factory.makePerson()36 self.uploaderperson = self.factory.makePerson()
34 self.potemplate = self.factory.makePOTemplate(37
35 productseries=self.productseries)38 def _switch_dbuser(self):
36 self.entry = self.queue.addOrUpdateEntry(39 if self.dbuser != None:
37 'demo.pot', '#demo', False, self.uploaderperson,40 transaction.commit()
38 productseries=self.productseries, potemplate=self.potemplate)41 self.layer.switchDbUser(self.dbuser)
3942
40 def _assertCanSetStatus(self, user, entry, expected_list):43 def _assertCanSetStatus(self, user, entry, expected_list):
41 # Helper to check for all statuses.44 # Helper to check for all statuses.
@@ -49,6 +52,7 @@
49 RosettaImportStatus.IMPORTED,52 RosettaImportStatus.IMPORTED,
50 RosettaImportStatus.NEEDS_REVIEW,53 RosettaImportStatus.NEEDS_REVIEW,
51 ]54 ]
55 self._switch_dbuser()
52 # Do *not* use assertContentEqual here, as the order matters.56 # Do *not* use assertContentEqual here, as the order matters.
53 self.assertEqual(expected_list,57 self.assertEqual(expected_list,
54 [entry.canSetStatus(status, user)58 [entry.canSetStatus(status, user)
@@ -71,6 +75,7 @@
71 # If the entry has no import target set, even Rosetta experts75 # If the entry has no import target set, even Rosetta experts
72 # cannot set it to approved.76 # cannot set it to approved.
73 self.entry.potemplate = None77 self.entry.potemplate = None
78 self.entry.pofile = None
74 self._assertCanSetStatus(self.rosetta_experts, self.entry,79 self._assertCanSetStatus(self.rosetta_experts, self.entry,
75 # A B D F I NR80 # A B D F I NR
76 [False, True, True, True, True, True])81 [False, True, True, True, True, True])
@@ -115,5 +120,66 @@
115 [False, False, False, False, False, False])120 [False, False, False, False, False, False])
116121
117122
123class TestCanSetStatusPOTemplate(TestCanSetStatusBase):
124 """Test canStatus applied to an entry with a POTemplate."""
125
126 def setUp(self):
127 """Create the entry to test on."""
128 super(TestCanSetStatusPOTemplate, self).setUp()
129
130 self.potemplate = self.factory.makePOTemplate(
131 productseries=self.productseries)
132 self.entry = self.queue.addOrUpdateEntry(
133 'demo.pot', '#demo', False, self.uploaderperson,
134 productseries=self.productseries, potemplate=self.potemplate)
135
136
137class TestCanSetStatusPOFile(TestCanSetStatusBase):
138 """Test canStatus applied to an entry with a POFile."""
139
140 def setUp(self):
141 """Create the entry to test on."""
142 super(TestCanSetStatusPOFile, self).setUp()
143
144 self.potemplate = self.factory.makePOTemplate(
145 productseries=self.productseries)
146 self.pofile = self.factory.makePOFile('eo', potemplate=self.potemplate)
147 self.entry = self.queue.addOrUpdateEntry(
148 'demo.po', '#demo', False, self.uploaderperson,
149 productseries=self.productseries, pofile=self.pofile)
150
151
152class TestCanSetStatusPOTemplateWithQueuedUser(TestCanSetStatusPOTemplate):
153 """Test handling of the status of a queue entry with 'queued' db user.
154
155 The archive uploader needs to set (and therefore check) the status of a
156 queue entry. It connects as a different database user and therefore we
157 need to make sure that setStatus stays within this user's permissions.
158 This is the version for POTemplate entries.
159 """
160
161 dbuser = 'queued'
162
163
164class TestCanSetStatusPOFileWithQueuedUser(TestCanSetStatusPOFile):
165 """Test handling of the status of a queue entry with 'queued' db user.
166
167 The archive uploader needs to set (and therefore check) the status of a
168 queue entry. It connects as a different database user and therefore we
169 need to make sure that setStatus stays within this user's permissions.
170 This is the version for POFile entries.
171 """
172
173 dbuser = 'queued'
174
175
118def test_suite():176def test_suite():
119 return unittest.TestLoader().loadTestsFromName(__name__)177 """Add only specific test cases and leave out the base case."""
178 suite = unittest.TestSuite()
179 suite.addTest(unittest.makeSuite(TestCanSetStatusPOTemplate))
180 suite.addTest(unittest.makeSuite(TestCanSetStatusPOFile))
181 suite.addTest(
182 unittest.makeSuite(TestCanSetStatusPOTemplateWithQueuedUser))
183 suite.addTest(unittest.makeSuite(TestCanSetStatusPOFileWithQueuedUser))
184 return suite
185

Subscribers

People subscribed via source and target branches

to status/vote changes: