Merge lp:~robru/gwibber/fix-rate-limiter into lp:~barry/gwibber/py3

Proposed by Robert Bruce Park
Status: Merged
Merged at revision: 1448
Proposed branch: lp:~robru/gwibber/fix-rate-limiter
Merge into: lp:~barry/gwibber/py3
Diff against target: 42 lines (+7/-7)
2 files modified
gwibber/gwibber/protocols/twitter.py (+1/-1)
gwibber/gwibber/testing/mocks.py (+6/-6)
To merge this branch: bzr merge lp:~robru/gwibber/fix-rate-limiter
Reviewer Review Type Date Requested Status
Barry Warsaw Pending
Review via email: mp+128301@code.launchpad.net

Description of the change

Barry, looks like you made a mock that didn't perfectly reflect reality, and then the code you wrote against it passed the test but broke in reality ;-)

So here's a little fixup for that, making the mock reflect reality and fixing the code to pass both the test, and the real world.

To post a comment you must log in.
lp:~robru/gwibber/fix-rate-limiter updated
1449. By Robert Bruce Park

Rebase barry's Facebook branch onto the updated py3 branch.

Includes schema fixups for the tests in other protocols. Also,
'debug_live.py facebook receive' is confirmed to be working.

Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 05, 2012, at 06:03 PM, Robert Bruce Park wrote:

>Barry, looks like you made a mock that didn't perfectly reflect reality, and
>then the code you wrote against it passed the test but broke in reality ;-)
>
>So here's a little fixup for that, making the mock reflect reality and fixing
>the code to pass both the test, and the real world.

Good catch, thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gwibber/gwibber/protocols/twitter.py'
2--- gwibber/gwibber/protocols/twitter.py 2012-10-05 12:50:57 +0000
3+++ gwibber/gwibber/protocols/twitter.py 2012-10-05 18:02:27 +0000
4@@ -326,7 +326,7 @@
5
6 def update(self, response):
7 info = response.info()
8- url = self._sanitize_url(info.geturl())
9+ url = self._sanitize_url(response.geturl())
10 # This is time in the future, in UTC epoch seconds, at which the
11 # current rate limiting window expires.
12 rate_reset = info.get('X-Rate-Limit-Reset')
13
14=== modified file 'gwibber/gwibber/testing/mocks.py'
15--- gwibber/gwibber/testing/mocks.py 2012-10-05 01:19:29 +0000
16+++ gwibber/gwibber/testing/mocks.py 2012-10-05 18:02:27 +0000
17@@ -86,12 +86,6 @@
18 class FakeInfo:
19 def __init__(self, headers):
20 self.headers = headers
21- def geturl(self):
22- if isinstance(url, str):
23- return url
24- else:
25- # Must be a Request object.
26- return url.full_url
27 def get(self, key, default=None):
28 return self.headers.get(key, default)
29 def get_content_charset(self):
30@@ -103,6 +97,12 @@
31 self.headers = headers
32 def read(self):
33 return self._data
34+ def geturl(self):
35+ if isinstance(url, str):
36+ return url
37+ else:
38+ # Must be a Request object.
39+ return url.full_url
40 def __enter__(self):
41 return self
42 def __exit__(self, *args, **kws):

Subscribers

People subscribed via source and target branches