本文整理汇总了Python中tests.testingutils.autospec_method函数的典型用法代码示例。如果您正苦于以下问题:Python autospec_method函数的具体用法?Python autospec_method怎么用?Python autospec_method使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了autospec_method函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_do_start_some_failed
def test_do_start_some_failed(self):
returns = [True, None]
autospec_method(self.job_run._start_action_runs, return_value=returns)
assert self.job_run._do_start()
assert_equal(self.job_run.event.ok.call_count, 1)
self.job_run.event.ok.assert_called_with('started')
示例2: test_cancel_pending
def test_cancel_pending(self):
pending_runs = [mock.Mock() for _ in xrange(2)]
autospec_method(self.run_collection.get_pending,
return_value=pending_runs)
self.run_collection.cancel_pending()
for pending_run in pending_runs:
pending_run.cancel.assert_called_with()
示例3: test_load_config
def test_load_config(self):
autospec_method(self.mcp.apply_config)
self.mcp.config = mock.create_autospec(manager.ConfigManager)
self.mcp._load_config()
self.mcp.state_watcher.disabled.assert_called_with()
self.mcp.apply_config.assert_called_with(
self.mcp.config.load.return_value, reconfigure=False)
示例4: test_start_no_startable_action_runs
def test_start_no_startable_action_runs(self):
autospec_method(self.job_run._do_start)
self.job_run.action_runs.has_startable_action_runs = False
assert not self.job_run.start()
self.job_run.event.info.assert_called_with('start')
assert not self.job_run.event.ok.mock_calls
示例5: test_handle_action_exit_up
def test_handle_action_exit_up(self):
self.task.action = mock.create_autospec(ActionCommand)
self.task.action.is_failed = False
autospec_method(self.task.queue)
self.task._handle_action_exit()
self.task.notify.assert_called_with(self.task.NOTIFY_UP)
self.task.queue.assert_called_with()
示例6: setup_task
def setup_task(self):
self.node = mock.create_autospec(node.Node)
self.pid_filename = '/tmp/filename'
self.task = serviceinstance.ServiceInstanceStopTask(
'id', self.node, self.pid_filename)
autospec_method(self.task.watch)
autospec_method(self.task.notify)
示例7: test_read_config_no_header
def test_read_config_no_header(self):
name = 'some_name'
autospec_method(self.controller._get_config_content)
autospec_method(self.controller.render_template)
resp = self.controller.read_config(name, add_header=False)
assert not self.controller.render_template.called
assert_equal(resp['config'], self.controller._get_config_content.return_value)
示例8: test_validate_fragment
def test_validate_fragment(self):
autospec_method(self.manager.load)
name = 'the_name'
self.manager.validate_fragment(name, self.content)
container = self.manager.load.return_value
container.add.assert_called_with(name, self.content)
container.validate.assert_called_with()
示例9: test_handle_instance_state_change_starting
def test_handle_instance_state_change_starting(self):
autospec_method(self.service.notify)
autospec_method(self.service.record_events)
instance_event = serviceinstance.ServiceInstance.STATE_STARTING
self.service._handle_instance_state_change(mock.Mock(), instance_event)
assert not self.service.notify.mock_calls
assert not self.service.record_events.mock_calls
示例10: test_stop
def test_stop(self):
autospec_method(self.node._fail_run)
action_command = mock.create_autospec(actioncommand.ActionCommand,
id=mock.Mock())
self.node.run_states[action_command.id] = mock.Mock()
self.node.stop(action_command)
assert_equal(self.node._fail_run.call_count, 1)
示例11: test_handle_action_unknown
def test_handle_action_unknown(self):
self.task.action = mock.create_autospec(ActionCommand)
self.task.action.is_unknown = True
autospec_method(self.task.queue)
self.task._handle_action_exit()
self.task.notify.assert_called_with(self.task.NOTIFY_FAILED)
assert_equal(self.task.queue.call_count, 1)
示例12: test_handle_instance_state_change_failed
def test_handle_instance_state_change_failed(self):
autospec_method(self.service.notify)
autospec_method(self.service.record_events)
instance_event = serviceinstance.ServiceInstance.STATE_FAILED
self.service._handle_instance_state_change(mock.Mock(), instance_event)
assert not self.service.notify.mock_calls
self.service.record_events.assert_called_with()
示例13: test_handler_action_run_skipped
def test_handler_action_run_skipped(self):
self.action_run.is_broken = False
self.action_run.is_skipped = True
self.job_run.action_runs.is_scheduled = True
autospec_method(self.job_run._start_action_runs)
self.job_run.handler(self.action_run, mock.Mock())
assert not self.job_run._start_action_runs.mock_calls
示例14: test_handler_finished_with_cleanup_done
def test_handler_finished_with_cleanup_done(self):
self.job_run.action_runs.is_active = False
self.job_run.action_runs.is_scheduled = False
self.job_run.action_runs.cleanup_action_run = mock.Mock(is_done=True)
autospec_method(self.job_run.finalize)
self.job_run.handler(self.action_run, mock.Mock())
self.job_run.finalize.assert_called_with()
示例15: test_handler_not_end_state_event
def test_handler_not_end_state_event(self):
autospec_method(self.job_run.finalize)
autospec_method(self.job_run._start_action_runs)
self.action_run.is_done = False
self.job_run.handler(self.action_run, mock.Mock())
assert not self.job_run.finalize.mock_calls
assert not self.job_run._start_action_runs.mock_calls