← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:simplify-makePerson-email into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:simplify-makePerson-email into launchpad:master.

Commit message:
Save a query in factory.makePerson

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/409552

Since this method knows that it's just created the `Person`, it doesn't need to perform the extra check for an existing preferred email address in `Person.validateAndEnsurePreferredEmail` and can instead just call `Person.setPreferredEmail` directly.  This saves a query from every `makePerson` call, which is very common in the test suite.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:simplify-makePerson-email into launchpad:master.
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index 1ee6fe5..6bd1811 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -674,7 +674,7 @@ class BareLaunchpadObjectFactory(ObjectFactory):
             account = IMasterStore(Account).get(
                 Account, person.accountID)
             account.status = AccountStatus.ACTIVE
-            person.validateAndEnsurePreferredEmail(email)
+            person.setPreferredEmail(email)
 
         removeSecurityProxy(email).status = email_address_status