def test_run_all_analyses(self, out_format): all_analysis = [AnalysisArgs(t, params) for t in AnalysisType] path = get_test_path("*.txt") args = AppArgs(path, get_test_path("."), out_format, all_analysis) chats = load(args) results = analyze(chats, args) assert results is not None output(results, args)
def test_parser(self): file_path = get_test_path("chat_simple_1.txt") args = AppArgs(file_path, "", None, []) chats = parser.load(args) assert len(chats) == 1 chat = chats[0] assert len(chat.participants) == 3 assert len(chat.messages) == 3 assert chat.participants[0] == "User One" assert chat.participants[1] == "User Two" assert chat.participants[2] == "User 3" assert chat.messages[0].date == datetime(2019, 11, 24, 12, 1) assert chat.messages[0].text == "Lorem" assert chat.messages[0].sender == "User One" assert "риб" in chat.messages[1].text assert chat.messages[2].text == "dolor sit amet"
def test_parsing_wildcard(self): file_path = get_test_path("chat_simple_*.txt") args = AppArgs(file_path, "", None, []) chats = parser.load(args) assert len(chats) == 2
def test_parsing_no_file(self): file_path = get_test_path("not_exist_file.txt") args = AppArgs(file_path, "", None, []) with pytest.raises(Exception): parser.load(args)
def teardown_class(cls): patterns = ["chat_simple_1_*.*", "chat_simple_2_*.*"] for pattern in patterns: for file in glob.glob(get_test_path(pattern)): os.remove(file)