def test_exact_words(): exact_phrase = 'duda kaczyński kempa' search_tweets_task = st.SearchTweetsTask(exact_words=exact_phrase) tweets_collector = st.CollectorTweetOutput() st.TweetSearchRunner(search_tweets_task=search_tweets_task, tweet_outputs=[tweets_collector]).run() tweet_list_assert_condition( tweets_collector.get_raw_list(), lambda tweet: to_base_text( exact_phrase) in to_base_text(tweet.full_text))
def test_search_to_username(): username = '******' search_tweets_task = st.SearchTweetsTask(to_username=username, tweets_limit=100) tweets_collector = st.CollectorTweetOutput() st.TweetSearchRunner(search_tweets_task=search_tweets_task, tweet_outputs=[tweets_collector]).run() tweet_list_assert_condition( tweets_collector.get_scrapped_tweets(), lambda tweet: to_base_text(username) in to_base_text(tweet.full_text))
def contains_any_word(words: str, value: str) -> bool: return any( [to_base_text(word) in to_base_text(value) for word in words.split()]) is True