← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/close-account-more into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/close-account-more into lp:launchpad.

Commit message:
Make close-account handle a few more cases related to bugs and translations.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/close-account-more/+merge/361793
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/close-account-more into lp:launchpad.
=== modified file 'lib/lp/registry/scripts/closeaccount.py'
--- lib/lp/registry/scripts/closeaccount.py	2018-12-17 14:48:36 +0000
+++ lib/lp/registry/scripts/closeaccount.py	2019-01-15 17:18:15 +0000
@@ -89,9 +89,11 @@
         ('branchmergeproposal', 'queuer'),
         ('branchmergeproposal', 'reviewer'),
         ('branchsubscription', 'subscribed_by'),
+        ('bug', 'owner'),
         ('bug', 'who_made_private'),
         ('bugactivity', 'person'),
         ('bugnomination', 'decider'),
+        ('bugtask', 'owner'),
         ('bugsubscription', 'subscribed_by'),
         ('faq', 'last_updated_by'),
         ('featureflagchangelogentry', 'person'),
@@ -135,6 +137,7 @@
         ('translationimportqueueentry', 'importer'),
         ('translationmessage', 'reviewer'),
         ('translationmessage', 'submitter'),
+        ('translationrelicensingagreement', 'person'),
         ('usertouseremail', 'recipient'),
         ('usertouseremail', 'sender'),
         ('xref', 'creator'),
@@ -230,9 +233,10 @@
         ('SignedCodeOfConduct', 'owner'),
         ('GpgKey', 'owner'),
 
-        # Subscriptions
+        # Subscriptions and notifications
         ('BranchSubscription', 'person'),
         ('BugMute', 'person'),
+        ('BugNotificationRecipient', 'person'),
         ('BugSubscription', 'person'),
         ('BugSubscriptionFilterMute', 'person'),
         ('GitSubscription', 'person'),
@@ -275,6 +279,9 @@
         # Soyuz reporting
         ('LatestPersonSourcePackageReleaseCache', 'creator'),
         ('LatestPersonSourcePackageReleaseCache', 'maintainer'),
+
+        # "Affects me too" information
+        ('BugAffectsPerson', 'person'),
         ]
     for table, person_id_column in removals:
         table_notification(table)

=== modified file 'lib/lp/registry/scripts/tests/test_closeaccount.py'
--- lib/lp/registry/scripts/tests/test_closeaccount.py	2018-12-20 11:11:36 +0000
+++ lib/lp/registry/scripts/tests/test_closeaccount.py	2019-01-15 17:18:15 +0000
@@ -37,6 +37,7 @@
 from lp.testing import TestCaseWithFactory
 from lp.testing.dbuser import dbuser
 from lp.testing.layers import LaunchpadZopelessLayer
+from lp.translations.interfaces.translationsperson import ITranslationsPerson
 
 
 class TestCloseAccount(TestCaseWithFactory):
@@ -281,3 +282,41 @@
         self.assertEqual(person, spph.package_maintainer)
         self.assertEqual(person, spph.package_creator)
         self.assertFalse(person.hasMaintainedPackages())
+
+    def test_skips_reported_bugs(self):
+        person = self.factory.makePerson()
+        bug = self.factory.makeBug(owner=person)
+        bugtask = self.factory.makeBugTask(bug=bug, owner=person)
+        person_id = person.id
+        account_id = person.account.id
+        script = self.makeScript([six.ensure_str(person.name)])
+        with dbuser('launchpad'):
+            self.runScript(script)
+        self.assertRemoved(account_id, person_id)
+        self.assertEqual(person, bug.owner)
+        self.assertEqual(person, bugtask.owner)
+
+    def test_handles_bug_affects_person(self):
+        person = self.factory.makePerson()
+        bug = self.factory.makeBug()
+        bug.markUserAffected(person)
+        self.assertTrue(bug.isUserAffected(person))
+        person_id = person.id
+        account_id = person.account.id
+        script = self.makeScript([six.ensure_str(person.name)])
+        with dbuser('launchpad'):
+            self.runScript(script)
+        self.assertRemoved(account_id, person_id)
+        self.assertFalse(bug.isUserAffected(person))
+
+    def test_skips_translation_relicensing_agreements(self):
+        person = self.factory.makePerson()
+        translations_person = ITranslationsPerson(person)
+        translations_person.translations_relicensing_agreement = True
+        person_id = person.id
+        account_id = person.account.id
+        script = self.makeScript([six.ensure_str(person.name)])
+        with dbuser('launchpad'):
+            self.runScript(script)
+        self.assertRemoved(account_id, person_id)
+        self.assertTrue(translations_person.translations_relicensing_agreement)


Follow ups