Renamed test and refactored fixtures

This commit is contained in:
Ken Tsang
2017-05-16 13:41:54 +01:00
parent 2a48891025
commit 3602431c2a

View File

@@ -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,