Skip to content

Commit

Permalink
got the 2nd test working
Browse files Browse the repository at this point in the history
  • Loading branch information
smcmurtry committed Feb 6, 2025
1 parent 3d5b4f4 commit 1c73741
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions tests/app/service/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,24 +1498,24 @@ def test_remove_user_from_service(notify_db, notify_db_session, client, sample_u
mocked_salesforce_client.engagement_delete_contact_role.assert_called_with(third_permission.service, third_permission.user)


def test_remove_user_from_service_only_user_with_manage_perm(notify_db, notify_db_session, client, sample_user_service_permission, mocker):
mocker.patch("app.service.rest.salesforce_client")
second_user = create_user(email="[email protected]")
third_user = create_user(email="[email protected]")
# Simulates successfully adding a user to the service
second_permission = create_sample_user_service_permission(notify_db, notify_db_session, user=second_user)
create_sample_user_service_permission(notify_db, notify_db_session, user=third_user, permission="view_activity")
assert len(second_permission.service.users) == 3
endpoint = url_for(
"service.remove_user_from_service",
service_id=str(second_permission.service.id),
user_id=str(second_permission.user.id),
)
auth_header = create_authorization_header()
resp = client.delete(endpoint, headers=[("Content-Type", "application/json"), auth_header])
assert resp.status_code == 400
result = resp.json
assert result["message"] == "SERVICE_NEEDS_USER_W_MANAGE_SETTINGS_PERM"
def test_remove_user_from_service_only_user_with_manage_perm(notify_api, notify_db, notify_db_session, client, sample_user_service_permission, mocker):
with notify_api.test_request_context():
with notify_api.test_client() as client:
manage_settings_user = sample_user_service_permission.user

Check notice

Code scanning / CodeQL

Unused local variable Note test

Variable manage_settings_user is not used.
second_user = create_user(email="[email protected]")
third_user = create_user(email="[email protected]")
create_sample_user_service_permission(notify_db, notify_db_session, user=second_user, permission="view_activity")
create_sample_user_service_permission(notify_db, notify_db_session, user=third_user, permission="view_activity")
endpoint = url_for(
"service.remove_user_from_service",
service_id=str(sample_user_service_permission.service.id),
user_id=str(sample_user_service_permission.user.id),
)
auth_header = create_authorization_header()
resp = client.delete(endpoint, headers=[("Content-Type", "application/json"), auth_header])
assert resp.status_code == 400
result = resp.json
assert result["message"] == "SERVICE_NEEDS_USER_W_MANAGE_SETTINGS_PERM"


def test_remove_non_existant_user_from_service(client, sample_user_service_permission):
Expand Down

0 comments on commit 1c73741

Please sign in to comment.