本文整理汇总了Python中tests.assertions.assert_length函数的典型用法代码示例。如果您正苦于以下问题:Python assert_length函数的具体用法?Python assert_length怎么用?Python assert_length使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assert_length函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例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)
示例3: 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)
self.job.build_new_runs.assert_called_with(run_time, manual=True)
assert_length(manual_runs, 1)
self.manual_run.start.assert_called_once_with()
示例4: 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)
示例5: test_from_state_node_no_longer_exists
def test_from_state_node_no_longer_exists(self):
run = jobrun.JobRun.from_state(self.state_data, self.action_graph,
self.output_path, self.context, self.node_pool)
assert_length(run.action_runs.run_map, 1)
assert_equal(run.job_name, 'thejobname')
assert_equal(run.run_time, self.run_time)
assert_equal(run.node, self.node_pool)
示例6: test_cancel_schedules_a_new_run
def test_cancel_schedules_a_new_run(self):
config = BASIC_CONFIG + dedent("""
jobs:
- name: "a_job"
node: local
schedule: "daily 05:00:00"
actions:
- name: "first_action"
command: "echo OK"
""")
client = self.sandbox.client
self.sandbox.save_config(config)
self.sandbox.trond()
job_url = client.get_url('MASTER.a_job')
self.sandbox.tronctl(['cancel', 'MASTER.a_job.0'])
def wait_on_cancel():
return len(client.job(job_url)['runs']) == 2
sandbox.wait_on_sandbox(wait_on_cancel)
job_runs = client.job(job_url)['runs']
assert_length(job_runs, 2)
run_states = [run['state'] for run in job_runs]
assert_equal(run_states, ['SCHE', 'CANC'])
示例7: test_build_action_run_collection
def test_build_action_run_collection(self):
collection = ActionRunFactory.build_action_run_collection(self.job_run)
assert_equal(collection.action_graph, self.action_graph)
assert_in('act1', collection.run_map)
assert_in('act2', collection.run_map)
assert_length(collection.run_map, 2)
assert_equal(collection.run_map['act1'].action_name, 'act1')
示例8: test_handler_not_done
def test_handler_not_done(self):
self.job_run.action_runs.is_active = True
self.job_run._start_action_runs = lambda: []
self.job_run.finalize = Turtle()
self.job_run.handler(None, actionrun.ActionRun.STATE_SUCCEEDED)
assert_length(self.job_run.finalize.calls, 0)
示例9: test_handler_no_queued
def test_handler_no_queued(self):
self.job_scheduler.run_job = Turtle()
def get_queued(state):
if state == ActionRun.STATE_QUEUED:
return []
self.job.runs.get_runs_by_state = get_queued
self.job_scheduler.handler(self.job, job.Job.NOTIFY_RUN_DONE)
assert_length(self.job_scheduler.run_job.calls, 0)
示例10: 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)
示例11: 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)
示例12: test_get_active
def test_get_active(self):
starting_run = self._mock_run(
run_num=self.run_collection.next_run_num(),
state=actionrun.ActionRun.STATE_STARTING)
self.run_collection.runs.appendleft(starting_run)
active = list(self.run_collection.get_active())
assert_length(active, 2)
assert_equal(active, [starting_run, self.job_runs[1]])
示例13: 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)
示例14: test_run_job_schedule_on_complete
def test_run_job_schedule_on_complete(self):
self.job_scheduler.schedule = Turtle()
self.scheduler.schedule_on_complete = True
self.job.runs.get_active = lambda s: []
job_run = Turtle(is_cancelled=False)
self.job_scheduler.run_job(job_run)
assert_length(job_run.start.calls, 1)
assert_length(self.job_scheduler.schedule.calls, 0)
示例15: test_get_runs_to_schedule_no_last_run
def test_get_runs_to_schedule_no_last_run(self):
self.job.runs.get_newest.return_value = None
job_runs = list(self.job_scheduler.get_runs_to_schedule(False))
self.job.scheduler.next_run_time.assert_called_once_with(None)
assert_length(job_runs, 1)
# This should return a JobRun which has the job attached as an observer
job_runs[0].attach.assert_any_call(True, self.job)