예제 #1
0
def add_user():
    Utility.load_evironment()
    connect(Utility.environment["mongo_db"],
            host=Utility.environment["mongo_url"])
    user = AccountProcessor.account_setup(
        {
            "email": "*****@*****.**",
            "first_name": "Demo",
            "last_name": "User",
            "password": "******",
            "account": "integration",
            "bot": "integration"
        },
        user="******")
    processor = MongoProcessor()
    processor.save_from_path("tests/testing_data/all", user['bot'],
                             "testAdmin")

    AccountProcessor.account_setup(
        {
            "email": "*****@*****.**",
            "first_name": "Demo",
            "last_name": "User",
            "password": "******",
            "account": "integration2",
            "bot": "integration2"
        },
        user="******")
예제 #2
0
 def test_load_from_path_all_sccenario(self):
     processor = MongoProcessor()
     processor.save_from_path("tests/testing_data/all", "all", "testUser")
     training_data = processor.load_nlu("all")
     assert isinstance(training_data, TrainingData)
     assert training_data.training_examples.__len__() == 283
     assert training_data.entity_synonyms.__len__() == 3
     assert training_data.regex_features.__len__() == 5
     assert training_data.lookup_tables.__len__() == 1
     story_graph = processor.load_stories("all")
     assert isinstance(story_graph, StoryGraph) == True
     assert story_graph.story_steps.__len__() == 13
     domain = processor.load_domain("all")
     assert isinstance(domain, Domain)
     assert domain.slots.__len__() == 8
     assert domain.templates.keys().__len__() == 21
     assert domain.entities.__len__() == 7
     assert domain.form_names.__len__() == 2
     assert domain.user_actions.__len__() == 32
     assert domain.intents.__len__() == 22
     assert not Utility.check_empty_string(
         domain.templates["utter_cheer_up"][0]["image"]
     )
     assert domain.templates["utter_did_that_help"][0]["buttons"].__len__() == 2
     assert domain.templates["utter_offer_help"][0]["custom"]
     assert domain.slots[0].type_name == "unfeaturized"
예제 #3
0
 def test_load_from_path_error(self):
     processor = MongoProcessor()
     loop = asyncio.new_event_loop()
     with pytest.raises(Exception):
         loop.run_until_complete(
             processor.save_from_path("tests/testing_data/error", "tests",
                                      "testUser"))
예제 #4
0
 def test_load_from_path(self):
     processor = MongoProcessor()
     loop = asyncio.new_event_loop()
     assert (loop.run_until_complete(
         processor.save_from_path("tests/testing_data/initial",
                                  bot="tests",
                                  user="******")) is None)
예제 #5
0
 def test_load_from_path_error(self):
     processor = MongoProcessor()
     with pytest.raises(Exception):
         processor.save_from_path("tests/testing_data/error", "tests", "testUser")
예제 #6
0
 def test_load_from_path(self):
     processor = MongoProcessor()
     assert (
         processor.save_from_path("tests/testing_data/initial", "tests", "testUser")
         is None
     )
예제 #7
0
    account = AccountProcessor.add_account("integration2", "testAdmin")
    bot = AccountProcessor.add_bot("integration2", account["_id"], "testAdmin")
    AccountProcessor.add_user(
        email="*****@*****.**",
        first_name="Demo",
        last_name="User",
        password="******",
        account=account["_id"],
        bot=bot["name"],
        user="******",
    )


add_user()
processor = MongoProcessor()
processor.save_from_path("tests/testing_data/all", "1_integration",
                         "testAdmin")


def test_api_wrong_login():
    response = client.post("/api/auth/login",
                           data={
                               "username": "******",
                               "password": "******"
                           })
    actual = response.json()
    assert actual["error_code"] == 422
    assert not actual["success"]
    assert actual["message"] == "User does not exists!"


# need to write test cases for inactive user ,bot and account