Ejemplo n.º 1
0
    def setUp(self):
        created = ActionExecutionDB()
        created.action = {'uid': 'action:core:ask'}
        created.status = 'succeeded'
        created.runner = {'name': 'inquirer'}
        created.liveaction = INQUIRY_LIVEACTION
        created.result = INQUIRY_RESULT

        self.saved = ActionExecutionModelTest._save_execution(created)
        self.retrieved = ActionExecution.get_by_id(self.saved.id)
        self.assertEqual(self.saved.action, self.retrieved.action,
                         'Same action was not returned.')
Ejemplo n.º 2
0
    def setUp(self):

        self.executions = {}

        for name, execution in ACTIONEXECUTIONS.items():

            created = ActionExecutionDB()
            created.action = execution['action']
            created.status = execution['status']
            created.runner = execution['runner']
            created.liveaction = execution['liveaction']
            created.result = execution['result']

            saved = ActionExecutionModelTest._save_execution(created)
            retrieved = ActionExecution.get_by_id(saved.id)
            self.assertEqual(saved.action, retrieved.action,
                             'Same action was not returned.')

            self.executions[name] = retrieved
Ejemplo n.º 3
0
    def setUp(self):

        self.executions = {}

        for name, execution in ACTIONEXECUTIONS.items():

            created = ActionExecutionDB()
            created.action = execution['action']
            created.status = execution['status']
            created.runner = execution['runner']
            created.liveaction = execution['liveaction']
            created.result = execution['result']

            saved = ActionExecutionModelTest._save_execution(created)
            retrieved = ActionExecution.get_by_id(saved.id)
            self.assertEqual(saved.action, retrieved.action,
                             'Same action was not returned.')

            self.executions[name] = retrieved
Ejemplo n.º 4
0
    def test_format_secret_action_parameters_are_masked(self):
        formatter = ConsoleLogFormatter()

        mock_message = 'test message 1'

        mock_action_db = ActionDB()
        mock_action_db.name = 'test.action'
        mock_action_db.pack = 'testpack'
        mock_action_db.parameters = {
            'parameter1': {
                'type': 'string',
                'required': False
            },
            'parameter2': {
                'type': 'string',
                'required': False,
                'secret': True
            }
        }

        mock_action_execution_db = ActionExecutionDB()
        mock_action_execution_db.action = mock_action_db.to_serializable_dict()
        mock_action_execution_db.parameters = {
            'parameter1': 'value1',
            'parameter2': 'value2'
        }

        record = MockRecord()
        record.msg = mock_message

        # Add "extra" attributes
        record._action_execution_db = mock_action_execution_db

        expected_msg_part = "'parameters': {'parameter1': 'value1', 'parameter2': '********'}"

        message = formatter.format(record=record)
        self.assertTrue('test message 1' in message)
        self.assertTrue(expected_msg_part in message)