def test_get_access_token(self): token = views.get_access_token(self.user) self.assertEqual(len(token.get('access_token')), 30) self.assertEqual(token.get('token_type'), 'Bearer') self.assertEqual(token.get('scope'), 'read write') self.assertEqual(token.get('expires_in'), 36000)
def test_access_token_failure(self): from api import APIException from views import get_access_token access_token = lambda : get_access_token('Wrong Key', 'Wrong Secret') self.assertRaises(APIException, access_token)
def test_access_token(self): from views import get_access_token from tweetsearch.settings import TWITTER_OAUTH_KEY, TWITTER_OAUTH_SECRET access_token = get_access_token(TWITTER_OAUTH_KEY, TWITTER_OAUTH_SECRET) expected_access_token = u'AAAAAAAAAAAAAAAAAAAAAEtYdwAAAAAAmsMTQS0s7IMdYRKSxLenW%2BR2%2Fq4%3DbjQjzkdJD6ESKHMMXkTRMlhXlXqu3zpW0HRFNwadoVyE0tqn9l' self.assertEqual(access_token, expected_access_token)