launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01561
[Merge] lp:~deryck/launchpad/better-testing-for-status-changes into lp:launchpad/devel
Deryck Hodge has proposed merging lp:~deryck/launchpad/better-testing-for-status-changes into lp:launchpad/devel with lp:~deryck/launchpad/lock-fix-released-status-126516 as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
#126516 would like limited access control for status field changes
https://bugs.launchpad.net/bugs/126516
This branch is the first toward a fix for Bug #126516, or more specifically
for a fix to limit transitioning away from Fix Released status. Before this
branch the tests for bugtask status changes was a mix of a unit test and
doctest, both living under lp.bugs.tests.
The branch refactors that mess, opting to do a complete unit test of
BugTask.transitionToStatus and BugTask.canTransitionToStatus. The doctest is
then made to be documentation and moved to lp.bugs.doc. Some example code is
left in the doctest, though refactored to use factory generated data.
To test, run:
./bin/test -cvvt bugtask-status-changes
./bin/test -cvvt test_bugtask_status
Thanks for the review!
--
https://code.launchpad.net/~deryck/launchpad/better-testing-for-status-changes/+merge/38550
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~deryck/launchpad/better-testing-for-status-changes into lp:launchpad/devel.
=== modified file 'lib/lp/bugs/doc/bugtask-status-changes.txt'
--- lib/lp/bugs/doc/bugtask-status-changes.txt 2010-10-15 15:16:13 +0000
+++ lib/lp/bugs/doc/bugtask-status-changes.txt 2010-10-15 15:16:14 +0000
@@ -12,6 +12,17 @@
* Expired
* Triaged
+ >>> owner = factory.makePerson()
+ >>> product = factory.makeProduct(owner=owner)
+ >>> bugtask = factory.makeBugTask(target=product)
+ >>> user = factory.makePerson()
+
+ >>> from lp.bugs.interfaces.bugtask import BugTaskStatus
+ >>> login_person(owner)
+ >>> bugtask.transitionToStatus(BugTaskStatus.WONTFIX, owner)
+ >>> print bugtask.status.title
+ Won't Fix
+
Regular users of Launchpad cannot transition a bug task to any of
these statuses.
@@ -19,7 +30,14 @@
registrant or bug supervisor can change from this status to any
other status.
-For more, see lp.bugs.tests.test_bugtask_status.TestBugTaskStatusSetting.
+ >>> login_person(user)
+ >>> bugtask.transitionToStatus(BugTaskStatus.CONFIRMED, user)
+ Traceback (most recent call last):
+ ...
+ UserCannotEditBugTaskStatus...
+
+This is fully tested in
+lp.bugs.tests.test_bugtask_status.TestBugTaskStatusSetting.
Testing for Permission
----------------------
@@ -30,15 +48,9 @@
enough to be used by UI code, e.g. to display only those statuses to
which a user can transition a particular bugtask.
- >>> owner = factory.makePerson()
- >>> product = factory.makeProduct(owner=owner)
- >>> bugtask = factory.makeBugTask(target=product)
- >>> user = factory.makePerson()
-
- >>> from lp.bugs.interfaces.bugtask import BugTaskStatus
- >>> bugtask.canTransitionToStatus(BugTaskStatus.WONTFIX, owner)
+ >>> bugtask.canTransitionToStatus(BugTaskStatus.TRIAGED, owner)
True
- >>> bugtask.canTransitionToStatus(BugTaskStatus.WONTFIX, user)
+ >>> bugtask.canTransitionToStatus(BugTaskStatus.TRIAGED, user)
False
This method is fully tested in