diff --git a/tests/config.py b/tests/config.py index 795ba07..d4fc471 100644 --- a/tests/config.py +++ b/tests/config.py @@ -46,3 +46,5 @@ test_tweet_media = {'user': {'name': 'Phil Gyford', 'profile_image_url_https': ' test_tweet_quoted = {u'contributors': None, u'truncated': False, u'text': u'Here\u2019s a quoted tweet. https://t.co/3neKzof0gT', u'is_quote_status': True, u'in_reply_to_status_id': None, u'id': 917706313785905157, u'favorite_count': 0, u'source': u'Tweetbot for Mac', u'quoted_status_id': 917699069916729344, u'retweeted': False, u'coordinates': None, u'quoted_status': {u'contributors': None, u'truncated': False, u'text': u'The quoted tweet text.', u'is_quote_status': False, u'in_reply_to_status_id': None, u'id': 917699069916729344, u'favorite_count': 1, u'source': u'web', u'retweeted': False, u'coordinates': None, u'entities': {u'symbols': [], u'user_mentions': [], u'hashtags': [], u'urls': []}, u'in_reply_to_screen_name': None, u'in_reply_to_user_id': None, u'retweet_count': 0, u'id_str': u'917699069916729344', u'favorited': False, u'user': {u'follow_request_sent': False, u'has_extended_profile': False, u'profile_use_background_image': False, u'default_profile_image': False, u'id': 12552, u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme1/bg.png', u'verified': False, u'translator_type': u'none', u'profile_text_color': u'000000', u'profile_image_url_https': u'https://pbs.twimg.com/profile_images/1167616130/james_200208_300x300_normal.jpg', u'profile_sidebar_fill_color': u'EEEEEE', u'entities': {u'url': {u'urls': [{u'url': u'https://t.co/FsYzXrATit', u'indices': [0, 23], u'expanded_url': u'http://www.gyford.com', u'display_url': u'gyford.com'}]}, u'description': {u'urls': []}}, u'followers_count': 2615, u'profile_sidebar_border_color': u'FFFFFF', u'id_str': u'12552', u'profile_background_color': u'C0C0C0', u'listed_count': 130, u'is_translation_enabled': False, u'utc_offset': 3600, u'statuses_count': 19182, u'description': u'Revised and updated edition for 2004.', u'friends_count': 308, u'location': u'London, UK', u'profile_link_color': u'0000FF', u'profile_image_url': u'http://pbs.twimg.com/profile_images/1167616130/james_200208_300x300_normal.jpg', u'following': False, u'geo_enabled': True, u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme1/bg.png', u'screen_name': u'philgyford', u'lang': u'en-gb', u'profile_background_tile': False, u'favourites_count': 2203, u'name': u'Phil Gyford', u'notifications': False, u'url': u'https://t.co/FsYzXrATit', u'created_at': u'Wed Nov 15 16:55:59 +0000 2006', u'contributors_enabled': False, u'time_zone': u'London', u'protected': False, u'default_profile': False, u'is_translator': False}, u'geo': None, u'in_reply_to_user_id_str': None, u'lang': u'ht', u'created_at': u'Tue Oct 10 10:31:22 +0000 2017', u'in_reply_to_status_id_str': None, u'place': None}, u'entities': {u'symbols': [], u'user_mentions': [], u'hashtags': [], u'urls': [{u'url': u'https://t.co/3neKzof0gT', u'indices': [23, 46], u'expanded_url': u'https://twitter.com/philgyford/status/917699069916729344', u'display_url': u'twitter.com/philgyford/sta\u2026'}]}, u'in_reply_to_screen_name': None, u'in_reply_to_user_id': None, u'retweet_count': 0, u'id_str': u'917706313785905157', u'favorited': False, u'user': {u'follow_request_sent': False, u'has_extended_profile': False, u'profile_use_background_image': True, u'default_profile_image': True, u'id': 2030131, u'profile_background_image_url_https': u'https://abs.twimg.com/images/themes/theme1/bg.png', u'verified': False, u'translator_type': u'none', u'profile_text_color': u'000000', u'profile_image_url_https': u'https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png', u'profile_sidebar_fill_color': u'E0FF92', u'entities': {u'description': {u'urls': [{u'url': u'https://t.co/FsYzXrATit', u'indices': [17, 40], u'expanded_url': u'http://www.gyford.com', u'display_url': u'gyford.com'}]}}, u'followers_count': 12, u'profile_sidebar_border_color': u'000000', u'id_str': u'2030131', u'profile_background_color': u'9AE4E8', u'listed_count': 4, u'is_translation_enabled': False, u'utc_offset': 3600, u'statuses_count': 497, u'description': u'Testing #testing https://t.co/FsYzXrATit $IBM #test @philgyford', u'friends_count': 18, u'location': u'', u'profile_link_color': u'0000FF', u'profile_image_url': u'http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png', u'following': True, u'geo_enabled': True, u'profile_background_image_url': u'http://abs.twimg.com/images/themes/theme1/bg.png', u'screen_name': u'philgyfordtest', u'lang': u'en', u'profile_background_tile': False, u'favourites_count': 0, u'name': u'Phil Gyford Test', u'notifications': False, u'url': None, u'created_at': u'Fri Mar 23 16:56:52 +0000 2007', u'contributors_enabled': False, u'time_zone': u'London', u'protected': False, u'default_profile': False, u'is_translator': False}, u'geo': None, u'in_reply_to_user_id_str': None, u'possibly_sensitive': False, u'possibly_sensitive_appealable': False, u'lang': u'en', u'created_at': u'Tue Oct 10 11:00:10 +0000 2017', u'quoted_status_id_str': u'917699069916729344', u'in_reply_to_status_id_str': None, u'place': None} +test_tweet_retweet = {'coordinates': None, 'source': 'Tweetbot for Mac', 'in_reply_to_user_id_str': None, 'truncated': False, 'in_reply_to_user_id': None, 'favorite_count': 0, 'user': {'has_extended_profile': False, 'following': True, 'url': None, 'profile_background_tile': False, 'geo_enabled': True, 'favourites_count': 0, 'lang': 'en', 'follow_request_sent': False, 'utc_offset': 3600, 'time_zone': 'London', 'profile_sidebar_border_color': '000000', 'verified': False, 'profile_use_background_image': True, 'name': 'Phil Gyford Test', 'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme1/bg.png', 'default_profile_image': True, 'friends_count': 18, 'profile_image_url': 'http://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png', 'profile_image_url_https': 'https://abs.twimg.com/sticky/default_profile_images/default_profile_normal.png', 'default_profile': False, 'screen_name': 'philgyfordtest', 'profile_link_color': '0000FF', 'profile_text_color': '000000', 'id_str': '2030131', 'profile_background_color': '9AE4E8', 'followers_count': 12, 'entities': {'description': {'urls': [{'indices': [17, 40], 'url': 'https://t.co/FsYzXrATit', 'expanded_url': 'http://www.gyford.com', 'display_url': 'gyford.com'}]}}, 'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme1/bg.png', 'protected': False, 'notifications': False, 'description': 'Testing #testing https://t.co/FsYzXrATit $IBM #test @philgyford', 'is_translation_enabled': False, 'is_translator': False, 'translator_type': 'none', 'contributors_enabled': False, 'statuses_count': 498, 'listed_count': 4, 'created_at': 'Fri Mar 23 16:56:52 +0000 2007', 'profile_sidebar_fill_color': 'E0FF92', 'id': 2030131, 'location': ''}, 'favorited': False, 'retweeted_status': {'coordinates': None, 'source': 'Pepys\' Diary', 'in_reply_to_user_id_str': None, 'truncated': False, 'in_reply_to_user_id': None, 'favorite_count': 21, 'user': {'has_extended_profile': False, 'following': True, 'url': 'https://t.co/b5ZyzWwQQA', 'profile_background_tile': False, 'geo_enabled': False, 'favourites_count': 1, 'lang': 'en', 'follow_request_sent': False, 'utc_offset': 3600, 'time_zone': 'London', 'profile_sidebar_border_color': 'CCCCCC', 'verified': False, 'profile_banner_url': 'https://pbs.twimg.com/profile_banners/14475268/1432652170', 'profile_use_background_image': False, 'name': 'Samuel Pepys', 'profile_background_image_url_https': 'https://abs.twimg.com/images/themes/theme1/bg.png', 'default_profile_image': False, 'friends_count': 14, 'profile_image_url': 'http://pbs.twimg.com/profile_images/629231884304695296/VZ-9FQ28_normal.jpg', 'profile_image_url_https': 'https://pbs.twimg.com/profile_images/629231884304695296/VZ-9FQ28_normal.jpg', 'default_profile': False, 'screen_name': 'samuelpepys', 'profile_link_color': '549355', 'profile_text_color': '333333', 'id_str': '14475268', 'profile_background_color': 'F1F4EB', 'followers_count': 55980, 'entities': {'description': {'urls': []}, 'url': {'urls': [{'indices': [0, 23], 'url': 'https://t.co/b5ZyzWwQQA', 'expanded_url': 'http://www.pepysdiary.com/', 'display_url': 'pepysdiary.com'}]}}, 'profile_background_image_url': 'http://abs.twimg.com/images/themes/theme1/bg.png', 'protected': False, 'notifications': False, 'description': 'The diaries of Samuel Pepys in real time, 1660-69. Currently tweeting the events of 1664. Run by @philgyford.', 'is_translation_enabled': False, 'is_translator': False, 'translator_type': 'none', 'contributors_enabled': False, 'statuses_count': 11060, 'listed_count': 1223, 'created_at': 'Tue Apr 22 14:39:20 +0000 2008', 'profile_sidebar_fill_color': 'E8E7DC', 'id': 14475268, 'location': 'London, UK'}, 'favorited': False, 'id': 917459832885653506, 'contributors': None, 'in_reply_to_screen_name': None, 'geo': None, 'in_reply_to_status_id_str': None, 'id_str': '917459832885653506', 'entities': {'hashtags': [], 'symbols': [], 'user_mentions': [], 'urls': []}, 'in_reply_to_status_id': None, 'text': 'My aunt and uncle in a very ill humour one with another, but I made shift with much ado to keep them from scolding.', 'retweet_count': 3, 'place': None, 'lang': 'en', 'created_at': 'Mon Oct 09 18:40:44 +0000 2017', 'is_quote_status': False, 'retweeted': False}, 'id': 917712989649801216, 'contributors': None, 'in_reply_to_screen_name': None, 'geo': None, 'in_reply_to_status_id_str': None, 'id_str': '917712989649801216', 'entities': {'hashtags': [], 'symbols': [], 'user_mentions': [{'id_str': '14475268', 'indices': [3, 15], 'name': 'Samuel Pepys', 'id': 14475268, 'screen_name': 'samuelpepys'}], 'urls': []}, 'in_reply_to_status_id': None, 'text': 'RT @samuelpepys: My aunt and uncle in a very ill humour one with another, but I made shift with much ado to keep them from scolding.', 'retweet_count': 3, 'place': None, 'lang': 'en', 'created_at': 'Tue Oct 10 11:26:41 +0000 2017', 'is_quote_status': False, 'retweeted': False} + diff --git a/tests/test_html_for_tweet.py b/tests/test_html_for_tweet.py index 6f1ffea..9ba25c6 100644 --- a/tests/test_html_for_tweet.py +++ b/tests/test_html_for_tweet.py @@ -5,7 +5,7 @@ from .config import ( test_tweet_object, test_tweet_html, test_tweet_symbols_object, test_tweet_compat_object, test_tweet_extended_object, test_tweet_extended_html, test_tweet_identical_urls, test_tweet_reply, - test_tweet_media, test_tweet_quoted, + test_tweet_media, test_tweet_quoted, test_tweet_retweet, unittest ) @@ -90,3 +90,11 @@ class TestHtmlForTweetTestCase(unittest.TestCase): u"""Here\u2019s a quoted tweet. twitter.com/philgyford/sta\u2026
The quoted tweet text.Phil Gyford@philgyford
""", tweet_text) + def test_retweet(self): + "With expand_quoted_status=True it should include a quoted tweet." + tweet_text = self.api.html_for_tweet(test_tweet_retweet) + + self.assertEqual( + u"""My aunt and uncle in a very ill humour one with another, but I made shift with much ado to keep them from scolding.""", + tweet_text) +