Example #1
0
 def test_mergeOfTwoBranches_target_not_dev_focus(self):
     # The target branch must be the development focus in order for the
     # lifecycle status of the source branch to be updated to merged.
     source = self.factory.makeProductBranch()
     target = self.factory.makeProductBranch()
     mergedetection.merge_detected(logging.getLogger(), source, target)
     self.assertNotEqual(
         BranchLifecycleStatus.MERGED, source.lifecycle_status)
 def test_mergeOfTwoBranches_target_dev_focus(self):
     # If the target branch is the development focus branch of the product,
     # then the source branch gets its lifecycle status set to merged.
     product = self.factory.makeProduct()
     source = self.factory.makeProductBranch(product=product)
     target = self.factory.makeProductBranch(product=product)
     product.development_focus.branch = target
     mergedetection.merge_detected(logging.getLogger(), source, target)
     self.assertEqual(BranchLifecycleStatus.MERGED, source.lifecycle_status)
 def test_mergeOfTwoBranches_target_dev_focus(self):
     # If the target branch is the development focus branch of the product,
     # then the source branch gets its lifecycle status set to merged.
     product = self.factory.makeProduct()
     source = self.factory.makeProductBranch(product=product)
     target = self.factory.makeProductBranch(product=product)
     product.development_focus.branch = target
     mergedetection.merge_detected(logging.getLogger(), source, target)
     self.assertEqual(
         BranchLifecycleStatus.MERGED, source.lifecycle_status)
Example #4
0
    def test_mergeOfTwoBranches_source_series_branch(self):
        # If the source branch is associated with a series, its lifecycle
        # status is not updated.
        product = self.factory.makeProduct()
        source = self.factory.makeProductBranch(product=product)
        target = self.factory.makeProductBranch(product=product)
        product.development_focus.branch = target
        series = product.newSeries(product.owner, 'new', '')
        series.branch = source

        mergedetection.merge_detected(logging.getLogger(), source, target)
        self.assertNotEqual(
            BranchLifecycleStatus.MERGED, source.lifecycle_status)
 def test_mergeProposalMergeDetected_not_series(self):
     # If the target branch is not a series branch, then the merge proposal
     # is still marked as merged, but the lifecycle status of the source
     # branch is not updated.
     proposal = self.factory.makeBranchMergeProposal()
     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.assertNotEqual(BranchLifecycleStatus.MERGED,
                         proposal.source_branch.lifecycle_status)
 def test_mergeProposalMergeDetected_not_series(self):
     # If the target branch is not a series branch, then the merge proposal
     # is still marked as merged, but the lifecycle status of the source
     # branch is not updated.
     proposal = self.factory.makeBranchMergeProposal()
     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.assertNotEqual(
         BranchLifecycleStatus.MERGED,
         proposal.source_branch.lifecycle_status)
Example #7
0
 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)