本文整理汇总了Python中mock.mock.MagicMock.set_helpers方法的典型用法代码示例。如果您正苦于以下问题:Python MagicMock.set_helpers方法的具体用法?Python MagicMock.set_helpers怎么用?Python MagicMock.set_helpers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mock.mock.MagicMock
的用法示例。
在下文中一共展示了MagicMock.set_helpers方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_start
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import set_helpers [as 别名]
def test_start(self):
execution_commands = [
{
'clusterName': 'cluster',
'hostName': 'host',
'alertDefinition': {
'name': 'alert1'
}
}
]
scheduler = AlertSchedulerHandler(TEST_PATH, TEST_PATH, TEST_PATH, TEST_PATH, 5, None, None, None)
alert_mock = MagicMock()
alert_mock.interval = Mock(return_value=5)
alert_mock.collect = Mock()
alert_mock.set_helpers = Mock()
scheduler.schedule_definition = MagicMock()
scheduler._AlertSchedulerHandler__scheduler = MagicMock()
scheduler._AlertSchedulerHandler__scheduler.running = False
scheduler._AlertSchedulerHandler__scheduler.start = Mock()
scheduler._AlertSchedulerHandler__json_to_callable = Mock(return_value=alert_mock)
scheduler._AlertSchedulerHandler__config_maps = {
'cluster': {}
}
scheduler.start()
self.assertTrue(scheduler._AlertSchedulerHandler__scheduler.start.called)
scheduler.schedule_definition.assert_called_with(alert_mock)
示例2: test_execute_alert
# 需要导入模块: from mock.mock import MagicMock [as 别名]
# 或者: from mock.mock.MagicMock import set_helpers [as 别名]
def test_execute_alert(self):
execution_commands = [
{
'clusterName': 'cluster',
'hostName': 'host',
'alertDefinition': {
'name': 'alert1'
}
}
]
scheduler = AlertSchedulerHandler(TEST_PATH, TEST_PATH, TEST_PATH, TEST_PATH, 5, None, None, None)
alert_mock = MagicMock()
alert_mock.collect = Mock()
alert_mock.set_helpers = Mock()
scheduler._AlertSchedulerHandler__json_to_callable = Mock(return_value=alert_mock)
scheduler._AlertSchedulerHandler__config_maps = {
'cluster': {}
}
scheduler.execute_alert(execution_commands)
scheduler._AlertSchedulerHandler__json_to_callable.assert_called_with('cluster', 'host', {'name': 'alert1'})
self.assertTrue(alert_mock.collect.called)