Merge lp:~robru/gwibber/identica-id-fix into lp:~barry/gwibber/py3

Proposed by Robert Bruce Park
Status: Merged
Merged at revision: 1451
Proposed branch: lp:~robru/gwibber/identica-id-fix
Merge into: lp:~barry/gwibber/py3
Diff against target: 51 lines (+30/-0)
2 files modified
gwibber/gwibber/protocols/identica.py (+8/-0)
gwibber/gwibber/tests/test_identica.py (+22/-0)
To merge this branch: bzr merge lp:~robru/gwibber/identica-id-fix
Reviewer Review Type Date Requested Status
Barry Warsaw Pending
Ken VanDine Pending
Review via email: mp+129093@code.launchpad.net

Description of the change

Ken pointed out that Identica wasn't recording the UID/screen name properly, and when i investigated, I discovered that Twitter's _whoami method was not compatible with Identica's, so here's a fix for that.

I tested this on my Identica account and it looked like it worked, but I would love to get ken's confirmation that this is actually working.

To post a comment you must log in.
Revision history for this message
Barry Warsaw (barry) wrote :

On Oct 11, 2012, at 04:30 AM, Robert Bruce Park wrote:

>Ken pointed out that Identica wasn't recording the UID/screen name properly,
>and when i investigated, I discovered that Twitter's _whoami method was not
>compatible with Identica's, so here's a fix for that.
>
>I tested this on my Identica account and it looked like it worked, but I
>would love to get ken's confirmation that this is actually working.

<cough>Test?</cough>

Revision history for this message
Robert Bruce Park (robru) wrote :

On 12-10-11 08:07 AM, Barry Warsaw wrote:
> On Oct 11, 2012, at 04:30 AM, Robert Bruce Park wrote:
>
>> Ken pointed out that Identica wasn't recording the UID/screen name properly,
>> and when i investigated, I discovered that Twitter's _whoami method was not
>> compatible with Identica's, so here's a fix for that.
>>
>> I tested this on my Identica account and it looked like it worked, but I
>> would love to get ken's confirmation that this is actually working.
>
> <cough>Test?</cough>
>

Bah, you accepted all the other _whoami methods without tests! :-P

lp:~robru/gwibber/identica-id-fix updated
1452. By Robert Bruce Park

Add test case for Identica._whoami changes.

Revision history for this message
Robert Bruce Park (robru) wrote :

Alright barry, test case added. Please merge.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'gwibber/gwibber/protocols/identica.py'
2--- gwibber/gwibber/protocols/identica.py 2012-10-05 12:50:57 +0000
3+++ gwibber/gwibber/protocols/identica.py 2012-10-11 16:51:58 +0000
4@@ -38,6 +38,14 @@
5
6 _tweet_permalink = 'http://identi.ca/notice/{tweet_id}'
7
8+ def _whoami(self, authdata):
9+ """Identify the authenticating user."""
10+ self._account.secret_token = authdata.get('TokenSecret')
11+ url = self._api_base.format(endpoint='users/show')
12+ result = self._get_url(url)
13+ self._account.user_id = result.get('id')
14+ self._account.user_name = result.get('screen_name')
15+
16 def _publish_tweet(self, tweet):
17 tweet['id_str'] = str(tweet['id'])
18 super()._publish_tweet(tweet)
19
20=== modified file 'gwibber/gwibber/tests/test_identica.py'
21--- gwibber/gwibber/tests/test_identica.py 2012-10-05 12:50:57 +0000
22+++ gwibber/gwibber/tests/test_identica.py 2012-10-11 16:51:58 +0000
23@@ -57,6 +57,28 @@
24 # as to isolate out test logger from other tests.
25 self.log_mock.stop()
26
27+ @mock.patch('gwibber.utils.authentication.Authentication.login',
28+ return_value=None)
29+ @mock.patch('gwibber.utils.download.get_json',
30+ return_value=None)
31+ def test_unsuccessful_authentication(self, *mocks):
32+ self.assertFalse(self.protocol._login())
33+ self.assertIsNone(self.account.user_name)
34+ self.assertIsNone(self.account.user_id)
35+
36+ @mock.patch('gwibber.utils.authentication.Authentication.login',
37+ return_value=dict(AccessToken='some clever fake data',
38+ TokenSecret='sssssshhh!'))
39+ def test_successful_authentication(self, *mocks):
40+ get_url = self.protocol._get_url = mock.Mock(
41+ return_value=dict(id='1234', screen_name='therealrobru'))
42+ self.assertTrue(self.protocol._login())
43+ self.assertEqual(self.account.user_name, 'therealrobru')
44+ self.assertEqual(self.account.user_id, '1234')
45+ self.assertEqual(self.account.access_token, 'some clever fake data')
46+ self.assertEqual(self.account.secret_token, 'sssssshhh!')
47+ get_url.assert_called_once_with('http://identi.ca/api/users/show.json')
48+
49 def test_mentions(self):
50 get_url = self.protocol._get_url = mock.Mock(return_value=['tweet'])
51 publish = self.protocol._publish_tweet = mock.Mock()

Subscribers

People subscribed via source and target branches