Merge lp:~adeuring/launchpad/bug-261254-fix-mantis-login into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Deryck Hodge |
Approved revision: | no longer in the source branch. |
Merged at revision: | not available |
Proposed branch: | lp:~adeuring/launchpad/bug-261254-fix-mantis-login |
Merge into: | lp:launchpad |
Diff against target: |
348 lines (+162/-31) 4 files modified
lib/lp/bugs/externalbugtracker/mantis.py (+28/-7) lib/lp/bugs/tests/externalbugtracker-xmlrpc-transport.txt (+11/-3) lib/lp/bugs/tests/externalbugtracker.py (+26/-21) lib/lp/bugs/tests/test_bugtracker.py (+97/-0) |
To merge this branch: | bzr merge lp:~adeuring/launchpad/bug-261254-fix-mantis-login |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Deryck Hodge (community) | code | Approve | |
Review via email: mp+23097@code.launchpad.net |
Description of the change
This branch fixes bug 261254: Launchpad couldn't connect to ALSA Bug Tracker.
The communication between the Launchpad's "Mantis bug watcher" and
a Mantis bug tracker was hampered by three issues:
1. Some time ago, ClientCookie.
urllib2.
but the cookie handler from urllib2 was not added. Since many
Mantis trackers require users to login (be it as a guest), and since
the credentials are stored in a cookie, access to a Mantis tracker
was no longer possible. (I also think that things like bug filter
settings are stored in cookies.)
2. class MantisLoginHandler works by overloading the method
redirect_
urllib2.
disappeared.
3. At least the Alsa bug tracker returns a HTTP 500 error when the
URL for CSV data is accessed. This led to an exception in
Mantis.csv_data. The new implementation simply treats this
repsonse as an indication that the Mantis isntance does not
provide any CSV data and that we must screen-scrape the bug data.
The code changes to fix these bugs are quite straightforward, I think.
In order to ensure that a similiar unnoticed disappearance of the
method MantisLoginHand
I added a unit test for it. Similary, I added a test to ensure that
MantisLoginHandler is used.
Finally, I added a test that HTTP 500 errors are treated by
Mantis.csv_data as described above. In order to test that other HTTP
errors are not swallowed by Mantis.csv_data, I moved the the
code from this cached property into the method _csv_data(), so that
I can use assertRaises.
The redirect and HTTP error tests require a sort of "fake
request/response handling", which was already implemented by the
class Urlib2Transport
"tailor-made" for some XMLRPC tests. I generalized it a bit, which
in turn required some modifications of
externalbugtrac
The new method setError(self, error, url) indeed needs the second
parameter:
1. Mantis._csv_data() issues two HTTP requests, and we want that
the second request returns an error.
2. While HTTPError.
it seems that it is nowhere stored, so we can't use something
like seif.raise_
in Urlib2Transport
URL the one where the error should be returned.
Finally, "make lint" had three complaints:
1620: [E0702, Urlib2Transport
1626: [W0108 , Urlib2Transport
1639: [W0108, Urlib2Transport
I don't think that we'll ever hae a "raise None" in line 1620.
Lambda _may_ not be necessary, but using something like
is not a good idea, since response and req are instances of different
classes.
I disabled these messages.
tests:
./bin/test -vvt test_bugtracker
./bin/test -vvt tests/externalb
No lint except the wrong messages mentioned above.
Looks good. Nice work debugging what was going on here.
Cheers,
deryck