← Back to team overview

launchpad-reviewers team mailing list archive

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

 

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

Commit message:
Skip POFile.lasttranslator and POFileTranslator.person in close-account.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/close-account-po-file-translator/+merge/364110
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/close-account-po-file-translator into lp:launchpad.
=== modified file 'lib/lp/registry/scripts/closeaccount.py'
--- lib/lp/registry/scripts/closeaccount.py	2019-01-15 17:04:31 +0000
+++ lib/lp/registry/scripts/closeaccount.py	2019-03-07 17:23:03 +0000
@@ -1,4 +1,4 @@
-# Copyright 2009-2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2009-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Remove personal details of a user from the database, leaving a stub."""
@@ -112,6 +112,8 @@
         ('persontransferjob', 'major_person'),
         ('persontransferjob', 'minor_person'),
         ('poexportrequest', 'person'),
+        ('pofile', 'lasttranslator'),
+        ('pofiletranslator', 'person'),
         ('question', 'answerer'),
         ('questionreopening', 'answerer'),
         ('questionreopening', 'reopener'),

=== modified file 'lib/lp/registry/scripts/tests/test_closeaccount.py'
--- lib/lp/registry/scripts/tests/test_closeaccount.py	2019-01-15 17:04:31 +0000
+++ lib/lp/registry/scripts/tests/test_closeaccount.py	2019-03-07 17:23:03 +0000
@@ -1,4 +1,4 @@
-# Copyright 2018 Canonical Ltd.  This software is licensed under the
+# Copyright 2018-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
 """Test the close-account script."""
@@ -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.pofiletranslator import IPOFileTranslatorSet
 from lp.translations.interfaces.translationsperson import ITranslationsPerson
 
 
@@ -320,3 +321,22 @@
             self.runScript(script)
         self.assertRemoved(account_id, person_id)
         self.assertTrue(translations_person.translations_relicensing_agreement)
+
+    def test_skips_po_file_translators(self):
+        person = self.factory.makePerson()
+        pofile = self.factory.makePOFile()
+        potmsgset = self.factory.makePOTMsgSet(pofile.potemplate)
+        self.factory.makeCurrentTranslationMessage(
+            potmsgset=potmsgset, translator=person, language=pofile.language)
+        self.assertIsNotNone(
+            getUtility(IPOFileTranslatorSet).getForPersonPOFile(
+                person, pofile))
+        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.assertIsNotNone(
+            getUtility(IPOFileTranslatorSet).getForPersonPOFile(
+                person, pofile))


Follow ups