def test_get_structural_subscriptions_level(self): # get_structural_subscriptions() 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.assertContentEqual([subscription], get_structural_subscriptions( bug, BugNotificationLevel.METADATA)) self.assertContentEqual([], get_structural_subscriptions( bug, BugNotificationLevel.COMMENTS))
def test_get_structural_subscriptions_level(self): # get_structural_subscriptions() 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.assertContentEqual( [subscription], get_structural_subscriptions( bug, BugNotificationLevel.METADATA)) self.assertContentEqual( [], get_structural_subscriptions( bug, BugNotificationLevel.COMMENTS))
def test_get_structural_subscriptions_no_subscriptions(self): # If there are no subscriptions for any of the bug's targets then no # subscriptions will be returned by get_structural_subscriptions(). product, bug = self.make_product_with_bug() subscriptions = get_structural_subscriptions(bug, None) self.assertIsInstance(subscriptions, RESULT_SETS) self.assertEqual([], list(subscriptions))
def test_get_structural_subscriptions_single_target(self): # Subscriptions for any of the bug's targets are returned. subscriber = self.factory.makePerson() login_person(subscriber) product, bug = self.make_product_with_bug() subscription = product.addBugSubscription(subscriber, subscriber) self.assertContentEqual( [subscription], get_structural_subscriptions(bug, None))
def test_get_structural_subscriptions_single_target(self): # Subscriptions for any of the bug's targets are returned. subscriber = self.factory.makePerson() login_person(subscriber) product, bug = self.make_product_with_bug() subscription = product.addBugSubscription(subscriber, subscriber) self.assertContentEqual([subscription], get_structural_subscriptions(bug, None))
def test_get_structural_subscriptions_exclude(self): # Subscriptions for any of the given excluded subscribers are not # returned. subscriber = self.factory.makePerson() login_person(subscriber) product, bug = self.make_product_with_bug() product.addBugSubscription(subscriber, subscriber) self.assertContentEqual( [], get_structural_subscriptions( bug, None, exclude=[subscriber]))
def test_get_structural_subscriptions_exclude(self): # Subscriptions for any of the given excluded subscribers are not # returned. subscriber = self.factory.makePerson() login_person(subscriber) product, bug = self.make_product_with_bug() product.addBugSubscription(subscriber, subscriber) self.assertContentEqual([], get_structural_subscriptions( bug, None, exclude=[subscriber]))
def test_get_structural_subscriptions_multiple_targets_2(self): # Only the first of multiple subscriptions for a person is returned # when they have multiple matching subscriptions. actor = self.factory.makePerson() login_person(actor) subscriber = self.factory.makePerson() product1 = self.factory.makeProduct(owner=actor) subscription1 = product1.addBugSubscription(subscriber, subscriber) product2 = self.factory.makeProduct(owner=actor) product2.addBugSubscription(subscriber, subscriber) bug = self.factory.makeBug(target=product1) bug.addTask(actor, product2) subscriptions = get_structural_subscriptions(bug, None) self.assertIsInstance(subscriptions, RESULT_SETS) self.assertContentEqual([subscription1], subscriptions)
def test_get_structural_subscriptions_multiple_targets(self): # Subscriptions 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) subscription1 = product1.addBugSubscription(subscriber1, subscriber1) product2 = self.factory.makeProduct(owner=actor) subscription2 = product2.addBugSubscription(subscriber2, subscriber2) bug = self.factory.makeBug(target=product1) bug.addTask(actor, product2) subscriptions = get_structural_subscriptions(bug, None) self.assertIsInstance(subscriptions, RESULT_SETS) self.assertContentEqual([subscription1, subscription2], subscriptions)
def test_get_structural_subscriptions_multiple_targets(self): # Subscriptions 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) subscription1 = product1.addBugSubscription(subscriber1, subscriber1) product2 = self.factory.makeProduct(owner=actor) subscription2 = product2.addBugSubscription(subscriber2, subscriber2) bug = self.factory.makeBug(target=product1) bug.addTask(actor, product2) subscriptions = get_structural_subscriptions(bug, None) self.assertIsInstance(subscriptions, RESULT_SETS) self.assertContentEqual( [subscription1, subscription2], subscriptions)