~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/model/tests/test_bugtask.py

[r=stevenk][bug=80902][incr] transitionToTarget now calls
 validate_target,
 and only unsets the milestone once the transition is verified.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1744
1744
        sp2 = self.factory.makeSourcePackage(distroseries=ds2)
1745
1745
        self.assertTransitionForbidden(sp1, sp2)
1746
1746
 
 
1747
    def test_transition_to_same_is_noop(self):
 
1748
        p = self.factory.makeProduct()
 
1749
        self.assertTransitionWorks(p, p)
 
1750
 
 
1751
    def test_validate_target_is_called(self):
 
1752
        p = self.factory.makeProduct()
 
1753
        task1 = self.factory.makeBugTask(target=p)
 
1754
        task2 = self.factory.makeBugTask(
 
1755
            bug=task1.bug, target=self.factory.makeProduct())
 
1756
        with person_logged_in(task2.owner):
 
1757
            self.assertRaisesWithContent(
 
1758
                IllegalTarget,
 
1759
                "A fix for this bug has already been requested for %s"
 
1760
                % p.displayname, task2.transitionToTarget, p)
 
1761
 
 
1762
    def test_milestone_preserved_if_transition_rejected(self):
 
1763
        series = self.factory.makeProductSeries()
 
1764
        task = self.factory.makeBugTask(target=series.product)
 
1765
        milestone = self.factory.makeMilestone(product=series.product)
 
1766
        with person_logged_in(task.owner):
 
1767
            task.milestone = milestone
 
1768
            self.assertRaises(
 
1769
                IllegalTarget,
 
1770
                task.transitionToTarget, self.factory.makeSourcePackage())
 
1771
            self.assertEqual(milestone, task.milestone)
 
1772
 
1747
1773
 
1748
1774
class TestBugTargetKeys(TestCaseWithFactory):
1749
1775
    """Tests for bug_target_to_key and bug_target_from_key."""