Merge lp:~jml/launchpad/more-login-helpers into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Robert Collins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 11122 |
Proposed branch: | lp:~jml/launchpad/more-login-helpers |
Merge into: | lp:launchpad |
Diff against target: |
411 lines (+278/-18) 6 files modified
lib/lp/code/model/tests/test_codeimportjob.py (+4/-5) lib/lp/testing/__init__.py (+5/-4) lib/lp/testing/_login.py (+73/-7) lib/lp/testing/tests/test_login.py (+191/-0) lib/lp/translations/tests/test_hastranslationtemplates.py (+3/-1) lib/lp/translations/tests/test_pofile.py (+2/-1) |
To merge this branch: | bzr merge lp:~jml/launchpad/more-login-helpers |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Robert Collins (community) | Approve | ||
Review via email: mp+29595@code.launchpad.net |
Commit message
Add login_team, login_as and login_celebrity helpers.
Description of the change
This branch adds a few new login test helpers: login_team, login_as and login_celebrity.
login_team logs you in as an arbitrary member of a team. login_as logs you in as pretty much whatever you give it: None, ANONYMOUS, a person or a team. login_celebrity will log you in as whatever celebrity you provide.
This branch also has another big advantage: tests! For the first time ever, the login helpers themselves have unit tests.
I did some drive-by cleanup in lp/testing/__init__ too, getting rid of an unnecessary re-export.
Probably the weirdest thing about this branch is the way I figure out the currently logged in user. As far as I can tell, we have two mechanisms: inspecting the zope security policy and checking the launch bag. I've used both to be extra safe, but would happily be convinced to use only one.
+ ANONYMOUS are equivalent, and will log the person is as the anonymous
typo - ITYM 'in as'
get_arbitrary should return different members each time I think. At the moment it will give a false sense of arbitrariness.
If you don't like random(), perhaps walking the team list from end to start would do (so that the owner isn't always the first one returned).
Rather than an XXX, I think you've just written some clear explanation of a bit of cruft you're tolerating - thats fine. As I understand XXX's in the lp code base they should be attached to something to fix - and in this case I'd put it on the 'launch bag' saying 'this duplicates the security context and should be deleted'.
Finally, I'd really like a single class rather than these separate functions, but that would be future work, its not needed for this patch - this patch is a clear improvement on its own.
-Rob