Merge lp:~mars/launchpad/fix-js-unittests into lp:launchpad/db-devel

Proposed by Māris Fogels
Status: Rejected
Rejected by: Māris Fogels
Proposed branch: lp:~mars/launchpad/fix-js-unittests
Merge into: lp:launchpad/db-devel
Diff against target: 524 lines (+218/-52)
12 files modified
database/schema/security.cfg (+3/-0)
lib/canonical/launchpad/javascript/bugs/filebug-dupefinder.js (+5/-0)
lib/canonical/launchpad/javascript/client/client.js (+2/-2)
lib/canonical/launchpad/javascript/lp/comment.js (+0/-1)
lib/canonical/launchpad/javascript/lp/lp.js (+2/-3)
lib/canonical/launchpad/javascript/soyuz/lp_dynamic_dom_updater.js (+5/-5)
lib/lp/code/browser/branch.py (+5/-0)
lib/lp/code/browser/codereviewcomment.py (+4/-3)
lib/lp/code/errors.py (+51/-0)
lib/lp/code/templates/branchmergeproposal-index.pt (+62/-27)
lib/lp/registry/browser/team.py (+4/-2)
lib/lp/translations/tests/test_translationimportqueue.py (+75/-9)
To merge this branch: bzr merge lp:~mars/launchpad/fix-js-unittests
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+15546@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Māris Fogels (mars) wrote :

Hi,

This branch fixes a number of failures in the JavaScript unit test suite that
resulted from the YUI 3.0.0 upgrade.

I manually ran all of the unit tests under lib/canonical/launchpad/javascript/
to ensure that the features under test still work.

My changes are free of lint. There is one spurious lint error in lp.js.

Maris

Revision history for this message
Gavin Panella (allenap) wrote :

Has Y.fail() been renamed as Y.error(), or is it a deprecated synonym? If neither, then I'd be inclined to leave it alone; "fail" more closely matches the terminology used in the Python testing world. Y.error() sounds like it should be used when test set-up fails, not when an assertion fails.

I'm very happy to see that the 'click' simulation has been fixed (re. test_me_too.js). Figuring that one out caused me a very sweary afternoon of pain.

Thanks for doing this :)

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

On Wed, Dec 2, 2009 at 8:54 AM, Gavin Panella <email address hidden> wrote:
> Review: Approve
> Has Y.fail() been renamed as Y.error(), or is it a deprecated synonym? If neither, then I'd be inclined to leave it alone; "fail" more closely matches the terminology used in the Python testing world. Y.error() sounds like it should be used when test set-up fails, not when an assertion fails.

Yes, Y.fail() became Y.error(). Y.fail() is now only in the 'test' module, and has become the standard xUnit "fail()" call.

This caused a subtle bug: my tests were failing when they should have been raising errors. Turns out the code under test was calling Y.fail() itself, so it raised a failure exception instead of a real error.

>
> I'm very happy to see that the 'click' simulation has been fixed (re. test_me_too.js). Figuring that one out caused me a very sweary afternoon of pain.

It took me a while, too. I remembered a comment Bjorn made during the lazr-js sprint about using click because mousedown was unreliable. Turns out it was true!

>
> Thanks for doing this :)
>

My pleasure! Thank you for the review.

Mars

lp:~mars/launchpad/fix-js-unittests updated
8737. By Māris Fogels

Merge from db-devel

8738. By Māris Fogels

Merged trunk instead of db-devel so we can land on the mainline.

8739. By Māris Fogels

Merge from RF. Fixed one conflict.

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

Rejecting my own branch, as it has become stale (because PQM refuses to land it, argh!)

Unmerged revisions

8739. By Māris Fogels

Merge from RF. Fixed one conflict.

8738. By Māris Fogels

Merged trunk instead of db-devel so we can land on the mainline.

8737. By Māris Fogels

Merge from db-devel

8736. By Māris Fogels

