Exemple #1
0
async def chat_history_users(current_user: User = Depends(
    auth.get_current_user)):
    return {
        "data": {
            "users": ChatHistory.fetch_chat_users(current_user.get_bot())
        }
    }
Exemple #2
0
async def chat_history(
    sender: Text, current_user: User = Depends(auth.get_current_user)
):
    return {
        "data": {
            "history": list(ChatHistory.fetch_chat_history(current_user.bot, sender))
        }
    }
Exemple #3
0
async def chat_history_users(current_user: User = Depends(
    auth.get_current_user)):
    """ This function returns the list of the chatbot users """
    return {
        "data": {
            "users": ChatHistory.fetch_chat_users(current_user.get_bot())
        }
    }
Exemple #4
0
async def chat_history(sender: Text,
                       current_user: User = Depends(auth.get_current_user)):
    """ This function returns the chat history for a particular user of the chatbot """
    return {
        "data": {
            "history":
            list(ChatHistory.fetch_chat_history(current_user.get_bot(),
                                                sender))
        }
    }
 def test_fetch_chat_history(self, mock_chat_history):
     history = ChatHistory.fetch_chat_history(
         sender="5e564fbcdcf0d5fad89e3acd", bot="tests")
     print(history)
     assert len(history) == 12
     assert history[0]['event']
     assert history[0]['time']
     assert history[0]['date']
     assert history[0]['text']
     assert history[0]['is_exists'] == False or history[0]['is_exists']
     assert history[0]['intent']
     assert history[0]['confidence']
Exemple #6
0
 def test_fetch_chat_history(self, mock_chat_history):
     history = ChatHistory.fetch_chat_history(
         sender="5e564fbcdcf0d5fad89e3acd", bot="tests")
     print(history)
     assert len(history) == 12
     assert history[0]["event"]
     assert history[0]["time"]
     assert history[0]["date"]
     assert history[0]["text"]
     assert history[0]["is_exists"] == False or history[0]["is_exists"]
     assert history[0]["intent"]
     assert history[0]["confidence"]
 def test_fetch_chat_users_error(self, mock_get_tracker_and_domain):
     with pytest.raises(Exception):
         users = ChatHistory.fetch_chat_users(bot="tests")
         assert len(users) == 0
 def test_fetch_chat_users_db_error(self, mock_mongo_processor):
     with pytest.raises(Exception):
         users = ChatHistory.fetch_chat_users(bot="tests")
         assert len(users) == 0
 def test_conversation_steps(self, mock_chat_history):
     conversation_steps = ChatHistory.conversation_steps("tests")
     assert conversation_steps
Exemple #10
0
async def conversation_time(current_user: User = Depends(
    auth.get_current_user)):
    """ This returns the duration of the chat that took place between the user and the
        chatbot """
    return {"data": ChatHistory.conversation_time(current_user.get_bot())}
Exemple #11
0
 def test_conversation_time_empty(self, mock_chat_history_empty):
     conversation_time = ChatHistory.conversation_time("tests")
     assert not conversation_time
Exemple #12
0
 def test_visitor_hit_fallback(self, mock_chat_history):
     hit_fall_back = ChatHistory.visitor_hit_fallback("tests")
     assert hit_fall_back['fallback_count'] == 3
     assert hit_fall_back['total_count'] == 31
Exemple #13
0
 def test_visitor_hit_fallback_error(self, mock_get_tracker_and_domain):
     with pytest.raises(Exception):
         hit_fall_back = ChatHistory.visitor_hit_fallback("tests")
         assert hit_fall_back['fallback_count'] == 0
         assert hit_fall_back['total_count'] == 0
Exemple #14
0
 def test_fetch_chat_history_empty(self, mock_chat_history_empty):
     history = ChatHistory.fetch_chat_history(sender="123", bot="tests")
     assert len(history) == 0
Exemple #15
0
 def test_fetch_chat_history_error(self, mock_get_tracker_and_domain):
     with pytest.raises(Exception):
         history = ChatHistory.fetch_chat_history(sender="123", bot="tests")
         assert len(history) == 0
Exemple #16
0
 def test_visitor_hit_fallback_empty(self, mock_chat_history_empty):
     hit_fall_back = ChatHistory.visitor_hit_fallback("tests")
     assert hit_fall_back["fallback_count"] == 0
     assert hit_fall_back["total_count"] == 0
Exemple #17
0
async def visitor_hit_fallback(current_user: User = Depends(
    auth.get_current_user)):
    """ This function returns the number of times the bot hit
        a fallback (the bot admitting to not having a reply for a given
        text/query) for a given user """
    return {"data": ChatHistory.visitor_hit_fallback(current_user.get_bot())}
Exemple #18
0
async def visitor_hit_fallback(current_user: User = Depends(
    auth.get_current_user)):
    return {"data": ChatHistory.visitor_hit_fallback(current_user.get_bot())}
Exemple #19
0
async def conversation_steps(current_user: User = Depends(
    auth.get_current_user)):
    """ This function returns the number of conversation steps that took place in the chat
        between the user and the chatbot """
    return {"data": ChatHistory.conversation_steps(current_user.get_bot())}
Exemple #20
0
 def test_conversation_steps_empty(self, mock_chat_history_empy):
     conversation_steps = ChatHistory.conversation_steps("tests")
     assert not conversation_steps
Exemple #21
0
 def test_conversation_time(self, mock_chat_history):
     conversation_time = ChatHistory.conversation_time("tests")
     assert conversation_time
Exemple #22
0
 def test_fetch_chat_users_empty(self, mock_chat_history_empy):
     with pytest.raises(Exception):
         users = ChatHistory.fetch_chat_users(bot="tests")
         assert len(users) == 0
Exemple #23
0
async def conversation_time(current_user: User = Depends(
    auth.get_current_user)):
    return {"data": ChatHistory.conversation_time(current_user.get_bot())}
Exemple #24
0
 def test_conversation_steps_error(self, mock_get_tracker_and_domain):
     with pytest.raises(Exception):
         conversation_steps = ChatHistory.conversation_steps("tests")
         assert not conversation_steps