本文整理汇总了Python中st2common.models.db.action.ActionDB.to_serializable_dict方法的典型用法代码示例。如果您正苦于以下问题:Python ActionDB.to_serializable_dict方法的具体用法?Python ActionDB.to_serializable_dict怎么用?Python ActionDB.to_serializable_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类st2common.models.db.action.ActionDB
的用法示例。
在下文中一共展示了ActionDB.to_serializable_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_format_secret_action_parameters_are_masked
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import to_serializable_dict [as 别名]
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)
示例2: test_format_secret_action_parameters_are_masked
# 需要导入模块: from st2common.models.db.action import ActionDB [as 别名]
# 或者: from st2common.models.db.action.ActionDB import to_serializable_dict [as 别名]
def test_format_secret_action_parameters_are_masked(self):
formatter = ConsoleLogFormatter()
mock_message = 'test message 1'
parameters = {
'parameter1': {
'type': 'string',
'required': False
},
'parameter2': {
'type': 'string',
'required': False,
'secret': True
}
}
mock_action_db = ActionDB(pack='testpack', name='test.action', parameters=parameters)
action = mock_action_db.to_serializable_dict()
parameters = {
'parameter1': 'value1',
'parameter2': 'value2'
}
mock_action_execution_db = ActionExecutionDB(action=action, parameters=parameters)
record = MockRecord()
record.msg = mock_message
# Add "extra" attributes
record._action_execution_db = mock_action_execution_db
expected_msg_part = (r"'parameters': {u?'parameter1': u?'value1', "
r"u?'parameter2': u?'\*\*\*\*\*\*\*\*'}")
message = formatter.format(record=record)
self.assertTrue('test message 1' in message)
self.assertRegexpMatches(message, expected_msg_part)