mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
Renamed test and refactored fixtures
This commit is contained in:
@@ -941,39 +941,39 @@ def test_add_unknown_user_to_service_returns404(notify_api, notify_db, notify_db
|
|||||||
assert result['message'] == expected_message
|
assert result['message'] == expected_message
|
||||||
|
|
||||||
|
|
||||||
def test_remove_user_from_service(notify_api, notify_db, notify_db_session, sample_user_service_permission):
|
def test_remove_user_from_service(
|
||||||
with notify_api.test_request_context():
|
notify_db, notify_db_session, client, sample_user_service_permission
|
||||||
with notify_api.test_client() as client:
|
):
|
||||||
second_user = create_user(email="new@digital.cabinet-office.gov.uk")
|
second_user = create_user(email="new@digital.cabinet-office.gov.uk")
|
||||||
# Simulates successfully adding a user to the service
|
# Simulates successfully adding a user to the service
|
||||||
second_permission = create_user_service_permission(
|
second_permission = create_user_service_permission(
|
||||||
notify_db,
|
notify_db,
|
||||||
notify_db_session,
|
notify_db_session,
|
||||||
user=second_user)
|
user=second_user)
|
||||||
endpoint = url_for(
|
endpoint = url_for(
|
||||||
'service.remove_user_from_service',
|
'service.remove_user_from_service',
|
||||||
service_id=str(second_permission.service.id),
|
service_id=str(second_permission.service.id),
|
||||||
user_id=str(second_permission.user.id))
|
user_id=str(second_permission.user.id))
|
||||||
auth_header = create_authorization_header()
|
auth_header = create_authorization_header()
|
||||||
resp = client.delete(
|
resp = client.delete(
|
||||||
endpoint,
|
endpoint,
|
||||||
headers=[('Content-Type', 'application/json'), auth_header])
|
headers=[('Content-Type', 'application/json'), auth_header])
|
||||||
assert resp.status_code == 204
|
assert resp.status_code == 204
|
||||||
|
|
||||||
|
|
||||||
def test_remove_user_from_service(notify_api, notify_db, notify_db_session, sample_user_service_permission):
|
def test_remove_non_existant_user_from_service(
|
||||||
with notify_api.test_request_context():
|
client, sample_user_service_permission
|
||||||
with notify_api.test_client() as client:
|
):
|
||||||
second_user = create_user(email="new@digital.cabinet-office.gov.uk")
|
second_user = create_user(email="new@digital.cabinet-office.gov.uk")
|
||||||
endpoint = url_for(
|
endpoint = url_for(
|
||||||
'service.remove_user_from_service',
|
'service.remove_user_from_service',
|
||||||
service_id=str(sample_user_service_permission.service.id),
|
service_id=str(sample_user_service_permission.service.id),
|
||||||
user_id=str(second_user.id))
|
user_id=str(second_user.id))
|
||||||
auth_header = create_authorization_header()
|
auth_header = create_authorization_header()
|
||||||
resp = client.delete(
|
resp = client.delete(
|
||||||
endpoint,
|
endpoint,
|
||||||
headers=[('Content-Type', 'application/json'), auth_header])
|
headers=[('Content-Type', 'application/json'), auth_header])
|
||||||
assert resp.status_code == 404
|
assert resp.status_code == 404
|
||||||
|
|
||||||
|
|
||||||
def test_cannot_remove_only_user_from_service(notify_api,
|
def test_cannot_remove_only_user_from_service(notify_api,
|
||||||
|
|||||||
Reference in New Issue
Block a user