本文整理汇总了Python中app.master.build.Build._all_subjobs_by_id[subjob_id]方法的典型用法代码示例。如果您正苦于以下问题:Python Build._all_subjobs_by_id[subjob_id]方法的具体用法?Python Build._all_subjobs_by_id[subjob_id]怎么用?Python Build._all_subjobs_by_id[subjob_id]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app.master.build.Build
的用法示例。
在下文中一共展示了Build._all_subjobs_by_id[subjob_id]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_subjobs_with_pagination_request
# 需要导入模块: from app.master.build import Build [as 别名]
# 或者: from app.master.build.Build import _all_subjobs_by_id[subjob_id] [as 别名]
def test_subjobs_with_pagination_request(
self,
offset: Optional[int],
limit: Optional[int],
expected_first_subjob_id: int,
expected_last_subjob_id: int,
):
build = Build(BuildRequest({}))
# Create 20 mock subjobs with ids 1 to 20
for subjob_id in range(1, self._NUM_SUBJOBS + 1):
subjob_mock = Mock(spec=Subjob)
subjob_mock.subjob_id = subjob_id
build._all_subjobs_by_id[subjob_id] = subjob_mock
requested_subjobs = build.get_subjobs(offset, limit)
id_of_first_subjob = requested_subjobs[0].subjob_id if len(requested_subjobs) else None
id_of_last_subjob = requested_subjobs[-1].subjob_id if len(requested_subjobs) else None
num_subjobs = len(requested_subjobs)
self.assertEqual(id_of_first_subjob, expected_first_subjob_id, 'Received the wrong first subjob from request')
self.assertEqual(id_of_last_subjob, expected_last_subjob_id, 'Received the wrong last subjob from request')
if offset is not None and limit is not None:
self.assertLessEqual(num_subjobs, self._PAGINATION_MAX_LIMIT, 'Received too many subjobs from request')