blunt rename of org (#620)

This commit is contained in:
Steven Reilly
2023-07-12 12:09:44 -04:00
committed by GitHub
parent 5fe81bc040
commit 13d0e46b52
107 changed files with 1471 additions and 1471 deletions

View File

@@ -2,7 +2,7 @@ from unittest.mock import ANY, call
import pytest
from app import organisations_client
from app import organizations_client
@pytest.mark.parametrize(
@@ -34,15 +34,15 @@ from app import organisations_client
'get_domains',
[
call('domains'),
call('organisations'),
call('organizations'),
],
None,
[
call(url='/organisations')
call(url='/organizations')
],
[
call(
'organisations',
'organizations',
'[{"domains": ["x", "y", "z"]}]',
ex=604800,
),
@@ -55,9 +55,9 @@ from app import organisations_client
'from api',
),
(
'get_organisations',
'get_organizations',
[
call('organisations'),
call('organizations'),
],
b"""
[
@@ -73,17 +73,17 @@ from app import organisations_client
],
),
(
'get_organisations',
'get_organizations',
[
call('organisations'),
call('organizations'),
],
None,
[
call(url='/organisations')
call(url='/organizations')
],
[
call(
'organisations',
'organizations',
'[{"domains": ["x", "y", "z"]}]',
ex=604800,
),
@@ -117,7 +117,7 @@ def test_returns_value_from_cache(
'app.extensions.RedisClient.set',
)
getattr(organisations_client, client_method)()
getattr(organizations_client, client_method)()
assert mock_redis_get.call_args_list == expected_cache_get_calls
assert mock_api_get.call_args_list == expected_api_calls
@@ -134,7 +134,7 @@ def test_deletes_domain_cache(
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_request = mocker.patch('notifications_python_client.base.BaseAPIClient.request')
organisations_client.update_organisation(fake_uuid, foo='bar')
organizations_client.update_organization(fake_uuid, foo='bar')
assert call('domains') in mock_redis_delete.call_args_list
assert len(mock_request.call_args_list) == 1
@@ -142,16 +142,16 @@ def test_deletes_domain_cache(
@pytest.mark.parametrize('post_data, expected_cache_delete_calls', (
({'foo': 'bar'}, [
call('organisations'),
call('organizations'),
call('domains'),
]),
({'name': 'new name'}, [
call('organisation-6ce466d0-fd6a-11e5-82f5-e0accb9d11a6-name'),
call('organisations'),
call('organization-6ce466d0-fd6a-11e5-82f5-e0accb9d11a6-name'),
call('organizations'),
call('domains'),
]),
))
def test_update_organisation_when_not_updating_org_type(
def test_update_organization_when_not_updating_org_type(
mocker,
fake_uuid,
post_data,
@@ -159,89 +159,89 @@ def test_update_organisation_when_not_updating_org_type(
):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post')
mock_post = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.post')
organisations_client.update_organisation(fake_uuid, **post_data)
organizations_client.update_organization(fake_uuid, **post_data)
mock_post.assert_called_with(
url='/organisations/{}'.format(fake_uuid),
url='/organizations/{}'.format(fake_uuid),
data=post_data
)
assert mock_redis_delete.call_args_list == expected_cache_delete_calls
def test_update_organisation_when_updating_org_type_and_org_has_services(mocker, fake_uuid):
def test_update_organization_when_updating_org_type_and_org_has_services(mocker, fake_uuid):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post')
mock_post = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.post')
organisations_client.update_organisation(
organizations_client.update_organization(
fake_uuid,
cached_service_ids=['a', 'b', 'c'],
organisation_type='central',
organization_type='central',
)
mock_post.assert_called_with(
url='/organisations/{}'.format(fake_uuid),
data={'organisation_type': 'central'}
url='/organizations/{}'.format(fake_uuid),
data={'organization_type': 'central'}
)
assert mock_redis_delete.call_args_list == [
call('service-a', 'service-b', 'service-c'),
call('organisations'),
call('organizations'),
call('domains'),
]
def test_update_organisation_when_updating_org_type_but_org_has_no_services(mocker, fake_uuid):
def test_update_organization_when_updating_org_type_but_org_has_no_services(mocker, fake_uuid):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post')
mock_post = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.post')
organisations_client.update_organisation(
organizations_client.update_organization(
fake_uuid,
cached_service_ids=[],
organisation_type='central',
organization_type='central',
)
mock_post.assert_called_with(
url='/organisations/{}'.format(fake_uuid),
data={'organisation_type': 'central'}
url='/organizations/{}'.format(fake_uuid),
data={'organization_type': 'central'}
)
assert mock_redis_delete.call_args_list == [
call('organisations'),
call('organizations'),
call('domains'),
]
def test_update_service_organisation_deletes_cache(mocker, fake_uuid):
def test_update_service_organization_deletes_cache(mocker, fake_uuid):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post')
mock_post = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.post')
organisations_client.update_service_organisation(
organizations_client.update_service_organization(
service_id=fake_uuid,
org_id=fake_uuid
)
assert sorted(mock_redis_delete.call_args_list) == [
call('live-service-and-organisation-counts'),
call('organisations'),
call('live-service-and-organization-counts'),
call('organizations'),
call('service-{}'.format(fake_uuid)),
]
mock_post.assert_called_with(
url='/organisations/{}/service'.format(fake_uuid),
url='/organizations/{}/service'.format(fake_uuid),
data=ANY
)
def test_remove_user_from_organisation_deletes_user_cache(mocker):
def test_remove_user_from_organization_deletes_user_cache(mocker):
mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete')
mock_delete = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.delete')
mock_delete = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.delete')
org_id = 'abcd-1234'
user_id = 'efgh-5678'
organisations_client.remove_user_from_organisation(
organizations_client.remove_user_from_organization(
org_id=org_id,
user_id=user_id,
)
assert mock_redis_delete.call_args_list == [call(f'user-{user_id}')]
mock_delete.assert_called_with(f'/organisations/{org_id}/users/{user_id}')
mock_delete.assert_called_with(f'/organizations/{org_id}/users/{user_id}')

View File

@@ -81,7 +81,7 @@ def test_client_creates_service_with_correct_data(
# service_name argument is coerced to name
name='My first service',
# The rest pass through with the same names
organisation_type='central_government',
organization_type='central_government',
message_limit=1,
restricted=True,
user_id=fake_uuid,
@@ -514,7 +514,7 @@ def test_client_updates_service_with_allowed_attributes(
'message_limit',
'name',
'notes',
'organisation_type',
'organization_type',
'permissions',
'prefix_sms',
'rate_limit',

View File

@@ -1,14 +1,14 @@
from app.notify_client.status_api_client import StatusApiClient
def test_get_count_of_live_services_and_organisations(mocker):
def test_get_count_of_live_services_and_organizations(mocker):
mocker.patch('app.extensions.RedisClient.get', return_value=None)
client = StatusApiClient()
mock = mocker.patch.object(client, 'get', return_value={})
client.get_count_of_live_services_and_organisations()
client.get_count_of_live_services_and_organizations()
mock.assert_called_once_with(url='/_status/live-service-and-organisation-counts')
mock.assert_called_once_with(url='/_status/live-service-and-organization-counts')
def test_sets_value_in_cache(mocker):
@@ -26,12 +26,12 @@ def test_sets_value_in_cache(mocker):
'app.extensions.RedisClient.set',
)
assert client.get_count_of_live_services_and_organisations() == {'data_from': 'api'}
assert client.get_count_of_live_services_and_organizations() == {'data_from': 'api'}
mock_redis_get.assert_called_once_with('live-service-and-organisation-counts')
mock_api_get.assert_called_once_with(url='/_status/live-service-and-organisation-counts')
mock_redis_get.assert_called_once_with('live-service-and-organization-counts')
mock_api_get.assert_called_once_with(url='/_status/live-service-and-organization-counts')
mock_redis_set.assert_called_once_with(
'live-service-and-organisation-counts',
'live-service-and-organization-counts',
'{"data_from": "api"}',
ex=3600
)
@@ -51,9 +51,9 @@ def test_returns_value_from_cache(mocker):
'app.extensions.RedisClient.set',
)
assert client.get_count_of_live_services_and_organisations() == {'data_from': 'cache'}
assert client.get_count_of_live_services_and_organizations() == {'data_from': 'cache'}
mock_redis_get.assert_called_once_with('live-service-and-organisation-counts')
mock_redis_get.assert_called_once_with('live-service-and-organization-counts')
assert mock_api_get.called is False
assert mock_redis_set.called is False

View File

@@ -192,7 +192,7 @@ def test_returns_value_from_cache(
(user_api_client, 'check_verify_code', [user_id, '', ''], {}),
(user_api_client, 'complete_webauthn_login_attempt', [user_id], {'is_successful': True}),
(user_api_client, 'add_user_to_service', [SERVICE_ONE_ID, user_id, [], []], {}),
(user_api_client, 'add_user_to_organisation', [sample_uuid(), user_id], {}),
(user_api_client, 'add_user_to_organization', [sample_uuid(), user_id], {}),
(user_api_client, 'set_user_permissions', [user_id, SERVICE_ONE_ID, []], {}),
(user_api_client, 'activate_user', [user_id], {}),
(user_api_client, 'archive_user', [user_id], {}),