コード例 #1
0
ファイル: account.py プロジェクト: siddbane10/kairon
async def add_bot(request: TextData,
                  current_user: User = Depends(auth.get_current_user)):
    """
    Add new bot in a account.
    """
    AccountProcessor.add_bot(request.data, current_user.account,
                             current_user.get_user())
    return {'message': 'Bot created'}
コード例 #2
0
 def test_add_bot_for_existing_user(self):
     bot_response = AccountProcessor.add_bot("test_version_2",
                                             pytest.account,
                                             "*****@*****.**", False)
     bot = Bot.objects(name="test_version_2").get().to_mongo().to_dict()
     assert bot['_id'].__str__() == bot_response['_id'].__str__()
     user = User.objects(email="*****@*****.**").get()
     assert len(user.bot) == 2
     config = Configs.objects(
         bot=bot['_id'].__str__()).get().to_mongo().to_dict()
     assert config['language']
     assert config['pipeline'][6]['name'] == 'FallbackClassifier'
     assert config['pipeline'][6]['threshold'] == 0.7
     assert config['policies'][2]['name'] == 'RulePolicy'
     assert config['policies'][2][
         'core_fallback_action_name'] == "action_default_fallback"
     assert config['policies'][2]['core_fallback_threshold'] == 0.3
     assert Rules.objects(bot=bot['_id'].__str__()).get()
     assert Responses.objects(name='utter_default',
                              bot=bot['_id'].__str__(),
                              status=True).get()
コード例 #3
0
 def test_add_bot(self):
     bot_response = AccountProcessor.add_bot("test", pytest.account,
                                             "*****@*****.**", True)
     bot = Bot.objects(name="test").get().to_mongo().to_dict()
     assert bot['_id'].__str__() == bot_response['_id'].__str__()
     config = Configs.objects(
         bot=bot['_id'].__str__()).get().to_mongo().to_dict()
     assert config['language']
     assert config['pipeline'][6]['name'] == 'FallbackClassifier'
     assert config['pipeline'][6]['threshold'] == 0.7
     assert config['policies'][2]['name'] == 'RulePolicy'
     assert config['policies'][2][
         'core_fallback_action_name'] == "action_default_fallback"
     assert config['policies'][2]['core_fallback_threshold'] == 0.3
     assert Rules.objects(bot=bot['_id'].__str__()).get()
     assert Responses.objects(name__iexact='utter_please_rephrase',
                              bot=bot['_id'].__str__(),
                              status=True).get()
     assert Responses.objects(name='utter_default',
                              bot=bot['_id'].__str__(),
                              status=True).get()
     pytest.bot = bot_response['_id'].__str__()
コード例 #4
0
 def test_add_none_bot(self):
     with pytest.raises(AppException):
         AccountProcessor.add_bot(None, 1, "testAdmin")
コード例 #5
0
 def test_add_empty_bot(self):
     with pytest.raises(AppException):
         AccountProcessor.add_bot("", 1, "testAdmin")
コード例 #6
0
 def test_add_duplicate_bot_case_insensitive(self):
     with pytest.raises(Exception):
         AccountProcessor.add_bot("TEST", 1, "testAdmin")
コード例 #7
0
 def test_add_duplicate_bot(self):
     with pytest.raises(Exception):
         AccountProcessor.add_bot("test", 1, "testAdmin")
コード例 #8
0
 def test_add_bot(self):
     bot_response = AccountProcessor.add_bot("test", 1, "testAdmin")
     assert bot_response
     pytest.bot = bot_response["_id"].__str__()
コード例 #9
0
 def test_add_none_user(self):
     with pytest.raises(AppException):
         AccountProcessor.add_bot('test', 1, None)