476
478
self.assertContentEqual(public_branches, linked_branches)
477
479
self.assertNotIn(private_branch, linked_branches)
481
def test_getDirectSubscribers_with_recipients_query_count(self):
482
# getDirectSubscribers() uses a constant number of queries when given
483
# a recipients argument regardless of the number of subscribers.
484
bug = self.factory.makeBug()
486
def create_subscriber():
487
subscriber = self.factory.makePerson()
488
with person_logged_in(subscriber):
489
bug.subscribe(subscriber, subscriber)
491
def get_subscribers():
492
recipients = BugNotificationRecipients()
493
subs = bug.getDirectSubscribers(recipients=recipients)
494
list(subs) # Ensure they're pulled.
496
recorder1, recorder2 = record_two_runs(
497
get_subscribers, create_subscriber, 3)
499
recorder2, HasQueryCount(Equals(recorder1.count)))
501
def test_getSubscribersFromDuplicates_with_recipients_query_count(self):
502
# getSubscribersFromDuplicates() uses a constant number of queries
503
# when given a recipients argument regardless of the number of
505
bug = self.factory.makeBug()
506
duplicate_bug = self.factory.makeBug()
507
with person_logged_in(duplicate_bug.owner):
508
duplicate_bug.markAsDuplicate(bug)
510
def create_subscriber():
511
subscriber = self.factory.makePerson()
512
with person_logged_in(subscriber):
513
duplicate_bug.subscribe(subscriber, subscriber)
515
def get_subscribers():
516
recipients = BugNotificationRecipients()
517
subs = bug.getSubscribersFromDuplicates(recipients=recipients)
518
list(subs) # Ensure they're pulled.
520
recorder1, recorder2 = record_two_runs(
521
get_subscribers, create_subscriber, 3)
523
recorder2, HasQueryCount(Equals(recorder1.count)))
525
def test_getAlsoNotifiedSubscribers_with_recipients_query_count(self):
526
# getAlsoNotifiedSubscribers() uses a constant number of queries when
527
# given a recipients argument regardless of the number of subscribers.
528
bug = self.factory.makeBug()
531
# Create a new bugtask, set its assignee, set its pillar's
532
# official_malone=True, and subscribe someone to its target.
533
bugtask = self.factory.makeBugTask(bug=bug)
534
with person_logged_in(bugtask.owner):
535
bugtask.transitionToAssignee(bugtask.owner)
536
with person_logged_in(bugtask.pillar.owner):
537
bugtask.pillar.official_malone = True
538
subscriber = self.factory.makePerson()
539
with person_logged_in(subscriber):
540
bugtask.target.addSubscription(
541
subscriber, subscriber)
543
def get_subscribers():
544
recipients = BugNotificationRecipients()
545
subs = bug.getAlsoNotifiedSubscribers(recipients=recipients)
546
list(subs) # Ensure they're pulled.
548
recorder1, recorder2 = record_two_runs(
549
get_subscribers, create_stuff, 3)
551
recorder2, HasQueryCount(Equals(recorder1.count)))
480
554
class TestBugPrivateAndSecurityRelatedUpdatesMixin:
553
627
# If the bug is for a private project, then other direct subscribers
554
628
# should be unsubscribed.
556
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
630
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
557
631
self.createBugTasksAndSubscribers())
558
632
initial_subscribers = set((
559
633
self.factory.makePerson(), bugtask_a.owner, bug_owner,
586
660
# If the bug is for a private project, then other direct subscribers
587
661
# should be unsubscribed.
589
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
663
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
590
664
self.createBugTasksAndSubscribers(private_security_related=True))
591
665
initial_subscribers = set((
592
666
self.factory.makePerson(), bug_owner,
617
691
# If the bug is for a private project, then other direct subscribers
618
692
# should be unsubscribed.
620
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
694
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
621
695
self.createBugTasksAndSubscribers(private_security_related=True))
622
696
initial_subscribers = set((
623
self.factory.makePerson(), bug_owner,
697
self.factory.makePerson(), bug_owner,
624
698
bugtask_a.pillar.security_contact, bugtask_a.pillar.driver,
625
699
bugtask_a.pillar.bug_supervisor))
644
718
# When a bug is marked as private=false and security_related=false,
645
719
# any existing subscriptions are left alone.
647
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
721
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
648
722
self.createBugTasksAndSubscribers(private_security_related=True))
649
723
initial_subscribers = set((
650
724
self.factory.makePerson(), bug_owner,
751
825
# The bug supervisors are unsubscribed if a bug is made public and an
752
826
# email is sent telling them they have been unsubscribed.
754
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
828
(bug, bug_owner, bugtask_a, bugtask_b, default_bugtask) = (
755
829
self.createBugTasksAndSubscribers(private_security_related=True))
757
831
with person_logged_in(bug_owner):