Example #1
0
    def test_add_to_map_no_overwrite_existing(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLMapsStore(engine)

        self.assert_add_to_map_no_overwrite_existing(store)
Example #2
0
    def test_upload_from_text(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLGenderStore(engine)

        self.assert_upload_from_text(store)
Example #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)
Example #4
0
    def test_twitter_storage(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLTwitterStore(engine)

        self.assert_twitter_storage(store)
Example #5
0
    def test_linkedaccounts_storage(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLLinkedAccountStore(engine)

        self.assert_linkedaccounts_storage(store)
Example #6
0
    def test_load_nodes(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLPatternNodesStore(engine)

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

        self.assert_upload_from_file(store)
Example #8
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()
Example #9
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()
Example #10
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)
Example #11
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()
Example #12
0
    def test_load_triggers(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLTriggersStore(engine)

        self.assert_load(store)
Example #13
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)
Example #14
0
    def test_empty_regexes(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLRegexStore(engine)

        self.assert_empty_regexes(store)
    def test_empty_properties(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLPropertyStore(engine)

        self.assert_empty_properties(store)
Example #16
0
    def test_empty_named(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLSetsStore(engine)

        self.assert_empty_named(store)
Example #17
0
    def test_initialise(self):

        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        with self.assertRaises(NotImplementedError):
            engine.binaries_store()
Example #18
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)
Example #19
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)
Example #20
0
    def test_empty_defaults(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLDefaultVariableStore(engine)

        self.assert_empty_defaults(store)
Example #21
0
    def test_save_learnf(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLLearnfStore(engine)

        self.assert_save_learnf(store)
Example #22
0
    def test_upload_from_file(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLDefaultVariableStore(engine)

        self.assert_upload_from_file(store)
Example #23
0
    def test_save_errors(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLErrorsStore(engine)

        self.assert_errors(store)
Example #24
0
    def test_load_exception(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLPreProcessorsStore(engine)

        self.assert_load_exception(store)
Example #25
0
    def test_lookup_storage(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLGenderStore(engine)

        self.assert_lookup_storage(store)
Example #26
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)
Example #27
0
    def test_rdf_storage(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLRDFsStore(engine)

        self.assert_rdf_storage(store)
Example #28
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)
Example #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)
Example #30
0
    def test_load_no_map_found(self):
        config = SQLStorageConfiguration()
        engine = SQLStorageEngine(config)
        engine.initialise()
        store = SQLMapsStore(engine)

        self.assert_load_no_map_found(store)