Merge lp:~jtv/launchpad/test-pofile-permissions into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Gavin Panella on 2010-11-04 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 11882 |
| Proposed branch: | lp:~jtv/launchpad/test-pofile-permissions |
| Merge into: | lp:launchpad |
| Diff against target: |
849 lines (+500/-251) 3 files modified
lib/lp/translations/doc/pofile.txt (+12/-251) lib/lp/translations/tests/test_pofile.py (+188/-0) lib/lp/translations/tests/test_translationpermission.py (+300/-0) |
| To merge this branch: | bzr merge lp:~jtv/launchpad/test-pofile-permissions |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Gavin Panella (community) | code | Approve on 2010-11-04 | |
| Launchpad code reviewers | code | 2010-11-04 | Pending |
|
Review via email:
|
|||
Commit Message
Unit-test translation permissions.
Description of the Change
= Unit Test for POFile Permissions =
When looking at a translation, the privileges model is a bit different from what you see elsewhere in Launchpad. A user can have one of 3 levels of access to any given translation:
1. Nothing. The translation is read-only to this user.
2. Suggest. The user can enter suggestions.
3. Edit. The user can alter existing translations, review suggestions, and set new translations.
Where the user gets their privilege level is a bit of a complicated story. For the ongoing Recife work, we're separating the two ingredients more clearly:
(i) Personal matters: is the user an admin, have they accepted the licensing agreement, etc?
(ii) Access model: what is allowed by the access model configured for this product or distribution, and its translation group?
Testing for this was a bit haphazard, so messing with the privileges in the Recife branch is risky. That's why I'm first replacing the doctest with two separate unit test cases. Running the same tests against devel and my ongoing Recife work neatly reveals the differences. Mainly, the Recife branch takes away special privileges from POFile owners.
And that is all this branch does. Just testing, no changes. Nevertheless you'll notice a few small irregularities:
* I no longer test updateTranslations rejecting unpermitted translations, since I cut down the forest that check lived in. However updateTranslations is going away completely in the Recife branch, and for some time now we have been under a blood oath not to make any further changes to the method.
* I'm not verifying that a product owner who has declined the translations relicensing agreement can enter suggestions. It shouldn't matter, since the editing rights imply this, but in actual fact this is the one situation where pofile.
By the way, the heart of these permissions checks is some of the oldest code in Launchpad, apparently dating back to 2005, and defines some of its most fundamental policy behaviour. It's high time it was unit-tested.
To run the new tests:
{{{
./bin/test -vvc lpl.translation
./bin/test -vvc lpl.translation
}}}
No lint.
Jeroen
| Jeroen T. Vermeulen (jtv) wrote : | # |
> Right, looks good. That was quite painful to review :)
>
> It was a little mind-bending, but I liked how you managed to keep a
> lid on complexity in test_translatio
>
> One miniscule comment/question.
>
>
> [1]
>
> + def test_admin_
> + # Administrators can edit all translations and make suggestions
> + # anywhere.
> + self.closeTrans
>
> Why is closeTranslations() needed? Can you explain either here or in
> its docstring (assuming my question isn't stupid).
Good question, actually. It is needed to show that an admin has these rights _despite the chosen access model tending towards keeping people out_. Translations are open by default, and under those circumstances testing that an admin has edit rights has little value.

Right, looks good. That was quite painful to review :)
It was a little mind-bending, but I liked how you managed to keep a npermission.
lid on complexity in test_translatio
One miniscule comment/question.
[1]
+ def test_admin_ can_edit( self): lations( )
+ # Administrators can edit all translations and make suggestions
+ # anywhere.
+ self.closeTrans
Why is closeTranslations() needed? Can you explain either here or in
its docstring (assuming my question isn't stupid).