def test_get_all_tweets(self): tweet_db = models.Tweet( username="******", content="Test Content", posted_at=datetime.datetime.now(), last_edited_at=datetime.datetime.now(), ) for tag in ["tag_1", "tag_2"]: tweet_db.tags.append(models.Tag(tag=tag)) tweets = [tweet_db, tweet_db] self.twitter_clone_db.get_all_tweets.return_value = tweets all_tweets = [] t1 = Timestamp() t2 = Timestamp() for tweet_ in tweets: if tweet_.posted_at is not None: t1.FromDatetime(tweet_.posted_at) if tweet_.last_edited_at is not None: t2.FromDatetime(tweet_.last_edited_at) else: t2 = t1 ret_tweet = self.tweet( id=tweet_.id, username=tweet_.username, content=tweet_.content, posted_at=t1, last_edited_at=t2, ) for tag in tweet_.tags: ret_tweet.tag.append(tag.tag) all_tweets.append(ret_tweet) helper = Helper(self.twitter_clone_db) assert helper.get_all_tweets() == all_tweets
def GetAllTweets(self, request, context): logger.info("Calling GetAllTweets") helper = Helper() all_tweets = helper.get_all_tweets() for tweet in all_tweets: yield tweet