Exemplo n.º 1
0
    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
Exemplo n.º 2
0
    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
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 def test_total_sessions_error(self, mock_db_timeout):
     user_list, message = HistoryProcessor.session_count("tests")
     assert user_list == {}
     assert message
Exemplo n.º 5
0
 def test_unsuccessful_session_count_error(self, mock_db_timeout):
     user_list, message = HistoryProcessor.unsuccessful_session("tests")
     assert user_list == {}
     assert message
Exemplo n.º 6
0
 def test_user_intent_dropoff_error(self, mock_db_timeout):
     intent_dropoff, message = HistoryProcessor.intents_before_dropoff("tests")
     assert intent_dropoff == {}
     assert message
Exemplo n.º 7
0
 def test_user_dropoff_error(self, mock_db_timeout):
     user_list, message = HistoryProcessor.user_fallback_dropoff("tests")
     assert user_list["Dropoff_list"] == {}
     assert message
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
 def test_top_action_error(self, mock_db_timeout):
     with pytest.raises(Exception):
         HistoryProcessor.top_n_actions("tests")
Exemplo n.º 10
0
 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
Exemplo n.º 11
0
 def test_flatten_conversation_range(self, mock_mongo_client):
     f_count, message = HistoryProcessor.flatten_conversations("tests")
     assert f_count["conversation_data"] == []
     assert message
Exemplo n.º 12
0
 def test_flatten_conversation_error(self, mock_db_timeout):
     f_count, message = HistoryProcessor.flatten_conversations("tests")
     assert f_count["conversation_data"] == []
     assert message
Exemplo n.º 13
0
 def test_fallback_range(self, mock_mongo_client):
     f_count, message = HistoryProcessor.fallback_count_range("tests")
     assert f_count["fallback_count_rate"] == {}
     assert message
Exemplo n.º 14
0
 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
Exemplo n.º 15
0
 def test_user_retention_range(self, mock_mongo_client):
     retention, message = HistoryProcessor.user_retention_range("tests")
     assert retention['retention_range'] == {}
     assert message
Exemplo n.º 16
0
 def test_user_input_count_error(self, mock_db_timeout):
     input_count, message = HistoryProcessor.user_input_count("tests")
     assert input_count == []
     assert message
Exemplo n.º 17
0
 def test_user_input_count(self, mock_mongo_client):
     user_input, message = HistoryProcessor.user_input_count("tests")
     assert user_input == []
     assert message
Exemplo n.º 18
0
 def test_top_action(self, mock_mongo_client):
     top_n, message = HistoryProcessor.top_n_actions("tests")
     assert top_n == []
     assert message
Exemplo n.º 19
0
 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
Exemplo n.º 20
0
 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
Exemplo n.º 21
0
 def test_user_dropoff(self, mock_mongo_client):
     user_list, message = HistoryProcessor.user_fallback_dropoff("tests")
     assert user_list["Dropoff_list"] == {}
     assert message
Exemplo n.º 22
0
 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
Exemplo n.º 23
0
 def test_user_intent_dropoff(self, mock_mongo_client):
     intent_dropoff, message = HistoryProcessor.intents_before_dropoff("tests")
     assert intent_dropoff == {}
     assert message
Exemplo n.º 24
0
 def test_wordcloud_error(self, mock_db_timeout):
     with pytest.raises(Exception):
         HistoryProcessor.word_cloud("tests")
Exemplo n.º 25
0
 def test_unsuccessful_session_count(self, mock_mongo_client):
     user_list, message = HistoryProcessor.unsuccessful_session("tests")
     assert user_list == {}
     assert message
Exemplo n.º 26
0
 def test_wordcloud(self, mock_mongo_client):
     conversation, message = HistoryProcessor.word_cloud("tests")
     assert conversation == ""
     assert message
Exemplo n.º 27
0
 def test_total_sessions(self, mock_mongo_client):
     user_list, message = HistoryProcessor.session_count("tests")
     assert user_list == {}
     assert message
Exemplo n.º 28
0
 def test_wordcloud_data(self, mock_fallback_user_data):
     conversation, message = HistoryProcessor.word_cloud("conversations")
     assert conversation
     assert message
Exemplo n.º 29
0
    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"
Exemplo n.º 30
0
 def test_wordcloud_data_error(self, mock_fallback_user_data):
     with pytest.raises(Exception):
         HistoryProcessor.word_cloud("conversations", u_bound=.5, l_bound=.6)