More tests, coverage, and excluding lines from being covered
There are some lines that will never be hit in tests, excluding those from being covered!
This commit is contained in:
parent
00c0bd91a6
commit
acdf73a04e
6 changed files with 45 additions and 10 deletions
|
|
@ -11,6 +11,8 @@ class TwythonAuthTestCase(unittest.TestCase):
|
|||
self.bad_api = Twython('BAD_APP_KEY', 'BAD_APP_SECRET')
|
||||
|
||||
self.oauth2_api = Twython(app_key, app_secret, oauth_version=2)
|
||||
self.oauth2_bad_api = Twython('BAD_APP_KEY', 'BAD_APP_SECRET',
|
||||
oauth_version=2)
|
||||
|
||||
def test_get_authentication_tokens(self):
|
||||
"""Test getting authentication tokens works"""
|
||||
|
|
@ -44,6 +46,11 @@ class TwythonAuthTestCase(unittest.TestCase):
|
|||
"""Test obtaining an Application Only OAuth 2 access token succeeds"""
|
||||
self.oauth2_api.obtain_access_token()
|
||||
|
||||
def test_obtain_access_token_bad_tokens(self):
|
||||
"""Test obtaining an Application Only OAuth 2 access token using bad app tokens fails"""
|
||||
self.assertRaises(TwythonAuthError,
|
||||
self.oauth2_bad_api.obtain_access_token)
|
||||
|
||||
def test_obtain_access_token_raises_error_when_oauth1(self):
|
||||
"""Test when API is set for OAuth 1, obtain_access_token raises a
|
||||
TwythonError"""
|
||||
|
|
|
|||
|
|
@ -84,10 +84,28 @@ class TwythonAPITestCase(unittest.TestCase):
|
|||
self.api.encode('Twython is awesome!')
|
||||
|
||||
def test_html_for_tweet(self):
|
||||
"""Test HTML for Twitter returns what we want"""
|
||||
"""Test HTML for Tweet returns what we want"""
|
||||
tweet_text = self.api.html_for_tweet(test_tweet_object)
|
||||
self.assertEqual(test_tweet_html, tweet_text)
|
||||
|
||||
def test_html_for_tweet_expanded_url(self):
|
||||
"""Test using expanded url in HTML for Tweet displays full urls"""
|
||||
tweet_text = self.api.html_for_tweet(test_tweet_object,
|
||||
use_expanded_url=True)
|
||||
# Make sure full url is in HTML
|
||||
self.assertTrue('http://google.com' in tweet_text)
|
||||
|
||||
def test_html_for_tweet_short_url(self):
|
||||
"""Test using expanded url in HTML for Tweet displays full urls"""
|
||||
tweet_text = self.api.html_for_tweet(test_tweet_object, False)
|
||||
# Make sure HTML doesn't contain the display OR exapanded url
|
||||
self.assertTrue(not 'http://google.com' in tweet_text)
|
||||
self.assertTrue(not 'google.com' in tweet_text)
|
||||
|
||||
def test_raise_error_on_bad_ssl_cert(self):
|
||||
"""Test TwythonError is raised by a RequestException when an actual HTTP happens"""
|
||||
self.assertRaises(TwythonError, self.api.get, 'https://example.com')
|
||||
|
||||
# Timelines
|
||||
def test_get_mentions_timeline(self):
|
||||
"""Test returning mentions timeline for authenticated user succeeds"""
|
||||
|
|
|
|||
|
|
@ -19,6 +19,16 @@ class TwythonStreamTestCase(unittest.TestCase):
|
|||
self.api = MyStreamer(app_key, app_secret,
|
||||
oauth_token, oauth_token_secret)
|
||||
|
||||
client_args = {
|
||||
'headers': {
|
||||
'User-Agent': '__twython__ Stream Test'
|
||||
}
|
||||
}
|
||||
# Initialize with header for coverage checking for User-Agent
|
||||
self.api_with_header = MyStreamer(app_key, app_secret,
|
||||
oauth_token, oauth_token_secret,
|
||||
client_args=client_args)
|
||||
|
||||
def test_stream_status_filter(self):
|
||||
self.api.statuses.filter(track='twitter')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue