def test_rt_with_entity_1(self): status = self.thaw_tweet('rt_with_entity_1') tweet = Tweet(self.settings, status, self.api) expected_content = '+1 \n---\nRT @lisacrispin\nThanks again to all the wonderful, welcoming people who made @boosterconf amazing. Umbrellas, great food, perfect mix of session types & lengths, great diversity, wide range of topics, so fun. #booster2019 💜\nhttps://twitter.com/lisacrispin/status/1106754071233552384' self.assertEqual(expected_content, tweet.clean_content)
def test_mention_replacement_1(self): status = self.thaw_tweet('mention_replacement_1') tweet = Tweet(self.settings, status, self.api) expected_content = '#booster2019 was another great time. Lovely city, on-point organization (food, coffee), awesome talks & crowd (including an evolter, @MartinBurnsSCO).' self.assertEqual(expected_content, tweet.clean_content)
def test_rt_with_mentions(self): status = self.thaw_tweet('retweet_with_mentions') tweet = Tweet(self.settings, status, self.api) expected_content = 'RT @lorddeath\nTbh I need to find time to email @aaisp and be prepared to do some troubleshooting, as my “@a.1” line drops pretty much daily :( Even @aaisp can\'t force BT OpenReach to give me fully-stable lines :p' self.assertEqual(expected_content, tweet.clean_content)
def test_quote_tweet_mention_mangle_1(self): status = self.thaw_tweet('quote_tweet_mention_mangle_1') tweet = Tweet(self.settings, status, self.api) expected_content = """Say no to spec work. https://euronews.com/2019/04/15/fire-underway-at-notre-dame-cathedral-in-paris-firefighters-say Source: https://twitter.com/EPhilippePM/status/1118472220509126661 cc @nospec --- RT @EPhilippePM Faut-il reconstruire une flèche ? À l’identique ? Adaptée aux techniques et aux enjeux de notre époque ? Un concours international d’architecture portant sur la reconstruction de la flèche de la cathédrale sera organisé. #Not… https://twitter.com/EPhilippePM/status/1118472220509126661""" self.assertEqual(expected_content, tweet.clean_content)
result = tweet_poster.post(t) if result: worker_stat.add_toot() # # Post Tweets to Mastodon # toot_poster = TootPoster(c.SEND, session, mast_api, bridge) if bridge.t_settings.post_to_mastodon_enabled and len(new_tweets) > 0: for status in new_tweets: tweet = Tweet(bridge.t_settings, status, twitter_api) result = toot_poster.post(tweet) if result: worker_stat.add_tweet() # # Post Instagram # if len(new_instas) > 0: for data in new_instas: stat_recorded = False
if bridge.mastodon_access_code: toot_poster = TootPoster(c.SEND, session, mast_api, bridge) if bridge.twitter_oauth_token: l.info(f"{bridge.id}: T - @{bridge.twitter_handle}") if settings.post_to_mastodon_enabled and len(new_tweets) > 0: l.info(f"{len(new_tweets)} new tweets found") if not bridge_stat: bridge_stat = BridgeStat(bridge.id) for status in new_tweets: tweet = Tweet(settings, status, twitter_api) try: result = toot_poster.post(tweet) except MoaMediaUploadException as e: continue if result: worker_stat.add_tweet() bridge_stat.add_tweet() bridge.md.last_tweet = tweet.created_at session.commit() #