437
438
list(user.getBugSubscriberPackages())
438
439
self.assertThat(recorder, HasQueryCount(Equals(1)))
441
def createCopiedPackage(self, spph, copier, dest_distroseries=None,
443
if dest_distroseries is None:
444
dest_distroseries = self.factory.makeDistroSeries()
445
if dest_archive is None:
446
dest_archive = dest_distroseries.main_archive
448
dest_distroseries, creator=copier,
449
pocket=PackagePublishingPocket.UPDATES,
450
archive=dest_archive)
452
def test_getLatestSynchronisedPublishings_most_recent_first(self):
453
# getLatestSynchronisedPublishings returns the latest copies sorted
454
# by most recent first.
455
spph = self.factory.makeSourcePackagePublishingHistory()
456
copier = self.factory.makePerson()
457
copied_spph1 = self.createCopiedPackage(spph, copier)
458
copied_spph2 = self.createCopiedPackage(spph, copier)
459
synchronised_spphs = copier.getLatestSynchronisedPublishings()
461
self.assertContentEqual(
462
[copied_spph2, copied_spph1],
465
def test_getLatestSynchronisedPublishings_other_creator(self):
466
spph = self.factory.makeSourcePackagePublishingHistory()
467
copier = self.factory.makePerson()
468
self.createCopiedPackage(spph, copier)
469
someone_else = self.factory.makePerson()
470
synchronised_spphs = someone_else.getLatestSynchronisedPublishings()
474
synchronised_spphs.count())
476
def test_getLatestSynchronisedPublishings_latest(self):
477
# getLatestSynchronisedPublishings returns only the latest copy of
478
# a package in a distroseries
479
spph = self.factory.makeSourcePackagePublishingHistory()
480
copier = self.factory.makePerson()
481
dest_distroseries = self.factory.makeDistroSeries()
482
self.createCopiedPackage(
483
spph, copier, dest_distroseries)
484
copied_spph2 = self.createCopiedPackage(
485
spph, copier, dest_distroseries)
486
synchronised_spphs = copier.getLatestSynchronisedPublishings()
488
self.assertContentEqual(
492
def test_getLatestSynchronisedPublishings_cross_archive_copies(self):
493
# getLatestSynchronisedPublishings returns only the copies copied
495
spph = self.factory.makeSourcePackagePublishingHistory()
496
copier = self.factory.makePerson()
497
dest_distroseries2 = self.factory.makeDistroSeries(
498
distribution=spph.distroseries.distribution)
499
self.createCopiedPackage(
500
spph, copier, dest_distroseries2)
501
synchronised_spphs = copier.getLatestSynchronisedPublishings()
505
synchronised_spphs.count())
507
def test_getLatestSynchronisedPublishings_main_archive(self):
508
# getLatestSynchronisedPublishings returns only the copies copied in
509
# a primary archive (as opposed to a ppa).
510
spph = self.factory.makeSourcePackagePublishingHistory()
511
copier = self.factory.makePerson()
512
dest_distroseries = self.factory.makeDistroSeries()
513
ppa = self.factory.makeArchive(
514
distribution=dest_distroseries.distribution)
515
self.createCopiedPackage(
516
spph, copier, dest_distroseries, ppa)
517
synchronised_spphs = copier.getLatestSynchronisedPublishings()
521
synchronised_spphs.count())
441
524
class TestPersonStates(TestCaseWithFactory):
1636
1719
super_team_member_person,
1637
1720
super_team_member_team]),
1638
1721
set(recipients))
1723
def test_get_recipients_team_with_disabled_owner_account(self):
1724
"""Mail is not sent to a team owner whose account is disabled.
1726
See <https://bugs.launchpad.net/launchpad/+bug/855150>
1728
owner = self.factory.makePerson(email='foo@bar.com')
1729
team = self.factory.makeTeam(owner)
1730
owner.account.status = AccountStatus.DEACTIVATED
1731
self.assertContentEqual([], get_recipients(team))
1733
def test_get_recipients_team_with_disabled_member_account(self):
1734
"""Mail is not sent to a team member whose account is disabled.
1736
See <https://bugs.launchpad.net/launchpad/+bug/855150>
1738
person = self.factory.makePerson(email='foo@bar.com')
1739
person.account.status = AccountStatus.DEACTIVATED
1740
team = self.factory.makeTeam(members=[person])
1741
self.assertContentEqual([team.teamowner], get_recipients(team))
1743
def test_get_recipients_team_with_nested_disabled_member_account(self):
1744
"""Mail is not sent to transitive team member with disabled account.
1746
See <https://bugs.launchpad.net/launchpad/+bug/855150>
1748
person = self.factory.makePerson(email='foo@bar.com')
1749
person.account.status = AccountStatus.DEACTIVATED
1750
team1 = self.factory.makeTeam(members=[person])
1751
team2 = self.factory.makeTeam(members=[team1])
1752
self.assertContentEqual(
1754
get_recipients(team2))