~robru/gwibber/twitter-from-me-fix

« back to all changes in this revision

Viewing changes to gwibber/gwibber/tests/test_foursquare.py

  • Committer: Barry Warsaw
  • Date: 2012-09-21 18:46:21 UTC
  • mfrom: (1437.1.2 robru)
  • Revision ID: barry@python.org-20120921184621-o6xncvo0mvrt9nxj
Merge, with minor changes, lp:~robru/gwibber/accounts-fixup, which principly
cleans up the interface with libaccounts, and changes blanket attribute access
via dictionary lookup to specific direct. attribute accesses.

Also:
  * Make Account.enabled a property.
  * Add more explanation about why the gi.repository.Account API sucks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
                return_value=None)
68
68
    def test_unsuccessful_authentication(self, *mocks):
69
69
        self.assertFalse(self.protocol._login())
70
 
        self.assertNotIn('username', self.account)
71
 
        self.assertNotIn('user_id', self.account)
 
70
        self.assertIsNone(self.account.user_name)
 
71
        self.assertIsNone(self.account.user_id)
72
72
 
73
73
    @mock.patch('gwibber.utils.authentication.Authentication.login',
74
74
                return_value=dict(AccessToken='tokeny goodness'))
80
80
                                  id='1234567'))))
81
81
    def test_successful_authentication(self, *mocks):
82
82
        self.assertTrue(self.protocol._login())
83
 
        self.assertEqual(self.account['username'], 'Bob Loblaw')
84
 
        self.assertEqual(self.account['user_id'], '1234567')
 
83
        self.assertEqual(self.account.user_name, 'Bob Loblaw')
 
84
        self.assertEqual(self.account.user_id, '1234567')
85
85
 
86
86
    @mock.patch('gwibber.utils.base.Model', TestModel)
87
87
    @mock.patch('gwibber.utils.download.urlopen',
89
89
    @mock.patch('gwibber.protocols.foursquare.FourSquare._login',
90
90
                return_value=True)
91
91
    def test_receive(self, *mocks):
92
 
        self.account['access_token'] = 'tokeny goodness'
 
92
        self.account.access_token = 'tokeny goodness'
93
93
        self.assertEqual(0, TestModel.get_n_rows())
94
94
        self.protocol.receive()
95
95
        self.assertEqual(1, TestModel.get_n_rows())