• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python assertions.assert_call函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tests.assertions.assert_call函数的典型用法代码示例。如果您正苦于以下问题:Python assert_call函数的具体用法?Python assert_call怎么用?Python assert_call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assert_call函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_manual_start_with_run_time

    def test_manual_start_with_run_time(self):
        run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
        manual_runs = self.job_scheduler.manual_start(run_time)

        assert_call(self.job.build_new_runs, 0, run_time, manual=True)
        assert_length(manual_runs, 1)
        assert_length(self.manual_run.start.calls, 1)
开发者ID:ninsen,项目名称:Tron,代码行数:7,代码来源:job_test.py


示例2: test_start_no_startable_action_runs

    def test_start_no_startable_action_runs(self):
        self.job_run._do_start = Turtle()
        self.job_run.action_runs.has_startable_action_runs = False

        assert not self.job_run.start()
        assert_call(self.job_run.notify, 0, self.job_run.EVENT_START)
        assert_length(self.job_run.notify.calls, 1)
开发者ID:Bklyn,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py


示例3: test_handler_finished_with_cleanup

    def test_handler_finished_with_cleanup(self):
        self.job_run.action_runs.cleanup_action_run = Turtle(is_done=False)
        self.job_run.finalize = Turtle()

        self.job_run.handler(None, actionrun.ActionRun.STATE_SUCCEEDED)
        assert_length(self.job_run.finalize.calls, 0)
        assert_call(self.job_run.action_runs.cleanup_action_run.start, 0)
开发者ID:Bklyn,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py


示例4: test_start

    def test_start(self):
        self.job_run._do_start = Turtle()

        assert self.job_run.start()
        assert_call(self.job_run.notify, 0, self.job_run.EVENT_START)
        assert_call(self.job_run._do_start, 0)
        assert_length(self.job_run.notify.calls, 1)
开发者ID:Bklyn,项目名称:Tron,代码行数:7,代码来源:jobrun_test.py


示例5: test_get_runs_to_schedule_no_last_run

    def test_get_runs_to_schedule_no_last_run(self):
        self.job.runs.get_newest = lambda **kwargs: None

        job_runs = list(self.job_scheduler.get_runs_to_schedule())
        assert_length(self.job.scheduler.next_run_time.calls, 1)
        assert_length(job_runs, 1)
        # This should return a JobRun which has the job attached as an observer
        assert_call(job_runs[0].attach, 0, True, self.job)
开发者ID:ninsen,项目名称:Tron,代码行数:8,代码来源:job_test.py


示例6: test_handle_job_events_no_schedule_on_complete

 def test_handle_job_events_no_schedule_on_complete(self):
     self.job_scheduler.run_job = mock.Mock()
     self.job.scheduler.schedule_on_complete = False
     queued_job_run = mock.Mock()
     self.job.runs.get_first_queued = lambda: queued_job_run
     self.job_scheduler.handle_job_events(self.job, job.Job.NOTIFY_RUN_DONE)
     assert_call(self.reactor.callLater, 0, 0,
         self.job_scheduler.run_job, queued_job_run, run_queued=True)
开发者ID:Bklyn,项目名称:Tron,代码行数:8,代码来源:job_test.py


示例7: test_remove_old_runs

    def test_remove_old_runs(self):
        self.run_collection.run_limit = 1
        self.run_collection.remove_old_runs()

        assert_length(self.run_collection.runs, 1)
        assert_call(self.job_runs[-1].cleanup, 0)
        for job_run in self.run_collection.runs:
            assert_length(job_run.cancel.calls, 0)
开发者ID:pombredanne,项目名称:Tron,代码行数:8,代码来源:jobrun_test.py


示例8: test_get_runs_to_schedule_no_pending

    def test_get_runs_to_schedule_no_pending(self):
        job_runs = list(self.job_scheduler.get_runs_to_schedule())

        assert_call(self.job.runs.get_newest, 0, include_manual=False)
        assert_length(self.job.scheduler.next_run_time.calls, 1)
        assert_length(job_runs, 1)
        # This should return a JobRun which has the job attached as an observer
        assert_call(job_runs[0].attach, 0, True, self.job)
