def test_getStructuralSubscribers_no_subscribers(self):
     # If there are no subscribers for any of the bug's targets then no
     # subscribers will be returned by get_structural_subscribers().
     product, bug = self.make_product_with_bug()
     subscribers = get_structural_subscribers(bug, None, None, None)
     self.assertIsInstance(subscribers, RESULT_SETS)
     self.assertEqual([], list(subscribers))
Esempio n. 2
0
 def test_getStructuralSubscribers_no_subscribers(self):
     # If there are no subscribers for any of the bug's targets then no
     # subscribers will be returned by get_structural_subscribers().
     product, bug = self.make_product_with_bug()
     subscribers = get_structural_subscribers(bug, None, None, None)
     self.assertIsInstance(subscribers, RESULT_SETS)
     self.assertEqual([], list(subscribers))
 def test_getStructuralSubscribers_level(self):
     # get_structural_subscribers() respects the given level.
     subscriber = self.factory.makePerson()
     login_person(subscriber)
     product, bug = self.make_product_with_bug()
     subscription = product.addBugSubscription(subscriber, subscriber)
     filter = subscription.bug_filters.one()
     filter.bug_notification_level = BugNotificationLevel.METADATA
     self.assertEqual(
         [subscriber], list(
             get_structural_subscribers(
                 bug, None, BugNotificationLevel.METADATA, None)))
     filter.bug_notification_level = BugNotificationLevel.METADATA
     self.assertEqual(
         [], list(
             get_structural_subscribers(
                 bug, None, BugNotificationLevel.COMMENTS, None)))
 def test_getStructuralSubscribers_single_target(self):
     # Subscribers for any of the bug's targets are returned.
     subscriber = self.factory.makePerson()
     login_person(subscriber)
     product, bug = self.make_product_with_bug()
     product.addBugSubscription(subscriber, subscriber)
     self.assertEqual(
         [subscriber], list(
             get_structural_subscribers(bug, None, None, None)))
Esempio n. 5
0
 def test_getStructuralSubscribers_single_target(self):
     # Subscribers for any of the bug's targets are returned.
     subscriber = self.factory.makePerson()
     login_person(subscriber)
     product, bug = self.make_product_with_bug()
     product.addBugSubscription(subscriber, subscriber)
     self.assertEqual([subscriber],
                      list(get_structural_subscribers(
                          bug, None, None, None)))
Esempio n. 6
0
 def test_getStructuralSubscribers_level(self):
     # get_structural_subscribers() respects the given level.
     subscriber = self.factory.makePerson()
     login_person(subscriber)
     product, bug = self.make_product_with_bug()
     subscription = product.addBugSubscription(subscriber, subscriber)
     filter = subscription.bug_filters.one()
     filter.bug_notification_level = BugNotificationLevel.METADATA
     self.assertEqual([subscriber],
                      list(
                          get_structural_subscribers(
                              bug, None, BugNotificationLevel.METADATA,
                              None)))
     filter.bug_notification_level = BugNotificationLevel.METADATA
     self.assertEqual([],
                      list(
                          get_structural_subscribers(
                              bug, None, BugNotificationLevel.COMMENTS,
                              None)))
 def test_getStructuralSubscribers_recipients(self):
     # If provided, get_structural_subscribers() calls the appropriate
     # methods on a BugNotificationRecipients object.
     subscriber = self.factory.makePerson()
     login_person(subscriber)
     product, bug = self.make_product_with_bug()
     product.addBugSubscription(subscriber, subscriber)
     recipients = BugNotificationRecipients()
     subscribers = get_structural_subscribers(bug, recipients, None, None)
     # The return value is a list only when populating recipients.
     self.assertIsInstance(subscribers, list)
     self.assertEqual([subscriber], recipients.getRecipients())
     reason, header = recipients.getReason(subscriber)
     self.assertThat(
         reason, StartsWith(
             u"You received this bug notification because "
             u"you are subscribed to "))
     self.assertThat(header, StartsWith(u"Subscriber "))
Esempio n. 8
0
 def test_getStructuralSubscribers_recipients(self):
     # If provided, get_structural_subscribers() calls the appropriate
     # methods on a BugNotificationRecipients object.
     subscriber = self.factory.makePerson()
     login_person(subscriber)
     product, bug = self.make_product_with_bug()
     product.addBugSubscription(subscriber, subscriber)
     recipients = BugNotificationRecipients()
     subscribers = get_structural_subscribers(bug, recipients, None, None)
     # The return value is a list only when populating recipients.
     self.assertIsInstance(subscribers, list)
     self.assertEqual([subscriber], recipients.getRecipients())
     reason, header = recipients.getReason(subscriber)
     self.assertThat(
         reason,
         StartsWith(u"You received this bug notification because "
                    u"you are subscribed to "))
     self.assertThat(header, StartsWith(u"Subscriber "))
    def test_getStructuralSubscribers_multiple_targets(self):
        # Subscribers for any of the bug's targets are returned.
        actor = self.factory.makePerson()
        login_person(actor)

        subscriber1 = self.factory.makePerson()
        subscriber2 = self.factory.makePerson()

        product1 = self.factory.makeProduct(owner=actor)
        product1.addBugSubscription(subscriber1, subscriber1)
        product2 = self.factory.makeProduct(owner=actor)
        product2.addBugSubscription(subscriber2, subscriber2)

        bug = self.factory.makeBug(target=product1)
        bug.addTask(actor, product2)

        subscribers = get_structural_subscribers(bug, None, None, None)
        self.assertIsInstance(subscribers, RESULT_SETS)
        self.assertEqual(set([subscriber1, subscriber2]), set(subscribers))
Esempio n. 10
0
    def test_getStructuralSubscribers_multiple_targets(self):
        # Subscribers for any of the bug's targets are returned.
        actor = self.factory.makePerson()
        login_person(actor)

        subscriber1 = self.factory.makePerson()
        subscriber2 = self.factory.makePerson()

        product1 = self.factory.makeProduct(owner=actor)
        product1.addBugSubscription(subscriber1, subscriber1)
        product2 = self.factory.makeProduct(owner=actor)
        product2.addBugSubscription(subscriber2, subscriber2)

        bug = self.factory.makeBug(target=product1)
        bug.addTask(actor, product2)

        subscribers = get_structural_subscribers(bug, None, None, None)
        self.assertIsInstance(subscribers, RESULT_SETS)
        self.assertEqual(set([subscriber1, subscriber2]), set(subscribers))
 def assertSubscribers(self, expected_subscribers,
                       level=BugNotificationLevel.LIFECYCLE):
     observed_subscribers = list(
         get_structural_subscribers(self.bugtask, None, level))
     self.assertEqual(expected_subscribers, observed_subscribers)
Esempio n. 12
0
 def assertSubscribers(self,
                       expected_subscribers,
                       level=BugNotificationLevel.LIFECYCLE):
     observed_subscribers = list(
         get_structural_subscribers(self.bugtask, None, level))
     self.assertEqual(expected_subscribers, observed_subscribers)