Merge lp:~jcsackett/launchpad/join-not-allowed-244527 into lp:launchpad
Status: | Merged |
---|---|
Approved by: | j.c.sackett |
Approved revision: | no longer in the source branch. |
Merged at revision: | 11783 |
Proposed branch: | lp:~jcsackett/launchpad/join-not-allowed-244527 |
Merge into: | lp:launchpad |
Diff against target: |
160 lines (+65/-18) 4 files modified
lib/lp/registry/errors.py (+13/-7) lib/lp/registry/interfaces/person.py (+0/-5) lib/lp/registry/model/person.py (+4/-2) lib/lp/registry/tests/test_team_webservice.py (+48/-4) |
To merge this branch: | bzr merge lp:~jcsackett/launchpad/join-not-allowed-244527 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Edwin Grubbs (community) | code | Approve | |
Review via email: mp+38949@code.launchpad.net |
Commit message
Moves JoinNotAllowed to registry.errors. This registers it on the webservice so that it reports HTTP 400 BAD REQUEST across the API instead of a server error.
Description of the change
Summary
=======
As with many exceptions JoinNotAllowed wasn't properly exposed to the webservice, so API uses that trigger it get a 500 which mucks up our OOPS reports.
This is easily remedied by moving it to registry.errors, which is registered with the webservice and providing it a 400 webservice_error so it's reported back across the webservice rather than triggering a server error.
Proposed fix
============
Move the JoinNotAllowed to registry.errors and the BAD_REQUEST webservice_error type to it.
Preimplementation talk
=======
Spoke with Curtis Hovey.
Implementation details
=======
As in proposed.
Tests
=====
bin/test -vvct TestTeamJoining
Lint
====
make lint output:
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
lib/lp/
./lib/lp/
491: E302 expected 2 blank lines, found 1
The error lint found has to do with it being confused by comments.
Hi JC,
This branch looks good. I just have one suggestion.
-Edwin
>=== modified file 'lib/lp/ registry/ tests/test_ team_webservice .py' registry/ tests/test_ team_webservice .py 2010-10-04 20:46:55 +0000 registry/ tests/test_ team_webservice .py 2010-10-20 16:20:29 +0000 l(httplib. FORBIDDEN, api_error. response. status) TestLoader( ).loadTestsFrom Name(__ name__) (TestCaseWithFa ctory): nalLayer _rejects_ membership( self): makePerson( name='test- person' ) makeTeam( name='test- team') self.team. teamowner) subscriptionpol icy = TeamSubscriptio nPolicy. RESTRICTED for("test" , self.person) people[ 'test-person' ] l(httplib. BAD_REQUEST, api_error. response. status) accepts_ membership( self): makePerson( name='test- person' ) makeTeam( name='test- team') self.team. teamowner) subscriptionpol icy = TeamSubscriptio nPolicy. OPEN for("test" , self.person) people[ 'test-person' ] people[ 'test-team' ] join(team= test_team. self_link) team_membership s.count( ))
>--- lib/lp/
>+++ lib/lp/
>@@ -48,5 +52,36 @@
> self.assertEqua
>
>
>-def test_suite():
>- return unittest.
>+class TestTeamJoining
>+
>+ layer = DatabaseFunctio
>+
>+ def test_restricted
>+ self.person = self.factory.
>+ self.team = self.factory.
>+ login_person(
>+ self.team.
>+ logout()
>+
>+ launchpad = launchpadlib_
>+ person = launchpad.
>+ api_error = self.assertRaises(
>+ HTTPError,
>+ person.join,
>+ team='test-team')
>+ self.assertEqua
>+
>+ def test_open_
>+ # Calling person.join with a team that has an open membership
>+ # subscription policy should add that that user to the team.
>+ self.person = self.factory.
>+ self.team = self.factory.
>+ login_person(
>+ self.team.
>+ logout()
>+
>+ launchpad = launchpadlib_
>+ test_person = launchpad.
>+ test_team = launchpad.
>+ test_person.
>+ self.assertEqual(1, self.person.
Instead of checking the count, can you make this assertion: assertEqual(
['test- team'],
[membership. team.name team_memebershi ps])
self.
for membership in self.person.