def test_visitor_hit_fallback_nlu_fallback_configured(self, mock_fallback_user_data): hit_fall_back, message = HistoryProcessor.visitor_hit_fallback("conversations", fallback_action="action_default_fallback", nlu_fallback_action="utter_please_rephrase") assert hit_fall_back["fallback_count"] == 2 assert hit_fall_back["total_count"] == 4 assert message
def test_fetch_chat_history(self, monkeypatch): def events(*args, **kwargs): json_data = json.load(open("tests/testing_data/history/conversation.json")) return json_data['events'], 'Loading host:mongodb://test_kairon:27016, db:conversation, ' \ 'collection:conversations ' monkeypatch.setattr(HistoryProcessor, "fetch_user_history", events) history, message = HistoryProcessor.fetch_chat_history( sender="5e564fbcdcf0d5fad89e3acd", collection="tests" ) assert len(history) == 12 assert history[0]["event"] assert history[0]["time"] assert history[0]["date"] assert history[0]["text"] assert history[0]["intent"] assert history[0]["confidence"] assert message
def test_delete_user_history(self, mock_delete_chat): collection = '5ebc195d5b04bcbaa45c70cc' sender_id = '*****@*****.**' HistoryProcessor.delete_user_history(collection=collection, sender_id=sender_id, month=16) assert True
def test_total_sessions_error(self, mock_db_timeout): user_list, message = HistoryProcessor.session_count("tests") assert user_list == {} assert message
def test_unsuccessful_session_count_error(self, mock_db_timeout): user_list, message = HistoryProcessor.unsuccessful_session("tests") assert user_list == {} assert message
def test_user_intent_dropoff_error(self, mock_db_timeout): intent_dropoff, message = HistoryProcessor.intents_before_dropoff("tests") assert intent_dropoff == {} assert message
def test_user_dropoff_error(self, mock_db_timeout): user_list, message = HistoryProcessor.user_fallback_dropoff("tests") assert user_list["Dropoff_list"] == {} assert message
def test_conversation_time_range_error(self, mock_db_timeout): conversation_time, message = HistoryProcessor.average_conversation_time_range("tests") assert conversation_time["Conversation_time_range"] == {} assert message
def test_top_action_error(self, mock_db_timeout): with pytest.raises(Exception): HistoryProcessor.top_n_actions("tests")
def test_total_conversation_range(self, mock_mongo_client): conversation_steps, message = HistoryProcessor.total_conversation_range("tests") assert conversation_steps["total_conversation_range"] == {} assert message
def test_flatten_conversation_range(self, mock_mongo_client): f_count, message = HistoryProcessor.flatten_conversations("tests") assert f_count["conversation_data"] == [] assert message
def test_flatten_conversation_error(self, mock_db_timeout): f_count, message = HistoryProcessor.flatten_conversations("tests") assert f_count["conversation_data"] == [] assert message
def test_fallback_range(self, mock_mongo_client): f_count, message = HistoryProcessor.fallback_count_range("tests") assert f_count["fallback_count_rate"] == {} assert message
def test_fallback_range_error(self, mock_db_timeout): f_count, message = HistoryProcessor.fallback_count_range("tests") assert f_count["fallback_count_rate"] == {} assert message
def test_user_retention_range(self, mock_mongo_client): retention, message = HistoryProcessor.user_retention_range("tests") assert retention['retention_range'] == {} assert message
def test_user_input_count_error(self, mock_db_timeout): input_count, message = HistoryProcessor.user_input_count("tests") assert input_count == [] assert message
def test_user_input_count(self, mock_mongo_client): user_input, message = HistoryProcessor.user_input_count("tests") assert user_input == [] assert message
def test_top_action(self, mock_mongo_client): top_n, message = HistoryProcessor.top_n_actions("tests") assert top_n == [] assert message
def test_conversation_time_range(self, mock_mongo_client): conversation_time, message = HistoryProcessor.average_conversation_time_range("tests") assert conversation_time["Conversation_time_range"] == {} assert message
def test_conversation_step_range_error(self, mock_db_timeout): conversation_steps, message = HistoryProcessor.average_conversation_step_range("tests") assert conversation_steps["average_conversation_steps"] == {} assert message
def test_user_dropoff(self, mock_mongo_client): user_list, message = HistoryProcessor.user_fallback_dropoff("tests") assert user_list["Dropoff_list"] == {} assert message
def test_conversation_step_range(self, mock_mongo_client): conversation_steps, message = HistoryProcessor.average_conversation_step_range("tests") assert conversation_steps["average_conversation_steps"] == {} assert message
def test_user_intent_dropoff(self, mock_mongo_client): intent_dropoff, message = HistoryProcessor.intents_before_dropoff("tests") assert intent_dropoff == {} assert message
def test_wordcloud_error(self, mock_db_timeout): with pytest.raises(Exception): HistoryProcessor.word_cloud("tests")
def test_unsuccessful_session_count(self, mock_mongo_client): user_list, message = HistoryProcessor.unsuccessful_session("tests") assert user_list == {} assert message
def test_wordcloud(self, mock_mongo_client): conversation, message = HistoryProcessor.word_cloud("tests") assert conversation == "" assert message
def test_total_sessions(self, mock_mongo_client): user_list, message = HistoryProcessor.session_count("tests") assert user_list == {} assert message
def test_wordcloud_data(self, mock_fallback_user_data): conversation, message = HistoryProcessor.word_cloud("conversations") assert conversation assert message
def test_delete_bot_history(self, mock_delete_chat): collection = '5f1928bda7c0280ca4869da3' msg = HistoryProcessor.delete_bot_history(collection=collection, month=7) assert msg == f"Loading host:mongodb://test_kairon:27016, db:conversation , collection: 5f1928bda7c0280ca4869da3"
def test_wordcloud_data_error(self, mock_fallback_user_data): with pytest.raises(Exception): HistoryProcessor.word_cloud("conversations", u_bound=.5, l_bound=.6)