开发者ID:ninsen,项目名称:Tron,代码行数:8,代码来源:job_test.py


示例9: test_restore_job_state

 def test_restore_job_state(self):
     run_collection = mocks.MockJobRunCollection(get_scheduled=lambda: ['a'])
     self.job_scheduler.job = Turtle(runs=run_collection)
     self.job_scheduler._set_callback = Turtle()
     state_data = 'state_data_token'
     self.job_scheduler.restore_state(state_data)
     assert_call(self.job_scheduler.job.restore_state, 0, state_data)
     assert_length(self.job_scheduler._set_callback.calls, 1)
     assert_call(self.job_scheduler._set_callback, 0, 'a')
开发者ID:ContextLogic,项目名称:Tron,代码行数:9,代码来源:job_test.py


示例10: test_reconfigure

    def test_reconfigure(self):
        self.mcp._load_config = Turtle()
        self.mcp.state_manager = mock.Mock()
        cm = mocks.MockContextManager()
        self.mcp.state_manager.disabled = mock.Mock(return_value=cm)

        self.mcp.reconfigure()
        assert_call(self.mcp._load_config, 0, reconfigure=True)
        self.mcp.state_manager.disabled.assert_called_with()
开发者ID:Bklyn,项目名称:Tron,代码行数:9,代码来源:mcp_test.py


示例11: test_set_action_runs

 def test_set_action_runs(self):
     self.job_run._action_runs = None
     action_runs = [Turtle(), Turtle()]
     run_collection = Turtle(action_runs_with_cleanup=action_runs)
     self.job_run._set_action_runs(run_collection)
     assert_length(self.job_run.watch.calls, 2)
     for i in xrange(2):
         assert_call(self.job_run.watch, i, action_runs[i])
     assert_equal(self.job_run.action_runs, run_collection)
     assert self.job_run.action_runs_proxy
开发者ID:Bklyn,项目名称:Tron,代码行数:10,代码来源:jobrun_test.py


示例12: test_cleanup

    def test_cleanup(self):
        self.job_run.clear_observers = Turtle()
        self.job_run.output_path = Turtle()
        self.job_run.cleanup()

        assert_call(self.job_run.clear_observers, 0)
        assert_call(self.job_run.output_path.delete, 0)
        assert not self.job_run.node
        assert not self.job_run.action_graph
        assert not self.job_run.action_runs
开发者ID:Bklyn,项目名称:Tron,代码行数:10,代码来源:jobrun_test.py


示例13: test_handler_with_startable

    def test_handler_with_startable(self):
        self.job_run.action_runs.get_startable_action_runs = lambda: True
        startable_run = Turtle()
        self.job_run.action_runs.get_startable_action_runs = lambda: [startable_run]
        self.job_run.finalize = Turtle()

        self.job_run.handler(None, actionrun.ActionRun.STATE_SUCCEEDED)
        assert_call(self.job_run.notify, 0, self.job_run.NOTIFY_STATE_CHANGED)
        assert_call(startable_run.start, 0)
        assert_length(self.job_run.finalize.calls, 0)
开发者ID:Bklyn,项目名称:Tron,代码行数:10,代码来源:jobrun_test.py


示例14: test_restore_state_partial

    def test_restore_state_partial(self):
        def restore(jobs, services):
            return {'1': 'thing'}, {'2': 'thing'}
        self.mcp.state_watcher = Turtle(restore=restore)
        self.mcp.restore_state()

        assert_call(self.mcp.jobs['1'].restore_job_state, 0, 'thing')
        assert_length(self.mcp.jobs['2'].restore_job_state.calls, 0)
        assert_length(self.mcp.services['1'].restore_service_state.calls, 0)
        assert_call(self.mcp.services['2'].restore_service_state, 0, 'thing')
