Esempio n. 1
0
 def test_generate_response(self):
     client = DummyDatabaseClient()
     client.scenarios = [
         DummyScenario(conditions='True', response='OK!', attributes={})
     ]
     engine = DialogEngine(client)
     resposne = engine.generate_response_text('')
     eq_(resposne.scenario.response, 'OK!')
Esempio n. 2
0
 def test_generate_response_wuthout_condition_is_true(self):
     client = DummyDatabaseClient()
     client.scenarios = [
         DummyScenario(conditions='False', response='OK!', attributes={})
     ]
     engine = DialogEngine(client)
     resposne = engine.generate_response_text('')
     ok_(resposne.scenario is None)
Esempio n. 3
0
 def test_generate_response_with_user_is_none(self):
     client = DummyDatabaseClient()
     client.scenarios = [
         DummyScenario(conditions="True", response='OK!', attributes={})
     ]
     engine = DialogEngine(client)
     resposne = engine.generate_response_text('')
     eq_(resposne.scenario.response, 'OK!')
     eq_(client._history[0][2], '1')
Esempio n. 4
0
 def test_generate_response_check_save_history_response_None(self):
     client = DummyDatabaseClient()
     client.scenarios = [
         DummyScenario(conditions='False', response='OK!', attributes={})
     ]
     engine = DialogEngine(client)
     engine.generate_response_text('', user='******')
     eq_(client._history[0][0], '')
     eq_(client._history[0][1], None)
     eq_(client._history[0][2], '111')
Esempio n. 5
0
 def test_generate_response_with_line_code(self):
     client = DummyDatabaseClient()
     conditions = """True \
         and True"""
     client.scenarios = [
         DummyScenario(conditions=conditions, response='OK!', attributes={})
     ]
     engine = DialogEngine(client)
     resposne = engine.generate_response_text('')
     eq_(resposne.scenario.response, 'OK!')
Esempio n. 6
0
 def test_generate_response_with_other_value(self):
     client = DummyDatabaseClient()
     client.scenarios = [
         DummyScenario(conditions='aaa == "bbb"',
                       response='OK!',
                       attributes={})
     ]
     engine = DialogEngine(client)
     resposne = engine.generate_response_text('', aaa='bbb')
     eq_(resposne.scenario.response, 'OK!')
Esempio n. 7
0
 def test_generate_response_with_request(self):
     client = DummyDatabaseClient()
     client.scenarios = [
         DummyScenario(conditions='regex("a*?")',
                       response='OK!',
                       attributes={})
     ]
     engine = DialogEngine(client)
     resposne = engine.generate_response_text('aaa')
     eq_(resposne.scenario.response, 'OK!')
Esempio n. 8
0
 def test_generate_response_with_attributes(self):
     client = DummyDatabaseClient()
     conditions = """attributes['id'] == '111'"""
     client.scenarios = [
         DummyScenario(conditions=conditions,
                       response='OK!',
                       attributes={"id": "111"})
     ]
     engine = DialogEngine(client)
     resposne = engine.generate_response_text('')
     eq_(resposne.scenario.response, 'OK!')
Esempio n. 9
0
 def test_train_matcher(self):
     client = DummyDatabaseClient()
     engine = DialogEngine(client)
     engine.train_matcher("classifier_test_model")
     shutil.rmtree("classifier_test_model", ignore_errors=True)
Esempio n. 10
0
 def test_get_user_id(self):
     client = DummyDatabaseClient()
     engine = DialogEngine(client)
     eq_(engine.get_user_id(**{"aaa": "aaa"}), "1")
Esempio n. 11
0
 def test_get_user_attributes(self):
     client = DummyDatabaseClient()
     engine = DialogEngine(client)
     eq_(engine.get_user_attributes("111"), {"aaa": "aaa"})
Esempio n. 12
0
 def test_create_new_user_with_option(self):
     client = DummyDatabaseClient()
     engine = DialogEngine(client)
     eq_(engine.create_new_user(option={"aaa": "aaa"}), "1")
Esempio n. 13
0
 def test_create_new_user(self):
     client = DummyDatabaseClient()
     engine = DialogEngine(client)
     eq_(engine.create_new_user(), "1")