本文整理汇总了Python中cms.grading.Job.JobGroup.export_to_dict方法的典型用法代码示例。如果您正苦于以下问题:Python JobGroup.export_to_dict方法的具体用法?Python JobGroup.export_to_dict怎么用?Python JobGroup.export_to_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cms.grading.Job.JobGroup
的用法示例。
在下文中一共展示了JobGroup.export_to_dict方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_execute_job_failure_releases_lock
# 需要导入模块: from cms.grading.Job import JobGroup [as 别名]
# 或者: from cms.grading.Job.JobGroup import export_to_dict [as 别名]
def test_execute_job_failure_releases_lock(self):
"""After a failure, the worker should be able to accept another job.
"""
n_jobs_a = 1
jobs_a, calls_a = TestWorker.new_jobs(n_jobs_a)
task_type_a = FakeTaskType([Exception()])
cms.service.Worker.get_task_type = Mock(return_value=task_type_a)
with self.assertRaises(JobException):
job_group = JobGroup([jobs_a[0]])
JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict()))
cms.service.Worker.get_task_type.assert_has_calls(calls_a)
self.assertEquals(task_type_a.call_count, n_jobs_a)
n_jobs_b = 3
jobs_b, calls_b = TestWorker.new_jobs(n_jobs_b)
task_type_b = FakeTaskType([True] * n_jobs_b)
cms.service.Worker.get_task_type = Mock(return_value=task_type_b)
for job in jobs_b:
job_group = JobGroup([job])
JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict()))
cms.service.Worker.get_task_type.assert_has_calls(calls_b)
self.assertEquals(task_type_b.call_count, n_jobs_b)
示例2: test_execute_job_subsequent_success
# 需要导入模块: from cms.grading.Job import JobGroup [as 别名]
# 或者: from cms.grading.Job.JobGroup import export_to_dict [as 别名]
def test_execute_job_subsequent_success(self):
"""Executes three successful jobs, then four others.
"""
n_jobs_a = 3
jobs_a, calls_a = TestWorker.new_jobs(n_jobs_a, prefix="a")
task_type_a = FakeTaskType([True] * n_jobs_a)
cms.service.Worker.get_task_type = Mock(return_value=task_type_a)
for job in jobs_a:
job_group = JobGroup([job])
JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict()))
cms.service.Worker.get_task_type.assert_has_calls(calls_a)
self.assertEquals(task_type_a.call_count, n_jobs_a)
n_jobs_b = 4
jobs_b, calls_b = TestWorker.new_jobs(n_jobs_b, prefix="b")
task_type_b = FakeTaskType([True] * n_jobs_b)
cms.service.Worker.get_task_type = Mock(return_value=task_type_b)
for job in jobs_b:
job_group = JobGroup([job])
JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict()))
cms.service.Worker.get_task_type.assert_has_calls(calls_b)
self.assertEquals(task_type_b.call_count, n_jobs_b)
示例3: test_execute_job_subsequent_locked
# 需要导入模块: from cms.grading.Job import JobGroup [as 别名]
# 或者: from cms.grading.Job.JobGroup import export_to_dict [as 别名]
def test_execute_job_subsequent_locked(self):
"""Executes a long job, then another one that should fail
because of the lock.
"""
# Because of how gevent works, the interval here can be very small.
task_type = FakeTaskType([0.01])
cms.service.Worker.get_task_type = Mock(return_value=task_type)
jobs_a, calls_a = TestWorker.new_jobs(1, prefix="a")
jobs_b, calls_b = TestWorker.new_jobs(1, prefix="b")
def first_call():
job_group = JobGroup([jobs_a[0]])
JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict()))
first_greenlet = gevent.spawn(first_call)
gevent.sleep(0) # To ensure we call jobgroup_a first.
with self.assertRaises(JobException):
job_group = JobGroup([jobs_b[0]])
JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict()))
first_greenlet.get()
self.assertNotIn(calls_b[0],
cms.service.Worker.get_task_type.mock_calls)
cms.service.Worker.get_task_type.assert_has_calls(calls_a)
示例4: test_execute_job_tasktype_raise
# 需要导入模块: from cms.grading.Job import JobGroup [as 别名]
# 或者: from cms.grading.Job.JobGroup import export_to_dict [as 别名]
def test_execute_job_tasktype_raise(self):
"""Executes two jobs raising exceptions.
"""
n_jobs = 2
jobs, unused_calls = TestWorker.new_jobs(n_jobs)
task_type = FakeTaskType([Exception(), Exception()])
cms.service.Worker.get_task_type = Mock(return_value=task_type)
for job in jobs:
with self.assertRaises(JobException):
job_group = JobGroup([job])
JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict()))
self.assertEquals(cms.service.Worker.get_task_type.call_count, n_jobs)
self.assertEquals(task_type.call_count, n_jobs)
示例5: test_execute_job_success
# 需要导入模块: from cms.grading.Job import JobGroup [as 别名]
# 或者: from cms.grading.Job.JobGroup import export_to_dict [as 别名]
def test_execute_job_success(self):
"""Executes three successful jobs.
"""
n_jobs = 3
jobs, calls = TestWorker.new_jobs(n_jobs)
task_type = FakeTaskType([True] * n_jobs)
cms.service.Worker.get_task_type = Mock(return_value=task_type)
for job in jobs:
job_group = JobGroup([job])
ret_job_group = JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict()))
self.assertTrue(ret_job_group.jobs[0].success)
cms.service.Worker.get_task_type.assert_has_calls(calls)
self.assertEquals(task_type.call_count, n_jobs)
示例6: test_execute_job_failure
# 需要导入模块: from cms.grading.Job import JobGroup [as 别名]
# 或者: from cms.grading.Job.JobGroup import export_to_dict [as 别名]
def test_execute_job_failure(self):
"""Executes two unsuccessful jobs.
"""
n_jobs = 2
jobs, unused_calls = TestWorker.new_jobs(n_jobs)
task_type = FakeTaskType([False] * n_jobs)
cms.service.Worker.get_task_type = Mock(return_value=task_type)
results = []
for job in jobs:
job_group = JobGroup([job])
results.append(JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict())))
for job_group in results:
for job in job_group.jobs:
self.assertFalse(job.success)
self.assertEquals(cms.service.Worker.get_task_type.call_count, n_jobs)
self.assertEquals(task_type.call_count, n_jobs)
示例7: first_call
# 需要导入模块: from cms.grading.Job import JobGroup [as 别名]
# 或者: from cms.grading.Job.JobGroup import export_to_dict [as 别名]
def first_call():
job_group = JobGroup([jobs_a[0]])
JobGroup.import_from_dict(
self.service.execute_job_group(job_group.export_to_dict()))