diff --git a/lastuser_core/models/user.py b/lastuser_core/models/user.py index e0acac07a..051568de6 100644 --- a/lastuser_core/models/user.py +++ b/lastuser_core/models/user.py @@ -595,48 +595,11 @@ def get(cls, buid=None): # -- User/Org/Team email/phone and misc -class OwnerMixin(object): - """ - Provides the :attr:`owner` property for UserEmail, UserEmailClaim, - UserPhone and UserPhoneClaim. - """ - @property - def owner(self): - """The owner of this object""" - return self.user or self.org or self.team - - @owner.setter - def owner(self, value): - if isinstance(value, User): - self.user = value - self.org = None - self.team = None - elif isinstance(value, Organization): - self.user = None - self.org = value - self.team = None - elif isinstance(value, Team): - self.user = None - self.org = None - self.team = value - else: - raise ValueError(value) - - -class UserEmail(OwnerMixin, BaseMixin, db.Model): +class UserEmail(BaseMixin, db.Model): __tablename__ = 'useremail' - user_id = db.Column(None, db.ForeignKey('user.id'), nullable=True) + user_id = db.Column(None, db.ForeignKey('user.id'), nullable=False) user = db.relationship(User, primaryjoin=user_id == User.id, backref=db.backref('emails', cascade='all, delete-orphan')) - - org_id = db.Column(None, db.ForeignKey('organization.id'), nullable=True) - org = db.relationship(Organization, primaryjoin=org_id == Organization.id, - backref=db.backref('emails', cascade='all, delete-orphan')) - - team_id = db.Column(None, db.ForeignKey('team.id'), nullable=True) - team = db.relationship(Team, primaryjoin=team_id == Team.id, - backref=db.backref('emails', cascade='all, delete-orphan')) - _email = db.Column('email', db.Unicode(254), unique=True, nullable=False) md5sum = db.Column(db.String(32), unique=True, nullable=False) domain = db.Column(db.Unicode(253), nullable=False, index=True) @@ -644,12 +607,6 @@ class UserEmail(OwnerMixin, BaseMixin, db.Model): private = db.Column(db.Boolean, nullable=False, default=False) type = db.Column(db.Unicode(30), nullable=True) - __table_args__ = (db.CheckConstraint( - db.case([(user_id != None, 1)], else_=0) + - db.case([(org_id != None, 1)], else_=0) + - db.case([(team_id != None, 1)], else_=0) == 1, # NOQA - name='useremail_user_id_or_org_id_or_team_id'),) - def __init__(self, email, **kwargs): super(UserEmail, self).__init__(**kwargs) self._email = email.lower() @@ -666,8 +623,8 @@ def email(self): email = db.synonym('_email', descriptor=email) def __repr__(self): - return ''.format( - email=self.email, owner=repr(self.owner)[1:-1]) + return ''.format( + email=self.email, user=repr(self.user)[1:-1]) def __unicode__(self): return unicode(self.email) @@ -712,20 +669,11 @@ def get(cls, email=None, md5sum=None): DDL('DROP INDEX ix_useremail_email_lower').execute_if(dialect='postgresql')) -class UserEmailClaim(OwnerMixin, BaseMixin, db.Model): +class UserEmailClaim(BaseMixin, db.Model): __tablename__ = 'useremailclaim' - user_id = db.Column(None, db.ForeignKey('user.id'), nullable=True) + user_id = db.Column(None, db.ForeignKey('user.id'), nullable=False) user = db.relationship(User, primaryjoin=user_id == User.id, backref=db.backref('emailclaims', cascade='all, delete-orphan')) - - org_id = db.Column(None, db.ForeignKey('organization.id'), nullable=True) - org = db.relationship(Organization, primaryjoin=org_id == Organization.id, - backref=db.backref('emailclaims', cascade='all, delete-orphan')) - - team_id = db.Column(None, db.ForeignKey('team.id'), nullable=True) - team = db.relationship(Team, primaryjoin=team_id == Team.id, - backref=db.backref('emailclaims', cascade='all, delete-orphan')) - _email = db.Column('email', db.Unicode(254), nullable=True, index=True) verification_code = db.Column(db.String(44), nullable=False, default=newsecret) md5sum = db.Column(db.String(32), nullable=False, index=True) @@ -734,17 +682,7 @@ class UserEmailClaim(OwnerMixin, BaseMixin, db.Model): private = db.Column(db.Boolean, nullable=False, default=False) type = db.Column(db.Unicode(30), nullable=True) - __table_args__ = ( - # Only one of these three unique constraints will apply as null values - # in the *_id columns are ignored for unique constraints - db.UniqueConstraint('user_id', 'email'), - db.UniqueConstraint('org_id', 'email'), - db.UniqueConstraint('team_id', 'email'), - db.CheckConstraint( - db.case([(user_id != None, 1)], else_=0) + - db.case([(org_id != None, 1)], else_=0) + - db.case([(team_id != None, 1)], else_=0) == 1, # NOQA - name='useremailclaim_user_id_or_org_id_or_team_id')) + __table_args__ = (db.UniqueConstraint('user_id', 'email'),) def __init__(self, email, **kwargs): super(UserEmailClaim, self).__init__(**kwargs) @@ -761,8 +699,8 @@ def email(self): email = db.synonym('_email', descriptor=email) def __repr__(self): - return ''.format( - email=self.email, owner=repr(self.owner)[1:-1]) + return ''.format( + email=self.email, user=repr(self.user)[1:-1]) def __unicode__(self): return unicode(self.email) @@ -796,32 +734,17 @@ def all(cls, email): return cls.query.filter(UserEmailClaim.email.in_([email, email.lower()])).order_by(cls.user_id).all() -class UserPhone(OwnerMixin, BaseMixin, db.Model): +class UserPhone(BaseMixin, db.Model): __tablename__ = 'userphone' - user_id = db.Column(None, db.ForeignKey('user.id'), nullable=True) + user_id = db.Column(None, db.ForeignKey('user.id'), nullable=False) user = db.relationship(User, primaryjoin=user_id == User.id, backref=db.backref('phones', cascade='all, delete-orphan')) - - org_id = db.Column(None, db.ForeignKey('organization.id'), nullable=True) - org = db.relationship(Organization, primaryjoin=org_id == Organization.id, - backref=db.backref('phones', cascade='all, delete-orphan')) - - team_id = db.Column(None, db.ForeignKey('team.id'), nullable=True) - team = db.relationship(Team, primaryjoin=team_id == Team.id, - backref=db.backref('phones', cascade='all, delete-orphan')) - _phone = db.Column('phone', db.Unicode(16), unique=True, nullable=False) gets_text = db.Column(db.Boolean, nullable=False, default=True) private = db.Column(db.Boolean, nullable=False, default=False) type = db.Column(db.Unicode(30), nullable=True) - __table_args__ = (db.CheckConstraint( - db.case([(user_id != None, 1)], else_=0) + - db.case([(org_id != None, 1)], else_=0) + - db.case([(team_id != None, 1)], else_=0) == 1, # NOQA - name='userphone_user_id_or_org_id_or_team_id'),) - def __init__(self, phone, **kwargs): super(UserPhone, self).__init__(**kwargs) self._phone = phone @@ -870,20 +793,11 @@ def get(cls, phone): return cls.query.filter_by(phone=phone).one_or_none() -class UserPhoneClaim(OwnerMixin, BaseMixin, db.Model): +class UserPhoneClaim(BaseMixin, db.Model): __tablename__ = 'userphoneclaim' - user_id = db.Column(None, db.ForeignKey('user.id'), nullable=True) + user_id = db.Column(None, db.ForeignKey('user.id'), nullable=False) user = db.relationship(User, primaryjoin=user_id == User.id, backref=db.backref('phoneclaims', cascade='all, delete-orphan')) - - org_id = db.Column(None, db.ForeignKey('organization.id'), nullable=True) - org = db.relationship(Organization, primaryjoin=org_id == Organization.id, - backref=db.backref('phoneclaims', cascade='all, delete-orphan')) - - team_id = db.Column(None, db.ForeignKey('team.id'), nullable=True) - team = db.relationship(Team, primaryjoin=team_id == Team.id, - backref=db.backref('phoneclaims', cascade='all, delete-orphan')) - _phone = db.Column('phone', db.Unicode(16), nullable=False, index=True) gets_text = db.Column(db.Boolean, nullable=False, default=True) verification_code = db.Column(db.Unicode(4), nullable=False, default=newpin) @@ -892,17 +806,7 @@ class UserPhoneClaim(OwnerMixin, BaseMixin, db.Model): private = db.Column(db.Boolean, nullable=False, default=False) type = db.Column(db.Unicode(30), nullable=True) - __table_args__ = ( - # Only one of these three unique constraints will apply as null values - # in the *_id columns are ignored for unique constraints - db.UniqueConstraint('user_id', 'phone'), - db.UniqueConstraint('org_id', 'phone'), - db.UniqueConstraint('team_id', 'phone'), - db.CheckConstraint( - db.case([(user_id != None, 1)], else_=0) + - db.case([(org_id != None, 1)], else_=0) + - db.case([(team_id != None, 1)], else_=0) == 1, # NOQA - name='userphoneclaim_user_id_or_org_id_or_team_id')) + __table_args__ = (db.UniqueConstraint('user_id', 'phone'),) def __init__(self, phone, **kwargs): super(UserPhoneClaim, self).__init__(**kwargs) diff --git a/lastuser_oauth/templates/emailverify.html.jinja2 b/lastuser_oauth/templates/emailverify.html.jinja2 index 44f54e64d..92006cc6d 100644 --- a/lastuser_oauth/templates/emailverify.html.jinja2 +++ b/lastuser_oauth/templates/emailverify.html.jinja2 @@ -11,6 +11,6 @@ -

