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

Proposed by Colin Watson
Status: Merged
Merged at revision: 18856
Proposed branch: lp:~cjwatson/launchpad/close-account-more
Merge into: lp:launchpad
Diff against target: 99 lines (+47/-1)
2 files modified
lib/lp/registry/scripts/closeaccount.py (+8/-1)
lib/lp/registry/scripts/tests/test_closeaccount.py (+39/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/close-account-more
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+361793@code.launchpad.net

Commit message

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

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/scripts/closeaccount.py'
2--- lib/lp/registry/scripts/closeaccount.py 2018-12-17 14:48:36 +0000
3+++ lib/lp/registry/scripts/closeaccount.py 2019-01-15 17:18:15 +0000
4@@ -89,9 +89,11 @@
5 ('branchmergeproposal', 'queuer'),
6 ('branchmergeproposal', 'reviewer'),
7 ('branchsubscription', 'subscribed_by'),
8+ ('bug', 'owner'),
9 ('bug', 'who_made_private'),
10 ('bugactivity', 'person'),
11 ('bugnomination', 'decider'),
12+ ('bugtask', 'owner'),
13 ('bugsubscription', 'subscribed_by'),
14 ('faq', 'last_updated_by'),
15 ('featureflagchangelogentry', 'person'),
16@@ -135,6 +137,7 @@
17 ('translationimportqueueentry', 'importer'),
18 ('translationmessage', 'reviewer'),
19 ('translationmessage', 'submitter'),
20+ ('translationrelicensingagreement', 'person'),
21 ('usertouseremail', 'recipient'),
22 ('usertouseremail', 'sender'),
23 ('xref', 'creator'),
24@@ -230,9 +233,10 @@
25 ('SignedCodeOfConduct', 'owner'),
26 ('GpgKey', 'owner'),
27
28- # Subscriptions
29+ # Subscriptions and notifications
30 ('BranchSubscription', 'person'),
31 ('BugMute', 'person'),
32+ ('BugNotificationRecipient', 'person'),
33 ('BugSubscription', 'person'),
34 ('BugSubscriptionFilterMute', 'person'),
35 ('GitSubscription', 'person'),
36@@ -275,6 +279,9 @@
37 # Soyuz reporting
38 ('LatestPersonSourcePackageReleaseCache', 'creator'),
39 ('LatestPersonSourcePackageReleaseCache', 'maintainer'),
40+
41+ # "Affects me too" information
42+ ('BugAffectsPerson', 'person'),
43 ]
44 for table, person_id_column in removals:
45 table_notification(table)
46
47=== modified file 'lib/lp/registry/scripts/tests/test_closeaccount.py'
48--- lib/lp/registry/scripts/tests/test_closeaccount.py 2018-12-20 11:11:36 +0000
49+++ lib/lp/registry/scripts/tests/test_closeaccount.py 2019-01-15 17:18:15 +0000
50@@ -37,6 +37,7 @@
51 from lp.testing import TestCaseWithFactory
52 from lp.testing.dbuser import dbuser
53 from lp.testing.layers import LaunchpadZopelessLayer
54+from lp.translations.interfaces.translationsperson import ITranslationsPerson
55
56
57 class TestCloseAccount(TestCaseWithFactory):
58@@ -281,3 +282,41 @@
59 self.assertEqual(person, spph.package_maintainer)
60 self.assertEqual(person, spph.package_creator)
61 self.assertFalse(person.hasMaintainedPackages())
62+
63+ def test_skips_reported_bugs(self):
64+ person = self.factory.makePerson()
65+ bug = self.factory.makeBug(owner=person)
66+ bugtask = self.factory.makeBugTask(bug=bug, owner=person)
67+ person_id = person.id
68+ account_id = person.account.id
69+ script = self.makeScript([six.ensure_str(person.name)])
70+ with dbuser('launchpad'):
71+ self.runScript(script)
72+ self.assertRemoved(account_id, person_id)
73+ self.assertEqual(person, bug.owner)
74+ self.assertEqual(person, bugtask.owner)
75+
76+ def test_handles_bug_affects_person(self):
77+ person = self.factory.makePerson()
78+ bug = self.factory.makeBug()
79+ bug.markUserAffected(person)
80+ self.assertTrue(bug.isUserAffected(person))
81+ person_id = person.id
82+ account_id = person.account.id
83+ script = self.makeScript([six.ensure_str(person.name)])
84+ with dbuser('launchpad'):
85+ self.runScript(script)
86+ self.assertRemoved(account_id, person_id)
87+ self.assertFalse(bug.isUserAffected(person))
88+
89+ def test_skips_translation_relicensing_agreements(self):
90+ person = self.factory.makePerson()
91+ translations_person = ITranslationsPerson(person)
92+ translations_person.translations_relicensing_agreement = True
93+ person_id = person.id
94+ account_id = person.account.id
95+ script = self.makeScript([six.ensure_str(person.name)])
96+ with dbuser('launchpad'):
97+ self.runScript(script)
98+ self.assertRemoved(account_id, person_id)
99+ self.assertTrue(translations_person.translations_relicensing_agreement)