def test_dialogue_manager_run(self): obj1 = dialogue_manager.DialogueManager( { 'scenarios': self.test_scenarios, 'external_actions': { 'nothing_found_action': self.TestAction } }, self.app_name) obj2 = dialogue_manager.DialogueManager( { 'scenarios': self.test_scenarios, 'external_actions': {} }, self.app_name) # путь по умолчанию без выполнения условий self.assertTrue( obj1.run(self.test_text_preprocessing_result, self.test_user1) == ( "TestNameResult", True)) self.assertTrue( obj2.run(self.test_text_preprocessing_result, self.test_user1) == ( "TestNameResult", True)) # случай когда срабатоли оба условия self.assertTrue( obj1.run(self.test_text_preprocessing_result, self.test_user2) == ( "TestNameResult", True)) # случай, когда 2-е условие не выполнено self.assertTrue( obj2.run(self.test_text_preprocessing_result, self.test_user3) == ( 'TestNameResult', True))
def test_dialogue_manager_run(self): obj1 = dialogue_manager.DialogueManager( { 'scenarios': self.test_scenarios, 'external_actions': { 'nothing_found_action': self.TestAction } }, self.app_name) obj2 = dialogue_manager.DialogueManager( { 'scenarios': self.test_scenarios, 'external_actions': {} }, self.app_name) # путь по умолчанию без выполнения условий self.assertTrue( obj1.run(self.test_text_preprocessing_result, self.test_user1) == ( "TestNameResult", True)) self.assertTrue( obj2.run(self.test_text_preprocessing_result, self.test_user1) == ( "TestNameResult", True)) # случай когда срабатоли оба условия self.assertTrue( obj1.run(self.test_text_preprocessing_result, self.test_user2) == ( "TestNameResult", True)) # случай, когда 2-е условие не выполнено self.assertTrue( obj2.run(self.test_text_preprocessing_result, self.test_user3) == ( 'TestNameResult', True)) # проверка на вызов before_action, если такой задан в external_actions obj2.run(self.test_text_preprocessing_result, self.test_user4) self.assertTrue(self.test_user4.descriptions['external_actions'] ['before_action'].run.called)
def test_dialogue_manager_found_action(self): obj1 = dialogue_manager.DialogueManager( { 'scenarios': self.test_scenarios, 'external_actions': { 'nothing_found_action': self.TestAction } }, self.app_name) obj2 = dialogue_manager.DialogueManager( { 'scenarios': self.test_scenarios, 'external_actions': {} }, self.app_name) self.assertTrue(obj1._nothing_found_action().descriptions, self.TestAction.descriptions) with self.assertRaises(TypeError): obj2._nothing_found_action()
def test_dialogue_manager_run_scenario(self): obj = dialogue_manager.DialogueManager( { 'scenarios': self.test_scenarios, 'external_actions': { 'nothing_found_action': self.TestAction } }, self.app_name) self.assertTrue( obj.run_scenario(1, self.test_text_preprocessing_result, self.test_user1) == "ResultTestName") self.assertTrue( obj.run_scenario(2, self.test_text_preprocessing_result, self.test_user1) == "TestNameResult")
def test_dialogue_manager_init(self): obj1 = dialogue_manager.DialogueManager( { 'scenarios': self.test_scenarios, 'external_actions': '333' }, self.app_name) self.assertTrue(obj1.scenario_descriptions == { 'scenarios': self.test_scenarios, 'external_actions': '333' }) self.assertTrue(obj1.scenarios == self.test_scenarios) self.assertTrue(obj1.scenario_keys == {1, 2}) self.assertTrue(obj1.actions == '333') self.assertTrue(obj1.NOTHING_FOUND_ACTION == "nothing_found_action")