diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index 2f4732473..93621668f 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -941,39 +941,39 @@ def test_add_unknown_user_to_service_returns404(notify_api, notify_db, notify_db assert result['message'] == expected_message -def test_remove_user_from_service(notify_api, notify_db, notify_db_session, sample_user_service_permission): - with notify_api.test_request_context(): - with notify_api.test_client() as client: - second_user = create_user(email="new@digital.cabinet-office.gov.uk") - # Simulates successfully adding a user to the service - second_permission = create_user_service_permission( - notify_db, - notify_db_session, - user=second_user) - 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 == 204 +def test_remove_user_from_service( + notify_db, notify_db_session, client, sample_user_service_permission +): + second_user = create_user(email="new@digital.cabinet-office.gov.uk") + # Simulates successfully adding a user to the service + second_permission = create_user_service_permission( + notify_db, + notify_db_session, + user=second_user) + 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 == 204 -def test_remove_user_from_service(notify_api, notify_db, notify_db_session, sample_user_service_permission): - with notify_api.test_request_context(): - with notify_api.test_client() as client: - second_user = create_user(email="new@digital.cabinet-office.gov.uk") - endpoint = url_for( - 'service.remove_user_from_service', - service_id=str(sample_user_service_permission.service.id), - user_id=str(second_user.id)) - auth_header = create_authorization_header() - resp = client.delete( - endpoint, - headers=[('Content-Type', 'application/json'), auth_header]) - assert resp.status_code == 404 +def test_remove_non_existant_user_from_service( + client, sample_user_service_permission +): + second_user = create_user(email="new@digital.cabinet-office.gov.uk") + endpoint = url_for( + 'service.remove_user_from_service', + service_id=str(sample_user_service_permission.service.id), + user_id=str(second_user.id)) + auth_header = create_authorization_header() + resp = client.delete( + endpoint, + headers=[('Content-Type', 'application/json'), auth_header]) + assert resp.status_code == 404 def test_cannot_remove_only_user_from_service(notify_api,