def test_iterReady_supports_updated_emails(self): # iterReady will also return pending MergeProposalUpdatedEmailJob. bmp = self.makeBranchMergeProposal( set_state=BranchMergeProposalStatus.NEEDS_REVIEW) self.completePendingJobs() old_merge_proposal = ( BranchMergeProposalNoPreviewDiffDelta.snapshot(bmp)) bmp.commit_message = 'new commit message' event = ObjectModifiedEvent( bmp, old_merge_proposal, [], bmp.registrant) merge_proposal_modified(bmp, event) [job] = self.job_source.iterReady() self.assertEqual(job.branch_merge_proposal, bmp) self.assertIsInstance(job, MergeProposalUpdatedEmailJob)
def notify_modified(proposal, func, *args, **kwargs): """Call func, then notify about the changes it made. :param proposal: the merge proposal to notify about. :param func: The callable that will modify the merge proposal. :param args: Additional arguments for the method. :param kwargs: Keyword arguments for the method. :return: The return value of the method. """ from lp.code.adapters.branch import BranchMergeProposalNoPreviewDiffDelta snapshot = BranchMergeProposalNoPreviewDiffDelta.snapshot(proposal) result = func(*args, **kwargs) notify(ObjectModifiedEvent(proposal, snapshot, [])) return result