def test_can_write_data_to_file(self, words_processor: WordsProcessor, wiki_page: WikiPage): """ test if can write out data loaded from a passed dto :param words_processor: :param wiki_page: :return: None """ words_processor.load_data(wiki_page) assert words_processor.write_in_file("test_file.txt")
def test_can_load_file(self, words_processor: WordsProcessor, test_file: str): """ test if class WordsProcessor can load and read a file line :param words_processor: :return: None """ assert words_processor.load_data(test_file) with pytest.raises(FileExistsError): words_processor.load_data("random_file_not_exists.txt")
def test_can_map_reduce_from_file(self, words_processor: WordsProcessor, test_file: str): """ test map-reduce process from a given file :param words_processor: :param test_file: :return: None """ words_processor.load_data(test_file) result = words_processor.process() assert dict(sorted(result.items(), key=lambda x: x[1], reverse=True)) == { 'text': 2, 'test': 1, 'lazy': 1, 'coming': 1, 'from': 1 }
def test_can_load_data_from_dto(self, wiki_page: WikiPage, words_processor: WordsProcessor) -> None: """ test if the class can load data from a compatible dto :param wiki_page: :param words_processor: :return: None """ assert words_processor.load_data( wiki_page ).text == "test!! text text lazy fox is coming from a fox mom.$^\n"