Merge lp:~cjwatson/launchpad/close-account-po-file-translator into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18896
Proposed branch: lp:~cjwatson/launchpad/close-account-po-file-translator
Merge into: lp:launchpad
Diff against target: 59 lines (+24/-2)
2 files modified
lib/lp/registry/scripts/closeaccount.py (+3/-1)
lib/lp/registry/scripts/tests/test_closeaccount.py (+21/-1)
To merge this branch: bzr merge lp:~cjwatson/launchpad/close-account-po-file-translator
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+364110@code.launchpad.net

Commit message

Skip POFile.lasttranslator and POFileTranslator.person in close-account.

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 2019-01-15 17:04:31 +0000
3+++ lib/lp/registry/scripts/closeaccount.py 2019-03-07 17:23:03 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2009-2018 Canonical Ltd. This software is licensed under the
6+# Copyright 2009-2019 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """Remove personal details of a user from the database, leaving a stub."""
10@@ -112,6 +112,8 @@
11 ('persontransferjob', 'major_person'),
12 ('persontransferjob', 'minor_person'),
13 ('poexportrequest', 'person'),
14+ ('pofile', 'lasttranslator'),
15+ ('pofiletranslator', 'person'),
16 ('question', 'answerer'),
17 ('questionreopening', 'answerer'),
18 ('questionreopening', 'reopener'),
19
20=== modified file 'lib/lp/registry/scripts/tests/test_closeaccount.py'
21--- lib/lp/registry/scripts/tests/test_closeaccount.py 2019-01-15 17:04:31 +0000
22+++ lib/lp/registry/scripts/tests/test_closeaccount.py 2019-03-07 17:23:03 +0000
23@@ -1,4 +1,4 @@
24-# Copyright 2018 Canonical Ltd. This software is licensed under the
25+# Copyright 2018-2019 Canonical Ltd. This software is licensed under the
26 # GNU Affero General Public License version 3 (see the file LICENSE).
27
28 """Test the close-account script."""
29@@ -37,6 +37,7 @@
30 from lp.testing import TestCaseWithFactory
31 from lp.testing.dbuser import dbuser
32 from lp.testing.layers import LaunchpadZopelessLayer
33+from lp.translations.interfaces.pofiletranslator import IPOFileTranslatorSet
34 from lp.translations.interfaces.translationsperson import ITranslationsPerson
35
36
37@@ -320,3 +321,22 @@
38 self.runScript(script)
39 self.assertRemoved(account_id, person_id)
40 self.assertTrue(translations_person.translations_relicensing_agreement)
41+
42+ def test_skips_po_file_translators(self):
43+ person = self.factory.makePerson()
44+ pofile = self.factory.makePOFile()
45+ potmsgset = self.factory.makePOTMsgSet(pofile.potemplate)
46+ self.factory.makeCurrentTranslationMessage(
47+ potmsgset=potmsgset, translator=person, language=pofile.language)
48+ self.assertIsNotNone(
49+ getUtility(IPOFileTranslatorSet).getForPersonPOFile(
50+ person, pofile))
51+ person_id = person.id
52+ account_id = person.account.id
53+ script = self.makeScript([six.ensure_str(person.name)])
54+ with dbuser('launchpad'):
55+ self.runScript(script)
56+ self.assertRemoved(account_id, person_id)
57+ self.assertIsNotNone(
58+ getUtility(IPOFileTranslatorSet).getForPersonPOFile(
59+ person, pofile))