本文整理汇总了Python中lp.services.database.interfaces.IStore.makeDerived方法的典型用法代码示例。如果您正苦于以下问题:Python IStore.makeDerived方法的具体用法?Python IStore.makeDerived怎么用?Python IStore.makeDerived使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lp.services.database.interfaces.IStore
的用法示例。
在下文中一共展示了IStore.makeDerived方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import makeDerived [as 别名]
def get(ujob_id):
"""Return the named job database class.
:param ujob_id: A tuple of Job.id, module name, class name for the
class to retrieve.
Return derived job class.
"""
job_id, module_name, class_name = ujob_id
bc_module = __import__(module_name, fromlist=[class_name])
db_class = getattr(bc_module, class_name)
factory = getattr(db_class, "makeInstance", None)
if factory is not None:
return factory(job_id)
# This method can be called with two distinct types of Jobs:
# - Jobs that are backed by a DB table with a foreign key onto Job.
# - Jobs that have no backing, and are only represented by a row in
# the Job table, but the class name we are given is the abstract
# job class.
# If there is no __storm_table__, it is the second type, and we have
# to look it up via the Job table.
if getattr(db_class, "__storm_table__", None) is None:
db_job = IStore(Job).find(Job, Job.id == job_id).one()
# Job.makeDerived() would be a mess of circular imports, so it is
# cleaner to just return the bare Job wrapped in the class.
return db_class(db_job)
# Otherwise, we have the concrete DB class, so use its FK.
db_job = IStore(db_class).find(db_class, db_class.job == job_id).one()
if db_job is None:
return None
return db_job.makeDerived()
示例2: test_mergeProposalMergeDetected
# 需要导入模块: from lp.services.database.interfaces import IStore [as 别名]
# 或者: from lp.services.database.interfaces.IStore import makeDerived [as 别名]
def test_mergeProposalMergeDetected(self):
# A merge proposal that is merged has the proposal itself marked as
# merged, and the source branch lifecycle status set as merged.
product = self.factory.makeProduct()
proposal = self.factory.makeBranchMergeProposal(product=product)
product.development_focus.branch = proposal.target_branch
self.assertNotEqual(
BranchMergeProposalStatus.MERGED, proposal.queue_status)
self.assertNotEqual(
BranchLifecycleStatus.MERGED,
proposal.source_branch.lifecycle_status)
mergedetection.merge_detected(
logging.getLogger(),
proposal.source_branch, proposal.target_branch, proposal)
self.assertEqual(
BranchMergeProposalStatus.MERGED, proposal.queue_status)
self.assertEqual(
BranchLifecycleStatus.MERGED,
proposal.source_branch.lifecycle_status)
job = IStore(proposal).find(
BranchMergeProposalJob,
BranchMergeProposalJob.branch_merge_proposal == proposal,
BranchMergeProposalJob.job_type ==
BranchMergeProposalJobType.MERGE_PROPOSAL_UPDATED).one()
derived_job = job.makeDerived()
derived_job.run()
notifications = pop_notifications()
self.assertIn('Work in progress => Merged',
notifications[0].get_payload(decode=True))
self.assertEqual(
config.canonical.noreply_from_address, notifications[0]['From'])
recipients = set(msg['x-envelope-to'] for msg in notifications)
expected = set(
[proposal.source_branch.registrant.preferredemail.email,
proposal.target_branch.registrant.preferredemail.email])
self.assertEqual(expected, recipients)