开发者ID:strategist922,项目名称:Tron,代码行数:10,代码来源:mcp_test.py


示例15: test_restore_state

 def test_restore_state(self):
     def restore(jobs, services):
         state_data = {'1': 'things', '2': 'things'}
         return state_data, state_data
     self.mcp.state_watcher = Turtle(restore=restore)
     self.mcp.restore_state()
     for job in self.mcp.jobs.values():
         assert_call(job.restore_job_state, 0, 'things')
     for service in self.mcp.services.values():
         assert_call(service.restore_service_state, 0, 'things')
开发者ID:strategist922,项目名称:Tron,代码行数:10,代码来源:mcp_test.py


示例16: test_handler_with_startable

    def test_handler_with_startable(self):
        startable_run = mock.create_autospec(actionrun.ActionRun)
        self.job_run.action_runs.get_startable_action_runs = lambda: [startable_run]
        autospec_method(self.job_run.finalize)
        self.action_run.is_broken = False

        self.job_run.handler(self.action_run, mock.Mock())
        assert_call(self.job_run.notify, 0, self.job_run.NOTIFY_STATE_CHANGED)
        startable_run.start.assert_called_with()
        assert not self.job_run.finalize.mock_calls
开发者ID:strategist922,项目名称:Tron,代码行数:10,代码来源:jobrun_test.py


示例17: test_build_new_runs_manual

    def test_build_new_runs_manual(self):
        run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
        runs = list(self.job.build_new_runs(run_time, manual=True))

        self.job.node_pool.next.assert_called_with()
        node = self.job.node_pool.next.return_value
        assert_length(runs, 1)
        assert_call(self.job.runs.build_new_run,
                0, self.job, run_time, node, manual=True)
        self.job.watch.assert_called_with(runs[0])
开发者ID:ContextLogic,项目名称:Tron,代码行数:10,代码来源:job_test.py


示例18: test_build_new_runs_all_nodes

    def test_build_new_runs_all_nodes(self):
        self.job.all_nodes = True
        run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
        runs = list(self.job.build_new_runs(run_time))

        assert_length(runs, 2)
        for i in xrange(len(runs)):
            node = self.job.node_pool.nodes[i]
            assert_call(self.job.runs.build_new_run,
                    i, self.job, run_time, node, manual=False)
            assert_call(self.job.watch, 1, runs[1])
开发者ID:ninsen,项目名称:Tron,代码行数:11,代码来源:job_test.py


示例19: test_build_new_run_manual

 def test_build_new_run_manual(self):
     self.run_collection.remove_old_runs = Turtle()
     run_time = datetime.datetime(2012, 3, 14, 15, 9, 26)
     job = Turtle(name="thejob")
     job.action_graph.action_map = {}
     node = MockNode("thenode")
     job_run = self.run_collection.build_new_run(job, run_time, node, True)
     assert_in(job_run, self.run_collection.runs)
     assert_call(self.run_collection.remove_old_runs, 0)
     assert_equal(job_run.run_num, 5)
     assert job_run.manual
开发者ID:Bklyn,项目名称:Tron,代码行数:11,代码来源:jobrun_test.py


示例20: test_restore_state

    def test_restore_state(self):
        run_data = ['one', 'two']
        job_runs = [Turtle(), Turtle()]
        self.job.runs.restore_state = lambda r, a, o, c, n: job_runs
        state_data = {'enabled': False, 'runs': run_data}

        self.job.restore_state(state_data)

        assert not self.job.enabled
        for i in xrange(len(job_runs)):
            assert_call(self.job.watch, i, job_runs[i])
        assert_call(self.job.notify, 0, self.job.EVENT_STATE_RESTORED)
开发者ID:ninsen,项目名称:Tron,代码行数:12,代码来源:job_test.py



注:本文中的tests.assertions.assert_call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python assertions.assert_length函数代码示例发布时间:2022-05-27
下一篇:
Python unittest.main函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap