~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/tests/test_structuralsubscription.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-17 14:05:32 UTC
  • mfrom: (13023.5.5 bug-777783)
  • Revision ID: launchpad@pqm.canonical.com-20110517140532-ir14h0t3r5v8sjmr
[r=adeuring][bug=777783] Subscriptions to Project Groups will now
        show up on the +subscriptions page for each group's sub-projects.

Show diffs side-by-side

added added

removed removed

Lines of Context:
516
516
             (dist_sourcepackage_bugtask, dist_sourcepackage),
517
517
             (dist_sourcepackage_bugtask, distribution))))
518
518
 
 
519
    def test_product_with_project_group(self):
 
520
        # get_structural_subscription_targets() will yield both a
 
521
        # product and its parent project group if it has one.
 
522
        project = self.factory.makeProject()
 
523
        product = self.factory.makeProduct(
 
524
            project=project, owner=project.owner)
 
525
        subscriber = self.factory.makePerson()
 
526
        with person_logged_in(subscriber):
 
527
            self_sub = project.addBugSubscription(subscriber, subscriber)
 
528
        # This is a sanity check.
 
529
        self.assertEqual(project, product.parent_subscription_target)
 
530
        bug = self.factory.makeBug(product=product)
 
531
        result = get_structural_subscription_targets(bug.bugtasks)
 
532
        self.assertEqual(
 
533
            set([(bug.bugtasks[0], product), (bug.bugtasks[0], project)]),
 
534
            set(result))
519
535
 
520
536
class TestGetStructuralSubscriptionsForBug(TestCaseWithFactory):
521
537
 
600
616
        subscriptions = self.getSubscriptions(self.subscriber)
601
617
        self.assertEqual(set([self_sub, team_sub]), set(subscriptions))
602
618
 
 
619
    def test_subscriptions_from_parent(self):
 
620
        # get_structural_subscriptions_for_bug() will return any
 
621
        # structural subscriptions from the parents of the targets of
 
622
        # that bug.
 
623
        project = self.factory.makeProject()
 
624
        product = self.factory.makeProduct(
 
625
            project=project, owner=project.owner)
 
626
        subscriber = self.factory.makePerson()
 
627
        self_sub = project.addBugSubscription(subscriber, subscriber)
 
628
        # This is a sanity check.
 
629
        self.assertEqual(project, product.parent_subscription_target)
 
630
        bug = self.factory.makeBug(product=product)
 
631
        subscriptions = get_structural_subscriptions_for_bug(
 
632
            bug, subscriber)
 
633
        self.assertEqual(set([self_sub]), set(subscriptions))
 
634
 
603
635
 
604
636
class TestGetStructuralSubscribers(TestCaseWithFactory):
605
637