예제 #1
0
 def test_action_1(self):
     data = {
         "behavior": "test",
         "check_scenario": False,
         "command_action": {
             "command": "cmd_id",
             "nodes": {},
             "request_data": {}
         }
     }
     registered_factories[Action] = action_factory
     actions["action_mock"] = MockAction
     self.user.parametrizer = MockParametrizer(self.user, {})
     self.user.message = PicklableMock()
     local_vars = PicklableMock()
     local_vars.values = dict()
     self.user.local_vars = local_vars
     test_incremental_id = "test_incremental_id"
     self.user.message.incremental_id = test_incremental_id
     behavior = PicklableMock()
     behavior.check_got_saved_id = Mock(return_value=False)
     self.user.behaviors = behavior
     action = SelfServiceActionWithState(data)
     text_preprocessing_result_raw = PicklableMock()
     text_preprocessing_result = Mock(raw=text_preprocessing_result_raw)
     result = action.run(self.user, text_preprocessing_result, None)
     behavior.check_got_saved_id.assert_called_once()
     behavior.add.assert_called_once()
     self.assertEqual(result[0].name, "cmd_id")
     self.assertEqual(result[0].raw, {
         'messageName': 'cmd_id',
         'payload': {}
     })
예제 #2
0
 def test_action_2(self):
     data = {
         "behavior": "test",
         "check_scenario": False,
         "command_action": {
             "command": "cmd_id",
             "nodes": {}
         }
     }
     self.user.parametrizer = MockParametrizer(self.user, {})
     self.user.message = PicklableMock()
     test_incremental_id = "test_incremental_id"
     self.user.message.incremental_id = test_incremental_id
     behavior = PicklableMock()
     self.user.behaviors = behavior
     behavior.check_got_saved_id = Mock(return_value=True)
     action = SelfServiceActionWithState(data)
     result = action.run(self.user, None)
     behavior.add.assert_not_called()
     self.assertIsNone(result)