Ejemplo n.º 1
0
    def test_load_triggers(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLTriggersStore(engine)

        self.assert_load(store)
Ejemplo n.º 2
0
    def test_upload_from_text(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLGenderStore(engine)

        self.assert_upload_from_text(store)
Ejemplo n.º 3
0
    def test_upload_from_csv_file(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLRDFsStore(engine)

        self.assert_upload_from_csv_file(store)
Ejemplo n.º 4
0
    def test_twitter_storage(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLTwitterStore(engine)

        self.assert_twitter_storage(store)
Ejemplo n.º 5
0
    def test_linkedaccounts_storage(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLLinkedAccountStore(engine)

        self.assert_linkedaccounts_storage(store)
Ejemplo n.º 6
0
    def test_upload_from_file_exception(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLPatternNodesStore(engine)

        self.assert_upload_from_file_exception(store)
    def test_upload_from_file(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLPostQuestionProcessorsStore(engine)

        self.assert_upload_from_file(store)
Ejemplo n.º 8
0
    def test_initialise_with_config(self):

        yaml = YamlConfigurationFile()
        self.assertIsNotNone(yaml)
        yaml.load_from_text(
            """
                sql:
                    type:   sql
                    config:
                        url: sqlite:///:memory
                        echo: false
                        encoding: utf-8
                        create_db: true
                        drop_all_first: True
                """, ConsoleConfiguration(), ".")

        mongo_config = yaml.get_section("sql")

        config = SQLStorageConfiguration()
        config.load_config_section(yaml, mongo_config, ".")

        self.assertEqual(config.url, 'sqlite:///:memory:')
        self.assertEqual(config.echo, False)
        self.assertEqual(config.encoding, 'utf-8')
        self.assertEqual(config.create_db, True)
        self.assertEqual(config.drop_all_first, True)
Ejemplo n.º 9
0
    def test_empty_named(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLSetsStore(engine)

        self.assert_empty_named(store)
Ejemplo n.º 10
0
    def test_read_write_question_properties_in_db(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLConversationStore(engine)

        client = TestClient()
        client_context = client.create_client_context("user1")

        store.empty()

        properties1 = {"key1": "value1", "key2": "value2"}

        store._write_properties_to_db(client_context, 1, 2,
                                      ConversationPropertyDAO.QUESTION,
                                      properties1)

        store.commit()

        properties2 = {}

        store._read_properties_from_db(client_context, 1, 2,
                                       ConversationPropertyDAO.QUESTION,
                                       properties2)

        self.assertEqual({"key1": "value1", "key2": "value2"}, properties2)

        store.empty()
Ejemplo n.º 11
0
 def test_initial_creation(self):
     config = SQLStorageConfiguration()
     self.assertEqual(config.url, 'sqlite:///:memory:')
     self.assertEqual(config.echo, False)
     self.assertEqual(config.encoding, 'utf-8')
     self.assertEqual(config.create_db, True)
     self.assertEqual(config.drop_all_first, True)
Ejemplo n.º 12
0
    def test_sentences_in_db(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLConversationStore(engine)

        store.empty()

        client = TestClient()
        client_context = client.create_client_context("user1")

        question1 = Question.create_from_text(client_context, "Hello There")
        question1.sentence(0).response = "Hi"
        question1.sentence(0)._positivity = 0.5
        question1.sentence(0)._subjectivity = 0.6

        store._write_sentences_to_db(client_context, 1, question1)

        store.commit()

        question2 = Question()

        store._read_sentences_from_db(client_context, 1, question2)

        self.assertEqual(1, len(question2.sentences))
        self.assertEqual(0.5, question2.sentences[0].positivity)
        self.assertEqual(0.6, question2.sentences[0].subjectivity)
        self.assertEqual(["Hello", "There"], question2.sentences[0].words)
        self.assertEqual("Hi", question2.sentences[0].response)

        store.empty()
Ejemplo n.º 13
0
    def test_match_context_in_db(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLConversationStore(engine)

        store.empty()

        client = TestClient()
        client_context = client.create_client_context("user1")

        matched_context1 = MatchContext(100,
                                        100,
                                        sentence="Hello",
                                        response="Hi There")
        matched_context1._matched_nodes = []
        matched_context1._template_node = None

        store._write_match_context_to_db(client_context, 1, matched_context1)

        store.commit()

        matched_context2 = MatchContext(100, 100)

        store._read_match_context_from_db(client_context, 1, matched_context2)

        self.assertEqual(100, matched_context2.max_search_timeout)
        self.assertEqual(100, matched_context2.max_search_depth)
        self.assertEqual("Hello", matched_context2.sentence)
        self.assertEqual("Hi There", matched_context2.response)

        store.empty()
Ejemplo n.º 14
0
    def test_upload_from_file(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLTriggersStore(engine)

        self.assert_upload_from_file(store, verbose=False)
Ejemplo n.º 15
0
    def test_initialise(self):

        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        with self.assertRaises(NotImplementedError):
            engine.binaries_store()
Ejemplo n.º 16
0
    def test_add_to_set_duplicates(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLSetsStore(engine)

        self.assert_add_to_set_duplicates(store)
Ejemplo n.º 17
0
    def test_load_nodes(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLPatternNodesStore(engine)

        self.assert_load(store)
Ejemplo n.º 18
0
    def test_empty_defaults(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLDefaultVariableStore(engine)

        self.assert_empty_defaults(store)
Ejemplo n.º 19
0
    def add_default_stores(amap):

        sql = SQLStorageConfiguration()
        amap['sqlite'] = {
            'type': 'sql',
            'config': sql.create_sqlstorage_config()
        }

        mongo = MongoStorageConfiguration()
        amap['mongo'] = {
            'type': 'mongo',
            'config': mongo.create_mongostorage_config()
        }

        redis = RedisStorageConfiguration()
        amap['redis'] = {
            'type': 'redis',
            'config': redis.create_redisstorage_config()
        }

        file = FileStorageConfiguration()
        amap['file'] = {
            'type': 'file',
            'config': file.create_filestorage_config()
        }

        logger = LoggerStorageConfiguration()
        amap['logger'] = {
            'type': 'logger',
            'config': logger.create_loggerstorage_config()
        }
Ejemplo n.º 20
0
    def test_upload_from_file(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLDefaultVariableStore(engine)

        self.assert_upload_from_file(store)
Ejemplo n.º 21
0
    def test_save_learnf(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLLearnfStore(engine)

        self.assert_save_learnf(store)
Ejemplo n.º 22
0
    def test_load_exception(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLPreProcessorsStore(engine)

        self.assert_load_exception(store)
Ejemplo n.º 23
0
    def test_save_errors(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLErrorsStore(engine)

        self.assert_errors(store)
Ejemplo n.º 24
0
    def test_upload_from_file_verbose(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLPreProcessorsStore(engine)

        self.assert_upload_from_file(store, verbose=True)
Ejemplo n.º 25
0
    def test_lookup_storage(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLGenderStore(engine)

        self.assert_lookup_storage(store)
Ejemplo n.º 26
0
    def test_upload_text_files_from_directory_no_subdir(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLMapsStore(engine)

        self.assert_upload_text_files_from_directory_no_subdir(store)
Ejemplo n.º 27
0
    def test_rdf_storage(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLRDFsStore(engine)

        self.assert_rdf_storage(store)
Ejemplo n.º 28
0
    def test_empty_properties(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLPropertyStore(engine)

        self.assert_empty_properties(store)
Ejemplo n.º 29
0
    def test_upload_csv_files_from_directory_with_subdir(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLRDFsStore(engine)

        self.assert_upload_csv_files_from_directory_with_subdir(store)
Ejemplo n.º 30
0
    def test_add_to_collection_exception(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLRegexStore(engine)

        self.assert_add_to_collection_collection(store)