-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
18 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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): | ||
|