~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

Merge db-devel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
154
154
        self.initial_filter = self.subscription.bug_filters[0]
155
155
 
156
156
    def assertSubscribers(
157
 
        self, expected_subscribers, level=BugNotificationLevel.NOTHING):
 
157
        self, expected_subscribers, level=BugNotificationLevel.LIFECYCLE):
158
158
        observed_subscribers = list(
159
159
            get_structural_subscribers(self.bugtask, None, level))
160
160
        self.assertEqual(expected_subscribers, observed_subscribers)
208
208
        self.initial_filter.bug_notification_level = (
209
209
            BugNotificationLevel.METADATA)
210
210
 
211
 
        # The subscription is found when looking for NOTHING or above.
 
211
        # The subscription is found when looking for LIFECYCLE or above.
212
212
        self.assertSubscribers(
213
 
            [self.ordinary_subscriber], BugNotificationLevel.NOTHING)
 
213
            [self.ordinary_subscriber], BugNotificationLevel.LIFECYCLE)
214
214
        # The subscription is found when looking for METADATA or above.
215
215
        self.assertSubscribers(
216
216
            [self.ordinary_subscriber], BugNotificationLevel.METADATA)
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