~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/tests/test_personset.py

  • Committer: Stuart Bishop
  • Date: 2012-01-05 07:57:21 UTC
  • mfrom: (14635 devel)
  • mto: This revision was merged to the branch mainline in revision 14636.
  • Revision ID: stuart.bishop@canonical.com-20120105075721-ol7khggaclh7dgqj
Merged rocketfuel into db-deploy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2012 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""Tests for PersonSet."""
201
201
 
202
202
    def test_existing_deactivated_account(self):
203
203
        # An existing deactivated account will be reactivated.
204
 
        account = self.factory.makeAccount('purchaser',
205
 
            status=AccountStatus.DEACTIVATED)
 
204
        person = self.factory.makePerson(
 
205
            account_status=AccountStatus.DEACTIVATED)
206
206
        openid_ident = removeSecurityProxy(
207
 
            account).openid_identifiers.any().identifier
 
207
            person.account).openid_identifiers.any().identifier
208
208
 
209
 
        person, db_updated = self.callGetOrCreate(openid_ident)
 
209
        found_person, db_updated = self.callGetOrCreate(openid_ident)
 
210
        self.assertEqual(person, found_person)
210
211
        self.assertEqual(AccountStatus.ACTIVE, person.account.status)
211
212
        self.assertTrue(db_updated)
212
213
        self.assertEqual(
215
216
 
216
217
    def test_existing_suspended_account(self):
217
218
        # An existing suspended account will raise an exception.
218
 
        account = self.factory.makeAccount('purchaser',
219
 
            status=AccountStatus.SUSPENDED)
 
219
        person = self.factory.makePerson(
 
220
            account_status=AccountStatus.SUSPENDED)
220
221
        openid_ident = removeSecurityProxy(
221
 
            account).openid_identifiers.any().identifier
 
222
            person.account).openid_identifiers.any().identifier
222
223
 
223
224
        self.assertRaises(
224
225
            AccountSuspendedError, self.callGetOrCreate, openid_ident)
236
237
    def test_no_matching_account_existing_email(self):
237
238
        # The openid_identity of the account matching the email will
238
239
        # updated.
239
 
        other_account = self.factory.makeAccount('test', email='a@b.com')
 
240
        other_person = self.factory.makePerson('a@b.com')
240
241
 
241
242
        person, db_updated = self.callGetOrCreate(
242
243
            u'other-openid-identifier', 'a@b.com')
243
244
 
244
 
        self.assertEqual(other_account, person.account)
 
245
        self.assertEqual(other_person, person)
245
246
        self.assert_(
246
247
            u'other-openid-identifier' in [
247
248
                identifier.identifier for identifier in removeSecurityProxy(