Remove has_member function from application model
This commit is contained in:
parent
a99c795319
commit
94e3dc637a
@ -51,10 +51,6 @@ class Application(
|
||||
def displayname(self):
|
||||
return self.name
|
||||
|
||||
def has_member(self, user_id):
|
||||
user_ids = set(str(user.id) for user in self.users)
|
||||
return str(user_id) in user_ids
|
||||
|
||||
def __repr__(self): # pragma: no cover
|
||||
return "<Application(name='{}', description='{}', portfolio='{}', id='{}')>".format(
|
||||
self.name, self.description, self.portfolio.name, self.id
|
||||
|
@ -45,8 +45,9 @@ def serialize_env_member_form_data(application):
|
||||
|
||||
|
||||
def check_users_are_in_application(user_ids, application):
|
||||
existing_ids = [str(role.user_id) for role in application.roles]
|
||||
for user_id in user_ids:
|
||||
if not application.has_member(user_id):
|
||||
if not user_id in existing_ids:
|
||||
raise NotFoundError("application user", user_id)
|
||||
return True
|
||||
|
||||
|
@ -39,16 +39,3 @@ def test_audit_event_for_application_deletion(session):
|
||||
)
|
||||
assert update_event.changed_state.get("deleted")
|
||||
assert update_event.changed_state["deleted"] == [False, True]
|
||||
|
||||
|
||||
def test_has_app_member():
|
||||
user = UserFactory.create()
|
||||
app = ApplicationFactory.create()
|
||||
ApplicationRoleFactory.create(user=user, application=app)
|
||||
assert app.has_member(user.id)
|
||||
|
||||
|
||||
def test_does_not_have_app_member():
|
||||
user = UserFactory.create()
|
||||
app = ApplicationFactory.create()
|
||||
assert not app.has_member(user.id)
|
||||
|
@ -192,7 +192,7 @@ def test_check_users_are_in_application():
|
||||
for user in [app_user_1, app_user_2, app_user_3]:
|
||||
ApplicationRoleFactory.create(user=user, application=application)
|
||||
|
||||
user_ids = [app_user_1.id, app_user_2.id, app_user_3.id]
|
||||
user_ids = [str(app_user_1.id), str(app_user_2.id), str(app_user_3.id)]
|
||||
assert check_users_are_in_application(user_ids, application)
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user