Fixed a number of JS unit tests that broke during the YUI 3.0.0 upgrade.

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 13:41:18 +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/bugs/filebug-dupefinder.js'
--- lib/canonical/launchpad/javascript/bugs/filebug-dupefinder.js 2009-12-10 13:45:40 +0000
+++ lib/canonical/launchpad/javascript/bugs/filebug-dupefinder.js 2009-12-11 13:41:18 +0000
@@ -56,8 +56,13 @@
5656
57 // Check that the details_div actually exists and raise an error if57 // Check that the details_div actually exists and raise an error if
58 // we can't find it.58 // we can't find it.
59<<<<<<< TREE
59 if (!Y.Lang.isValue(details_div)) {60 if (!Y.Lang.isValue(details_div)) {
60 Y.fail(61 Y.fail(
62=======
63 if (!Y.Lang.isValue(details_div)) {
64 Y.error(
65>>>>>>> MERGE-SOURCE
61 "Unable to find details div for expander " + expander.get('id'));66 "Unable to find details div for expander " + expander.get('id'));
62 } else {67 } else {
63 return details_div;68 return details_div;
6469
=== modified file 'lib/canonical/launchpad/javascript/client/client.js'
--- lib/canonical/launchpad/javascript/client/client.js 2009-12-07 12:26:37 +0000
+++ lib/canonical/launchpad/javascript/client/client.js 2009-12-11 13:41:18 +0000
@@ -694,11 +694,11 @@
694 */694 */
695 initializer: function(config) {695 initializer: function(config) {
696 if (!Y.Lang.isString(config.patch)) {696 if (!Y.Lang.isString(config.patch)) {
697 Y.fail("missing config: 'patch' containing the attribute name");697 Y.error("missing config: 'patch' containing the attribute name");
698 }698 }
699699
700 if (!Y.Lang.isString(config.resource)) {700 if (!Y.Lang.isString(config.resource)) {
701 Y.fail("missing config: 'resource' containing the URL to patch");701 Y.error("missing config: 'resource' containing the URL to patch");
702 }702 }
703703
704 // Save the config object that the user passed in so that we can pass704 // Save the config object that the user passed in so that we can pass
705705
=== 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 13:41:18 +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/javascript/lp/lp.js'
--- lib/canonical/launchpad/javascript/lp/lp.js 2009-12-07 12:26:37 +0000
+++ lib/canonical/launchpad/javascript/lp/lp.js 2009-12-11 13:41:18 +0000
@@ -66,10 +66,10 @@
6666
67 // If either the wrapper or the icon is null, raise an error.67 // If either the wrapper or the icon is null, raise an error.
68 if (wrapper_div === null) {68 if (wrapper_div === null) {
69 Y.fail("Collapsible has no wrapper div.");69 Y.error("Collapsible has no wrapper div.");
70 }70 }
71 if (icon === null) {71 if (icon === null) {
72 Y.fail("Collapsible has no icon.");72 Y.error("Collapsible has no icon.");
73 }73 }
7474
75 // Work out the target icon and animation based on the state of75 // Work out the target icon and animation based on the state of
@@ -791,4 +791,3 @@
791 tag2.style.display = display;791 tag2.style.display = display;
792 return false;792 return false;
793}793}
794
795794
=== modified file 'lib/canonical/launchpad/javascript/soyuz/lp_dynamic_dom_updater.js'
--- lib/canonical/launchpad/javascript/soyuz/lp_dynamic_dom_updater.js 2009-11-24 16:11:43 +0000
+++ lib/canonical/launchpad/javascript/soyuz/lp_dynamic_dom_updater.js 2009-12-11 13:41:18 +0000
@@ -14,7 +14,7 @@
14var lp = Y.namespace('lp');14var lp = Y.namespace('lp');
1515
16 /**16 /**
17 * The DomUpdater class provides the ability to plugin functionality 17 * The DomUpdater class provides the ability to plugin functionality
18 * to a DOM subtree so that it can update itself when given data in an18 * to a DOM subtree so that it can update itself when given data in an
19 * expected format.19 * expected format.
20 *20 *
@@ -79,7 +79,7 @@
79 Y.lp.DomUpdater = DomUpdater;79 Y.lp.DomUpdater = DomUpdater;
8080
81 /**81 /**
82 * The DynamicDomUpdater class provides the ability to plug functionality 82 * The DynamicDomUpdater class provides the ability to plug functionality
83 * into a DOM subtree so that it can update itself using an LP api method.83 * into a DOM subtree so that it can update itself using an LP api method.
84 *84 *
85 * For example:85 * For example:
@@ -94,7 +94,7 @@
94 * Once configured, the 'table' dom subtree will now update itself94 * Once configured, the 'table' dom subtree will now update itself
95 * by calling the user defined domUpdateFunction (with a default interval95 * by calling the user defined domUpdateFunction (with a default interval
96 * of 6000ms) with the result of the LPs api call.96 * of 6000ms) with the result of the LPs api call.
97 * 97 *
98 * @class DynamicDomUpdater98 * @class DynamicDomUpdater
99 * @extends DomUpdater99 * @extends DomUpdater
100 * @constructor100 * @constructor
@@ -326,7 +326,7 @@
326 }326 }
327327
328 if (actual_interval_updated) {328 if (actual_interval_updated) {
329 Y.log("Actual poll interval updated to " + 329 Y.log("Actual poll interval updated to " +
330 this._actual_interval + "ms.");330 this._actual_interval + "ms.");
331 }331 }
332332
@@ -344,7 +344,7 @@
344 * @private344 * @private
345 */345 */
346 _handleFailure: function(id, request) {346 _handleFailure: function(id, request) {
347 Y.fail("LP.DynamicDomUpdater for " + this.get("host") +347 Y.error("LP.DynamicDomUpdater for " + this.get("host") +
348 " failed to get dynamic data.");348 " failed to get dynamic data.");
349 }349 }
350 });350 });
351351
=== modified file 'lib/lp/code/browser/branch.py'
--- lib/lp/code/browser/branch.py 2009-12-11 00:56:16 +0000
+++ lib/lp/code/browser/branch.py 2009-12-11 13:41:18 +0000
@@ -79,9 +79,14 @@
79from lp.code.browser.branchmergeproposal import (79from lp.code.browser.branchmergeproposal import (
80 latest_proposals_for_each_branch)80 latest_proposals_for_each_branch)
81from lp.code.enums import (81from lp.code.enums import (
82<<<<<<< TREE
82 BranchLifecycleStatus, BranchType, RevisionControlSystems,83 BranchLifecycleStatus, BranchType, RevisionControlSystems,
83 UICreatableBranchType)84 UICreatableBranchType)
84from lp.code.errors import InvalidBranchMergeProposal85from lp.code.errors import InvalidBranchMergeProposal
86=======
87 BranchLifecycleStatus, BranchType, UICreatableBranchType)
88from lp.code.errors import InvalidBranchMergeProposal
89>>>>>>> MERGE-SOURCE
85from lp.code.interfaces.branch import (90from lp.code.interfaces.branch import (
86 BranchCreationForbidden, BranchExists, IBranch,91 BranchCreationForbidden, BranchExists, IBranch,
87 user_has_special_branch_access)92 user_has_special_branch_access)
8893
=== modified file 'lib/lp/code/browser/branchmergeproposal.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 13:41:18 +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/configure.zcml'
=== modified file 'lib/lp/code/errors.py'
--- lib/lp/code/errors.py 2009-12-07 06:51:42 +0000
+++ lib/lp/code/errors.py 2009-12-11 13:41:18 +0000
@@ -1,3 +1,4 @@
1<<<<<<< TREE
1# Copyright 2009 Canonical Ltd. This software is licensed under the2# Copyright 2009 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).3# GNU Affero General Public License version 3 (see the file LICENSE).
34
@@ -54,3 +55,53 @@
5455
55class WrongBranchMergeProposal(Exception):56class WrongBranchMergeProposal(Exception):
56 """The comment requested is not associated with this merge proposal."""57 """The comment requested is not associated with this merge proposal."""
58=======
59# Copyright 2009 Canonical Ltd. This software is licensed under the
60# GNU Affero General Public License version 3 (see the file LICENSE).
61
62"""Errors used in the lp/code modules."""
63
64__metaclass__ = type
65__all__ = [
66 'BadBranchMergeProposalSearchContext',
67 'BadStateTransition',
68 'BranchMergeProposalExists',
69 'InvalidBranchMergeProposal',
70 'UserNotBranchReviewer',
71 'WrongBranchMergeProposal',
72]
73
74
75class BadBranchMergeProposalSearchContext(Exception):
76 """The context is not valid for a branch merge proposal search."""
77
78
79class BadStateTransition(Exception):
80 """The user requested a state transition that is not possible."""
81
82
83class InvalidBranchMergeProposal(Exception):
84 """Raised during the creation of a new branch merge proposal.
85
86 The text of the exception is the rule violation.
87 """
88
89
90class BranchMergeProposalExists(InvalidBranchMergeProposal):
91 """Raised if there is already a matching BranchMergeProposal."""
92
93
94class UserNotBranchReviewer(Exception):
95 """The user who attempted to review the merge proposal isn't a reviewer.
96
97 A specific reviewer may be set on a branch. If a specific reviewer
98 isn't set then any user in the team of the owner of the branch is
99 considered a reviewer.
100 """
101
102
103class WrongBranchMergeProposal(Exception):
104 """The comment requested is not associated with this merge proposal."""
105
106
107>>>>>>> MERGE-SOURCE
57108
=== modified file 'lib/lp/code/model/tests/test_branchmergeproposals.py'
=== modified file 'lib/lp/code/templates/branch-import-details.pt'
=== 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 13:41:18 +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/team.py'
--- lib/lp/registry/browser/team.py 2009-12-01 22:09:05 +0000
+++ lib/lp/registry/browser/team.py 2009-12-11 13:41:18 +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/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 13:41:18 +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: