Add is_app_member() to user model
This commit is contained in:
parent
30018a061b
commit
c9deaeec72
@ -80,6 +80,9 @@ class User(
|
||||
def displayname(self):
|
||||
return self.full_name
|
||||
|
||||
def is_app_member(self, application):
|
||||
return self in application.users
|
||||
|
||||
def __repr__(self):
|
||||
return "<User(name='{}', dod_id='{}', email='{}', has_portfolios='{}', id='{}')>".format(
|
||||
self.full_name, self.dod_id, self.email, self.has_portfolios, self.id
|
||||
|
@ -26,6 +26,19 @@ def test_cannot_update_dod_id(session):
|
||||
session.commit()
|
||||
|
||||
|
||||
def test_is_app_member():
|
||||
user = UserFactory.create()
|
||||
app = ApplicationFactory.create()
|
||||
ApplicationRoleFactory.create(user=user, application=app)
|
||||
assert user.is_app_member(app)
|
||||
|
||||
|
||||
def test_is_not_app_member():
|
||||
user = UserFactory.create()
|
||||
app = ApplicationFactory.create()
|
||||
assert not user.is_app_member(app)
|
||||
|
||||
|
||||
def test_deleted_application_roles_are_ignored(session):
|
||||
user = UserFactory.create()
|
||||
app = ApplicationFactory.create()
|
||||
|
Loading…
x
Reference in New Issue
Block a user