Add test for missing symbols in entities
If a tweet has no `symbols` in its `entities` then `html_for_tweet()`
was failing.
I'm not sure how common this is but, for example, tweets in a downloaded
archive do not have `symbols` for some reason.
The previous change (b366ab5) fixed this, but I'm adding a test
for this case.
This commit is contained in:
parent
b366ab55c3
commit
6890802b2a
1 changed files with 12 additions and 0 deletions
|
|
@ -334,6 +334,18 @@ class TwythonAPITestCase(unittest.TestCase):
|
|||
self.assertTrue('<a href="https://twitter.com/search?q=%24AAPL" class="twython-symbol">$AAPL</a>' in tweet_text)
|
||||
self.assertTrue('<a href="https://twitter.com/search?q=%24ANOTHER" class="twython-symbol">$ANOTHER</a>' not in tweet_text)
|
||||
|
||||
def test_html_for_tweet_no_symbols(self):
|
||||
"""Should still work if tweet object has no symbols list"""
|
||||
tweet = test_tweet_symbols_object
|
||||
# Save a copy:
|
||||
symbols = tweet['entities']['symbols']
|
||||
del tweet['entities']['symbols']
|
||||
tweet_text = self.api.html_for_tweet(tweet)
|
||||
self.assertTrue('symbols: $AAPL and' in tweet_text)
|
||||
self.assertTrue('and $ANOTHER and $A.' in tweet_text)
|
||||
# Put the symbols back:
|
||||
test_tweet_symbols_object['entities']['symbols'] = symbols
|
||||
|
||||
def test_html_for_tweet_compatmode(self):
|
||||
tweet_text = self.api.html_for_tweet(test_tweet_compat_object)
|
||||
# link to compat web status link
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue