def test_after_multiple_execution_all_tweets_in_history( self, test_file, ): test_filepath = test_file.as_posix() tweet1_content = "This is a\n\nmultiline\n\ntweet." tweet2_content = "This is another tweet." from logtweet.history import add_tweet_to_history add_tweet_to_history(tweet1_content, history_filepath=test_filepath) add_tweet_to_history(tweet2_content, history_filepath=test_filepath) # Can be tested with ``create_tweet_history_msg`` and ``is_string_in_filelines`` from logtweet.history import create_tweet_history_msg, is_string_in_filelines tweet1_history_msg = create_tweet_history_msg(tweet1_content) tweet2_history_msg = create_tweet_history_msg(tweet2_content) assert is_string_in_filelines(tweet1_history_msg, filepath=test_filepath) assert is_string_in_filelines(tweet2_history_msg, filepath=test_filepath)
def test_false_for_string_not_in_file(self, test_file): search_string = "This is what I am looking for." file_content = f"""This is some thing. This is NOT what I am looking for. This is something else.""" test_file.write_text(file_content) from logtweet.history import is_string_in_filelines found = is_string_in_filelines( search_string, filepath=test_file.as_posix(), ) assert found is False
def test_finds_string_with_prefix_in_line(self, test_file): search_string = "This is what I am looking for." file_content = f"""This is some thing. Here is something, but '{search_string}' is in this line too. This is something else.""" test_file.write_text(file_content) from logtweet.history import is_string_in_filelines found = is_string_in_filelines( search_string, filepath=test_file.as_posix(), ) assert found is True
def test_adding_tweet_as_one_line_to_history_file( self, monkeypatch, test_file, ): test_filepath = str(test_file.as_posix()) tweet_content = "This is a\n\nmultiline\n\ntweet." from logtweet.history import add_tweet_to_history add_tweet_to_history(tweet_content, history_filepath=test_filepath) # Can be tested with ``create_tweet_history_msg`` and ``is_string_in_filelines`` from logtweet.history import create_tweet_history_msg, is_string_in_filelines tweet_history_msg = create_tweet_history_msg(tweet_content) assert is_string_in_filelines(tweet_history_msg, filepath=test_filepath)