Hello {{ useremail.owner.title }},

+

Hello {{ useremail.user.fullname }},

Click here to confirm your email address

If you did not sign up, you may safely ignore this email.

\ No newline at end of file diff --git a/migrations/versions/c446b9bc0691_remove_org_and_team_ownership_of_email_.py b/migrations/versions/c446b9bc0691_remove_org_and_team_ownership_of_email_.py new file mode 100644 index 000000000..0ce914762 --- /dev/null +++ b/migrations/versions/c446b9bc0691_remove_org_and_team_ownership_of_email_.py @@ -0,0 +1,93 @@ +"""Remove org and team ownership of email and phone + +Revision ID: c446b9bc0691 +Revises: f1185c3c4505 +Create Date: 2018-09-27 15:58:24.149115 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.sql import column + + +# revision identifiers, used by Alembic. +revision = 'c446b9bc0691' +down_revision = 'f1185c3c4505' +branch_labels = None +depends_on = None + + +def upgrade(): + op.alter_column('useremail', 'user_id', existing_type=sa.INTEGER(), nullable=False) + op.drop_constraint(u'useremail_team_id_fkey', 'useremail', type_='foreignkey') + op.drop_constraint(u'useremail_org_id_fkey', 'useremail', type_='foreignkey') + op.drop_column('useremail', 'team_id') + op.drop_column('useremail', 'org_id') + + op.alter_column('useremailclaim', 'user_id', existing_type=sa.INTEGER(), nullable=False) + op.drop_constraint(u'useremailclaim_org_id_email_key', 'useremailclaim', type_='unique') + op.drop_constraint(u'useremailclaim_team_id_email_key', 'useremailclaim', type_='unique') + op.drop_constraint(u'useremailclaim_team_id_fkey', 'useremailclaim', type_='foreignkey') + op.drop_constraint(u'useremailclaim_org_id_fkey', 'useremailclaim', type_='foreignkey') + op.drop_column('useremailclaim', 'team_id') + op.drop_column('useremailclaim', 'org_id') + + op.alter_column('userphone', 'user_id', existing_type=sa.INTEGER(), nullable=False) + op.drop_constraint(u'userphone_org_id_fkey', 'userphone', type_='foreignkey') + op.drop_constraint(u'userphone_team_id_fkey', 'userphone', type_='foreignkey') + op.drop_column('userphone', 'team_id') + op.drop_column('userphone', 'org_id') + + op.alter_column('userphoneclaim', 'user_id', existing_type=sa.INTEGER(), nullable=False) + op.drop_constraint(u'userphoneclaim_org_id_phone_key', 'userphoneclaim', type_='unique') + op.drop_constraint(u'userphoneclaim_team_id_phone_key', 'userphoneclaim', type_='unique') + op.drop_constraint(u'userphoneclaim_team_id_fkey', 'userphoneclaim', type_='foreignkey') + op.drop_constraint(u'userphoneclaim_org_id_fkey', 'userphoneclaim', type_='foreignkey') + op.drop_column('userphoneclaim', 'team_id') + op.drop_column('userphoneclaim', 'org_id') + + +def downgrade(): + op.add_column('userphoneclaim', sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('userphoneclaim', sa.Column('team_id', sa.INTEGER(), autoincrement=False, nullable=True)) + op.create_foreign_key(u'userphoneclaim_org_id_fkey', 'userphoneclaim', 'organization', ['org_id'], ['id']) + op.create_foreign_key(u'userphoneclaim_team_id_fkey', 'userphoneclaim', 'team', ['team_id'], ['id']) + op.create_unique_constraint(u'userphoneclaim_team_id_phone_key', 'userphoneclaim', ['team_id', 'phone']) + op.create_unique_constraint(u'userphoneclaim_org_id_phone_key', 'userphoneclaim', ['org_id', 'phone']) + op.alter_column('userphoneclaim', 'user_id', existing_type=sa.INTEGER(), nullable=True) + op.create_check_constraint('userphoneclaim_user_id_or_org_id_or_team_id', 'userphoneclaim', + sa.case([(column('user_id') != None, 1)], else_=0) + + sa.case([(column('org_id') != None, 1)], else_=0) + + sa.case([(column('team_id') != None, 1)], else_=0) == 1) # NOQA + + op.add_column('userphone', sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('userphone', sa.Column('team_id', sa.INTEGER(), autoincrement=False, nullable=True)) + op.create_foreign_key(u'userphone_team_id_fkey', 'userphone', 'team', ['team_id'], ['id']) + op.create_foreign_key(u'userphone_org_id_fkey', 'userphone', 'organization', ['org_id'], ['id']) + op.alter_column('userphone', 'user_id', existing_type=sa.INTEGER(), nullable=True) + op.create_check_constraint('userphone_user_id_or_org_id_or_team_id', 'userphone', + sa.case([(column('user_id') != None, 1)], else_=0) + + sa.case([(column('org_id') != None, 1)], else_=0) + + sa.case([(column('team_id') != None, 1)], else_=0) == 1) # NOQA + + op.add_column('useremailclaim', sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('useremailclaim', sa.Column('team_id', sa.INTEGER(), autoincrement=False, nullable=True)) + op.create_foreign_key(u'useremailclaim_org_id_fkey', 'useremailclaim', 'organization', ['org_id'], ['id']) + op.create_foreign_key(u'useremailclaim_team_id_fkey', 'useremailclaim', 'team', ['team_id'], ['id']) + op.create_unique_constraint(u'useremailclaim_team_id_email_key', 'useremailclaim', ['team_id', 'email']) + op.create_unique_constraint(u'useremailclaim_org_id_email_key', 'useremailclaim', ['org_id', 'email']) + op.alter_column('useremailclaim', 'user_id', existing_type=sa.INTEGER(), nullable=True) + op.create_check_constraint('useremailclaim_user_id_or_org_id_or_team_id', 'useremailclaim', + sa.case([(column('user_id') != None, 1)], else_=0) + + sa.case([(column('org_id') != None, 1)], else_=0) + + sa.case([(column('team_id') != None, 1)], else_=0) == 1) # NOQA + + op.add_column('useremail', sa.Column('org_id', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('useremail', sa.Column('team_id', sa.INTEGER(), autoincrement=False, nullable=True)) + op.create_foreign_key(u'useremail_org_id_fkey', 'useremail', 'organization', ['org_id'], ['id']) + op.create_foreign_key(u'useremail_team_id_fkey', 'useremail', 'team', ['team_id'], ['id']) + op.alter_column('useremail', 'user_id', existing_type=sa.INTEGER(), nullable=True) + op.create_check_constraint('useremail_user_id_or_org_id_or_team_id', 'useremail', + sa.case([(column('user_id') != None, 1)], else_=0) + + sa.case([(column('org_id') != None, 1)], else_=0) + + sa.case([(column('team_id') != None, 1)], else_=0) == 1) # NOQA diff --git a/tests/unit/lastuser_core/test_model_user_OwnerMixin.py b/tests/unit/lastuser_core/test_model_user_OwnerMixin.py deleted file mode 100644 index 0e7483925..000000000 --- a/tests/unit/lastuser_core/test_model_user_OwnerMixin.py +++ /dev/null @@ -1,42 +0,0 @@ -# -*- coding: utf-8 -*- - -import lastuser_core.models as models -from .test_db import TestDatabaseFixture - - -class TestUser(TestDatabaseFixture): - - def test_ownermixin_owner(self): - """Test to verify setting of owner property on any OwnerMixin inherited instance""" - crusoe = self.fixtures.crusoe - # scenario 1: check owner of existing UserEmail instance - crusoe_email = self.fixtures.crusoe_email - self.assertEqual(crusoe_email.owner, crusoe) - - # scenario 2: check owner when owner is org - client = self.fixtures.client - batdog = self.fixtures.batdog - dachshunds = self.fixtures.dachshunds - self.assertEqual(client.owner, batdog) - - # scenaio 3: check owner when new UserEmailClaim instance - spock = models.User(username=u'spock') - spock_email_claim = models.UserEmailClaim(email=u'spock@startrek.co.uk', user=spock) - self.assertEqual(spock_email_claim.owner, spock) - - # scenario 4: set user as owner on some OwnerMixin inherited instance - spock_phone = models.UserPhoneClaim(phone=u'+9112345678', user=spock) - spock_phone.owner = spock - self.assertEqual(spock_phone.owner, spock) - - # scenario 5: set organization as owner on some OwnerMixin inherited instance - spock_phone.owner = batdog - self.assertEqual(spock_phone.owner, batdog) - - # scenario 6: set Team as owner on some OwnerMixin inherited instance - spock_phone.owner = dachshunds - self.assertEqual(spock_phone.owner, dachshunds) - - # scenario 7: when owner not insance of User, organization or Team - with self.assertRaises(ValueError): - spock_phone.owner = client diff --git a/tests/unit/lastuser_core/test_model_user_UserEmailClaim.py b/tests/unit/lastuser_core/test_model_user_UserEmailClaim.py index 2c471dd0a..6fc6c0055 100644 --- a/tests/unit/lastuser_core/test_model_user_UserEmailClaim.py +++ b/tests/unit/lastuser_core/test_model_user_UserEmailClaim.py @@ -13,7 +13,7 @@ def test_UserEmailClaim(self): domain = u'batdogs.ca' new_email = u'crusoe@' + domain md5sum = md5(new_email).hexdigest() - result = models.UserEmailClaim(email=new_email, owner=crusoe) + result = models.UserEmailClaim(email=new_email, user=crusoe) db.session.add(result) db.session.commit() self.assertIsInstance(result, models.UserEmailClaim) @@ -28,7 +28,7 @@ def test_useremailclaim_permissions(self): """ crusoe = self.fixtures.crusoe email = u'crusoe@batdogs.ca' - email_claim = models.UserEmailClaim(email=email, owner=crusoe) + email_claim = models.UserEmailClaim(email=email, user=crusoe) permissions_expected = ['verify'] result = email_claim.permissions(crusoe) self.assertIsInstance(result, set) @@ -44,13 +44,13 @@ def test_UserEmailClaim_get(self): katnis = models.User(username=u'katnis', fullname=u'Katnis Everdeen') email = u'katnis@hungergames.org' - email_claim = models.UserEmailClaim(email=email, owner=katnis) + email_claim = models.UserEmailClaim(email=email, user=katnis) db.session.add(email_claim) db.session.commit() result = models.UserEmailClaim.get(email, katnis) self.assertIsInstance(result, models.UserEmailClaim) self.assertEqual(result.email, email) - self.assertEqual(result.owner, katnis) + self.assertEqual(result.user, katnis) def test_UserEmailClaim_all(self): """ @@ -59,8 +59,8 @@ def test_UserEmailClaim_all(self): gail = models.User(username=u'gail', fullname=u'Gail Hawthorne') peeta = models.User(username=u'peeta', fullname=u'Peeta Mallark') email = u'gail@district7.gov' - claim_by_gail = models.UserEmailClaim(email=email, owner=gail) - claim_by_peeta = models.UserEmailClaim(email=email, owner=peeta) + claim_by_gail = models.UserEmailClaim(email=email, user=gail) + claim_by_peeta = models.UserEmailClaim(email=email, user=peeta) db.session.add(claim_by_gail) db.session.add(claim_by_peeta) db.session.commit() @@ -74,6 +74,6 @@ def test_useremailclaim_email(self): """ effie = models.User(username=u'effie', fullname=u'Miss. Effie Trinket') email = u'effie@hungergames.org' - claim_by_effie = models.UserEmailClaim(email=email, owner=effie) + claim_by_effie = models.UserEmailClaim(email=email, user=effie) self.assertIsInstance(claim_by_effie.email, unicode) self.assertEqual(claim_by_effie.email, email) diff --git a/tests/unit/lastuser_core/test_model_user_UserPhone.py b/tests/unit/lastuser_core/test_model_user_UserPhone.py index 2cd8d4d6a..2c3dc658b 100644 --- a/tests/unit/lastuser_core/test_model_user_UserPhone.py +++ b/tests/unit/lastuser_core/test_model_user_UserPhone.py @@ -27,7 +27,7 @@ def test_UserPhone_get(self): phone = u'+8080808080' result = models.UserPhone.get(phone) self.assertIsInstance(result, models.UserPhone) - self.assertEqual(result.owner, crusoe) + self.assertEqual(result.user, crusoe) self.assertEqual(result.phone, phone) def test_UserPhone_unicode(self): diff --git a/tests/unit/lastuser_core/test_model_user_UserPhoneClaim.py b/tests/unit/lastuser_core/test_model_user_UserPhoneClaim.py index 71c6f2b63..647dd50c4 100644 --- a/tests/unit/lastuser_core/test_model_user_UserPhoneClaim.py +++ b/tests/unit/lastuser_core/test_model_user_UserPhoneClaim.py @@ -24,8 +24,8 @@ def test_UserPhoneClaim_all(self): crusoe = self.fixtures.crusoe oakley = self.fixtures.oakley phone = u'9191919191' - claim_by_crusoe = models.UserPhoneClaim(phone=phone, owner=crusoe) - claim_by_oakley = models.UserPhoneClaim(phone=phone, owner=oakley) + claim_by_crusoe = models.UserPhoneClaim(phone=phone, user=crusoe) + claim_by_oakley = models.UserPhoneClaim(phone=phone, user=oakley) db.session.add(claim_by_crusoe, claim_by_oakley) db.session.commit() result = models.UserPhoneClaim.all(phone) @@ -39,13 +39,13 @@ def test_UserPhoneClaim_get(self): """ snow = models.User(username=u'', fullname=u'President Coriolanus Snow') phone = u'9191919191' - phone_claim = models.UserPhoneClaim(phone=phone, owner=snow) + phone_claim = models.UserPhoneClaim(phone=phone, user=snow) db.session.add(phone_claim) db.session.commit() result = models.UserPhoneClaim.get(phone, snow) self.assertIsInstance(result, models.UserPhoneClaim) self.assertEqual(result.phone, phone) - self.assertEqual(result.owner, snow) + self.assertEqual(result.user, snow) def test_UserPhoneClaim_unicode(self): """ @@ -54,7 +54,7 @@ def test_UserPhoneClaim_unicode(self): """ haymitch = models.User(username=u'haymitch', fullname=u'Haymitch Abernathy') phone = u'9191919191' - phone_claim = models.UserPhoneClaim(phone=phone, owner=haymitch) + phone_claim = models.UserPhoneClaim(phone=phone, user=haymitch) db.session.add(phone_claim) db.session.commit() result = unicode(models.UserPhoneClaim(phone=phone)) @@ -68,7 +68,7 @@ def test_userphoneclaim_permissions(self): """ coin = models.User(username=u'coin', fullname=u'President Alma Coin') phone = u'9191919191' - phone_claim = models.UserPhoneClaim(phone=phone, owner=coin) + phone_claim = models.UserPhoneClaim(phone=phone, user=coin) permissions_expected = ['verify'] result = phone_claim.permissions(coin) self.assertIsInstance(result, set) diff --git a/tests/unit/lastuser_core/test_models.py b/tests/unit/lastuser_core/test_models.py index 644b6fdcb..e4385f559 100644 --- a/tests/unit/lastuser_core/test_models.py +++ b/tests/unit/lastuser_core/test_models.py @@ -68,7 +68,7 @@ def test_getuser(self): # scenario 3: with no @ starting in name, check by UserEmailClaim j_email = u'jonsnow@nightswatch.co.uk' jonsnow = models.User(username=u'jonsnow', fullname=u'Jon Snow') - jonsnow_email_claimed = models.UserEmailClaim(email=j_email, owner=jonsnow) + jonsnow_email_claimed = models.UserEmailClaim(email=j_email, user=jonsnow) db.session.add_all([jonsnow, jonsnow_email_claimed]) db.session.commit() result4 = models.getuser(j_email)