Colin Watson has proposed merging ~cjwatson/launchpad:fix-stormify-logintoken into launchpad:master.
Commit message: Fix bugs in conversion of LoginToken to Storm Requested reviews: Launchpad code reviewers (launchpad-reviewers) For more details, see: https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/446419 `LoginTokenSet.new` needs to explicitly add the new token to the store, as it may not be linked to any other object if it doesn't have a requester (e.g. `LoginTokenType.BUGTRACKER` tokens). `test_LoginTokenPruner` needs to flush SQL statements for new tokens to the database before trying to get their IDs. -- Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:fix-stormify-logintoken into launchpad:master.
diff --git a/lib/lp/scripts/tests/test_garbo.py b/lib/lp/scripts/tests/test_garbo.py index 71d302f..ea92f5a 100644 --- a/lib/lp/scripts/tests/test_garbo.py +++ b/lib/lp/scripts/tests/test_garbo.py @@ -2609,15 +2609,17 @@ class TestGarboTasks(TestCaseWithFactory): email="whatever", tokentype=LoginTokenType.NEWACCOUNT ) old_token.date_created = now - timedelta(days=666) - old_token_id = old_token.id store.add(old_token) + store.flush() + old_token_id = old_token.id # Create a token that will not be pruned. current_token = LoginToken( email="whatever", tokentype=LoginTokenType.NEWACCOUNT ) - current_token_id = current_token.id store.add(current_token) + store.flush() + current_token_id = current_token.id # Run the pruner. Batching is tested by the BulkPruner tests so # no need to repeat here. diff --git a/lib/lp/services/verification/model/logintoken.py b/lib/lp/services/verification/model/logintoken.py index 572cce2..03a5bc6 100644 --- a/lib/lp/services/verification/model/logintoken.py +++ b/lib/lp/services/verification/model/logintoken.py @@ -395,14 +395,16 @@ class LoginTokenSet: "tokentype is not an item of LoginTokenType: %s" % tokentype ) token = create_token(20) - return LoginToken( - requester=requester, - requesteremail=requesteremail, - email=email, - token=token, - tokentype=tokentype, - fingerprint=fingerprint, - redirection_url=redirection_url, + return IStore(LoginToken).add( + LoginToken( + requester=requester, + requesteremail=requesteremail, + email=email, + token=token, + tokentype=tokentype, + fingerprint=fingerprint, + redirection_url=redirection_url, + ) ) def __getitem__(self, tokentext):
_______________________________________________ Mailing list: https://launchpad.net/~launchpad-reviewers Post to : launchpad-reviewers@lists.launchpad.net Unsubscribe : https://launchpad.net/~launchpad-reviewers More help : https://help.launchpad.net/ListHelp