Add endpoint to allow org team members to be removed

This is similar to the corresponding endpoint for services. However,
it is a little simpler since we don't need to worry about always having
at least one team member for an organisation.

The new dao function added, `dao_remove_user_from_organisation`, is also
simpler than `dao_remove_user_from_service` since we don't have any
organisation permissions to deal with.
This commit is contained in:
Katie Smith
2022-01-05 13:30:52 +00:00
parent 081e0cab88
commit ed725c1513
3 changed files with 47 additions and 0 deletions

View File

@@ -694,6 +694,32 @@ def test_add_user_to_organisation_returns_404_if_user_does_not_exist(admin_reque
)
def test_remove_user_from_organisation(admin_request, sample_organisation, sample_user):
dao_add_user_to_organisation(organisation_id=sample_organisation.id, user_id=sample_user.id)
admin_request.delete(
'organisation.remove_user_from_organisation',
organisation_id=sample_organisation.id,
user_id=sample_user.id
)
assert sample_organisation.users == []
def test_remove_user_from_organisation_when_user_is_not_an_org_member(admin_request, sample_organisation, sample_user):
resp = admin_request.delete(
'organisation.remove_user_from_organisation',
organisation_id=sample_organisation.id,
user_id=sample_user.id,
_expected_status=404
)
assert resp == {
'result': 'error',
'message': 'User not found'
}
def test_get_organisation_users_returns_users_for_organisation(admin_request, sample_organisation):
first = create_user(email='first@invited.com')
second = create_user(email='another@invited.com')