Merge ~clinton-fung/launchpad:account-deletion-person-merge-skip01 into launchpad:master

Proposed by Clinton Fung
Status: Merged
Approved by: Clinton Fung
Approved revision: 3e93666d5edde65d70313a3daf93fc369d4b1130
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~clinton-fung/launchpad:account-deletion-person-merge-skip01
Merge into: launchpad:master
Diff against target: 50 lines (+21/-0)
2 files modified
lib/lp/registry/scripts/closeaccount.py (+2/-0)
lib/lp/registry/scripts/tests/test_closeaccount.py (+19/-0)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+436973@code.launchpad.net

Commit message

Add a skip for person.merged (and also personnotification.person) to allow account closure to proceed.

Description of the change

When merging two accounts, the source (from) account has a field set that links it to the target (to) account, for audit purposes. This link prevents account deletion. Add a skip to allow deletion to complete in this scenario.

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Otto Co-Pilot (otto-copilot) wrote :

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/lib/lp/registry/scripts/closeaccount.py b/lib/lp/registry/scripts/closeaccount.py
2index f673a02..cb2bf4f 100644
3--- a/lib/lp/registry/scripts/closeaccount.py
4+++ b/lib/lp/registry/scripts/closeaccount.py
5@@ -140,7 +140,9 @@ def close_account(username, log):
6 ("packagecopyrequest", "requester"),
7 ("packagediff", "requester"),
8 ("packageupload", "signing_key_owner"),
9+ ("person", "merged"),
10 ("personlocation", "last_modified_by"),
11+ ("personnotification", "person"),
12 ("persontransferjob", "major_person"),
13 ("persontransferjob", "minor_person"),
14 ("poexportrequest", "person"),
15diff --git a/lib/lp/registry/scripts/tests/test_closeaccount.py b/lib/lp/registry/scripts/tests/test_closeaccount.py
16index 41ca7e5..c1270d4 100644
17--- a/lib/lp/registry/scripts/tests/test_closeaccount.py
18+++ b/lib/lp/registry/scripts/tests/test_closeaccount.py
19@@ -32,8 +32,10 @@ from lp.code.tests.helpers import GitHostingFixture
20 from lp.registry.interfaces.person import IPersonSet
21 from lp.registry.interfaces.teammembership import ITeamMembershipSet
22 from lp.registry.model.productrelease import ProductRelease
23+from lp.registry.personmerge import merge_people
24 from lp.registry.scripts.closeaccount import CloseAccountScript
25 from lp.scripts.garbo import PopulateLatestPersonSourcePackageReleaseCache
26+from lp.services.config import config
27 from lp.services.database.interfaces import IStore
28 from lp.services.database.sqlbase import (
29 flush_database_caches,
30@@ -1296,3 +1298,20 @@ class TestCloseAccount(TestCaseWithFactory):
31 else:
32 self.runScript(script)
33 self.assertRemoved(account_id, person_id)
34+
35+ def test_skips_merged_and_personnotification_references(self):
36+ from_person = self.factory.makePerson(
37+ account_status=AccountStatus.PLACEHOLDER
38+ )
39+ to_person = self.factory.makePerson()
40+
41+ # See TestMergePeople._do_merge()
42+ with dbuser(config.IPersonMergeJobSource.dbuser):
43+ merge_people(from_person, to_person, None)
44+
45+ account_id = to_person.account.id
46+ person_id = to_person.id
47+ script = self.makeScript([to_person.name])
48+ with dbuser("launchpad"):
49+ self.runScript(script)
50+ self.assertRemoved(account_id, person_id)

Subscribers

People subscribed via source and target branches

to status/vote changes: