Moving tests to their own folder
This commit is contained in:
parent
53b930b75f
commit
6ce39f9921
6 changed files with 115 additions and 91 deletions
41
tests/test_auth.py
Normal file
41
tests/test_auth.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
from twython import Twython, TwythonError, TwythonAuthError
|
||||
|
||||
from .config import app_key, app_secret, screen_name
|
||||
|
||||
import unittest
|
||||
|
||||
|
||||
class TwythonAuthTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.api = Twython(app_key, app_secret)
|
||||
self.bad_api = Twython('BAD_APP_KEY', 'BAD_APP_SECRET')
|
||||
|
||||
self.oauth2_api = Twython(app_key, app_secret, oauth_version=2)
|
||||
|
||||
def test_get_authentication_tokens(self):
|
||||
"""Test getting authentication tokens works"""
|
||||
self.api.get_authentication_tokens(callback_url='http://google.com/',
|
||||
force_login=True,
|
||||
screen_name=screen_name)
|
||||
|
||||
def test_get_authentication_tokens_bad_tokens(self):
|
||||
"""Test getting authentication tokens with bad tokens
|
||||
raises TwythonAuthError"""
|
||||
self.assertRaises(TwythonAuthError, self.bad_api.get_authentication_tokens,
|
||||
callback_url='http://google.com/')
|
||||
|
||||
def test_get_authorized_tokens_bad_tokens(self):
|
||||
"""Test getting final tokens fails with wrong tokens"""
|
||||
self.assertRaises(TwythonError, self.bad_api.get_authorized_tokens,
|
||||
'BAD_OAUTH_VERIFIER')
|
||||
|
||||
def test_get_authentication_tokens_raises_error_when_oauth2(self):
|
||||
"""Test when API is set for OAuth 2, get_authentication_tokens raises
|
||||
a TwythonError"""
|
||||
self.assertRaises(TwythonError, self.oauth2_api.get_authentication_tokens)
|
||||
|
||||
def test_get_authorization_tokens_raises_error_when_oauth2(self):
|
||||
"""Test when API is set for OAuth 2, get_authentication_tokens raises
|
||||
a TwythonError"""
|
||||
self.assertRaises(TwythonError, self.oauth2_api.get_authorized_tokens,
|
||||
'BAD_OAUTH_VERIFIER')
|
||||
Loading…
Add table
Add a link
Reference in a new issue