mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-23 07:46:23 -04:00
blunt rename of org (#620)
This commit is contained in:
@@ -23,7 +23,7 @@ def test_should_raise_validation_error_for_password(
|
||||
|
||||
def test_valid_email_not_in_valid_domains(
|
||||
client_request,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
form = RegisterUserForm(email_address="test@test.com", mobile_number='2021231231')
|
||||
assert not form.validate()
|
||||
@@ -44,7 +44,7 @@ def test_valid_email_in_valid_domains(
|
||||
|
||||
def test_invalid_email_address_error_message(
|
||||
client_request,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
form = RegisterUserForm(
|
||||
name="test",
|
||||
|
||||
@@ -15,7 +15,7 @@ from tests.conftest import (
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
'user_services, user_organisations, expected_status, organisation_checked',
|
||||
'user_services, user_organizations, expected_status, organization_checked',
|
||||
(
|
||||
([SERVICE_ONE_ID], [], 200, False),
|
||||
([SERVICE_ONE_ID, SERVICE_TWO_ID], [], 200, False),
|
||||
@@ -41,15 +41,15 @@ def test_services_pages_that_org_users_are_allowed_to_see(
|
||||
mock_get_invites_for_service,
|
||||
mock_get_users_by_service,
|
||||
mock_get_template_folders,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
mock_has_jobs,
|
||||
user_services,
|
||||
user_organisations,
|
||||
user_organizations,
|
||||
expected_status,
|
||||
organisation_checked,
|
||||
organization_checked,
|
||||
):
|
||||
api_user_active['services'] = user_services
|
||||
api_user_active['organisations'] = user_organisations
|
||||
api_user_active['organizations'] = user_organizations
|
||||
api_user_active['permissions'] = {
|
||||
service_id: ['manage_users', 'manage_settings']
|
||||
for service_id in user_services
|
||||
@@ -58,7 +58,7 @@ def test_services_pages_that_org_users_are_allowed_to_see(
|
||||
name='SERVICE WITH ORG',
|
||||
id_=SERVICE_ONE_ID,
|
||||
users=[api_user_active['id']],
|
||||
organisation_id=ORGANISATION_ID,
|
||||
organization_id=ORGANISATION_ID,
|
||||
)
|
||||
|
||||
mock_get_service = mocker.patch(
|
||||
@@ -82,7 +82,7 @@ def test_services_pages_that_org_users_are_allowed_to_see(
|
||||
_expected_status=expected_status,
|
||||
)
|
||||
|
||||
assert mock_get_service.called is organisation_checked
|
||||
assert mock_get_service.called is organization_checked
|
||||
|
||||
|
||||
def test_service_navigation_for_org_user(
|
||||
@@ -96,13 +96,13 @@ def test_service_navigation_for_org_user(
|
||||
mock_get_service,
|
||||
mock_get_invites_for_service,
|
||||
mock_get_users_by_service,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
):
|
||||
api_user_active['services'] = []
|
||||
api_user_active['organisations'] = [ORGANISATION_ID]
|
||||
api_user_active['organizations'] = [ORGANISATION_ID]
|
||||
service = service_json(
|
||||
id_=SERVICE_ONE_ID,
|
||||
organisation_id=ORGANISATION_ID,
|
||||
organization_id=ORGANISATION_ID,
|
||||
)
|
||||
mocker.patch(
|
||||
'app.service_api_client.get_service',
|
||||
@@ -122,7 +122,7 @@ def test_service_navigation_for_org_user(
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('user_organisations, expected_menu_items, expected_status', [
|
||||
@pytest.mark.parametrize('user_organizations, expected_menu_items, expected_status', [
|
||||
(
|
||||
[],
|
||||
(
|
||||
@@ -155,19 +155,19 @@ def test_service_user_without_manage_service_permission_can_see_usage_page_when_
|
||||
mock_get_service,
|
||||
mock_get_invites_for_service,
|
||||
mock_get_users_by_service,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
mock_get_service_templates,
|
||||
mock_get_template_folders,
|
||||
mock_get_api_keys,
|
||||
user_organisations,
|
||||
user_organizations,
|
||||
expected_status,
|
||||
expected_menu_items,
|
||||
):
|
||||
active_caseworking_user['services'] = [SERVICE_ONE_ID]
|
||||
active_caseworking_user['organisations'] = user_organisations
|
||||
active_caseworking_user['organizations'] = user_organizations
|
||||
service = service_json(
|
||||
id_=SERVICE_ONE_ID,
|
||||
organisation_id=ORGANISATION_ID,
|
||||
organization_id=ORGANISATION_ID,
|
||||
)
|
||||
mocker.patch(
|
||||
'app.service_api_client.get_service',
|
||||
@@ -238,7 +238,7 @@ def test_code_to_extract_decorators_works_with_known_examples():
|
||||
get_routes_and_decorators(SERVICE_ID_ARGUMENT)
|
||||
)
|
||||
assert (
|
||||
'organisations.organisation_dashboard',
|
||||
'organizations.organization_dashboard',
|
||||
['main.route', 'user_has_permissions'],
|
||||
) in list(
|
||||
get_routes_and_decorators(ORGANISATION_ID_ARGUMENT)
|
||||
@@ -260,7 +260,7 @@ def test_routes_have_permissions_decorators():
|
||||
file, function = endpoint.split('.')
|
||||
|
||||
assert 'user_is_logged_in' not in decorators, (
|
||||
'@user_is_logged_in used on service or organisation specific endpoint\n'
|
||||
'@user_is_logged_in used on service or organization specific endpoint\n'
|
||||
'Use @user_has_permissions() or @user_is_platform_admin only\n'
|
||||
'app/main/views/{}.py::{}\n'
|
||||
).format(file, function)
|
||||
|
||||
@@ -38,7 +38,7 @@ def test_valid_list_of_white_list_email_domains(
|
||||
def test_invalid_list_of_white_list_email_domains(
|
||||
client_request,
|
||||
email,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
email_domain_validators = ValidGovEmail()
|
||||
with pytest.raises(ValidationError):
|
||||
|
||||
@@ -9,7 +9,7 @@ from tests.conftest import SERVICE_ONE_ID, SERVICE_TWO_ID, normalize_spaces
|
||||
OS1, OS2, OS3, S1, S2, S3 = repeat(uuid.uuid4(), 6)
|
||||
|
||||
SAMPLE_DATA = {
|
||||
'organisations': [
|
||||
'organizations': [
|
||||
{
|
||||
'name': 'org_1',
|
||||
'id': 'o1',
|
||||
@@ -31,37 +31,37 @@ SAMPLE_DATA = {
|
||||
'name': 'org_service_1',
|
||||
'id': OS1,
|
||||
'restricted': False,
|
||||
'organisation': 'o1',
|
||||
'organization': 'o1',
|
||||
},
|
||||
{
|
||||
'name': 'org_service_2',
|
||||
'id': OS2,
|
||||
'restricted': False,
|
||||
'organisation': 'o1',
|
||||
'organization': 'o1',
|
||||
},
|
||||
{
|
||||
'name': 'org_service_3',
|
||||
'id': OS3,
|
||||
'restricted': True,
|
||||
'organisation': 'o1',
|
||||
'organization': 'o1',
|
||||
},
|
||||
{
|
||||
'name': 'service_1',
|
||||
'id': S1,
|
||||
'restricted': False,
|
||||
'organisation': None,
|
||||
'organization': None,
|
||||
},
|
||||
{
|
||||
'name': 'service_2',
|
||||
'id': S2,
|
||||
'restricted': False,
|
||||
'organisation': None,
|
||||
'organization': None,
|
||||
},
|
||||
{
|
||||
'name': 'service_3',
|
||||
'id': S3,
|
||||
'restricted': True,
|
||||
'organisation': None,
|
||||
'organization': None,
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -70,15 +70,15 @@ SAMPLE_DATA = {
|
||||
@pytest.fixture
|
||||
def mock_get_orgs_and_services(mocker):
|
||||
return mocker.patch(
|
||||
'app.user_api_client.get_organisations_and_services_for_user',
|
||||
'app.user_api_client.get_organizations_and_services_for_user',
|
||||
return_value=SAMPLE_DATA
|
||||
)
|
||||
|
||||
|
||||
def test_choose_account_should_show_choose_accounts_page(
|
||||
client_request,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_organisation,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
mock_get_organization,
|
||||
):
|
||||
resp = client_request.get('main.choose_account')
|
||||
page = resp.find('main', {'id': 'main-content'})
|
||||
@@ -93,21 +93,21 @@ def test_choose_account_should_show_choose_accounts_page(
|
||||
|
||||
# first org
|
||||
assert outer_list_items[0].a.text == 'Org 1'
|
||||
assert outer_list_items[0].a['href'] == url_for('.organisation_dashboard', org_id='o1')
|
||||
assert outer_list_items[0].a['href'] == url_for('.organization_dashboard', org_id='o1')
|
||||
assert normalize_spaces(outer_list_items[0].select_one('.browse-list-hint').text) == (
|
||||
'1 live service'
|
||||
)
|
||||
|
||||
# second org
|
||||
assert outer_list_items[1].a.text == 'Org 2'
|
||||
assert outer_list_items[1].a['href'] == url_for('.organisation_dashboard', org_id='o2')
|
||||
assert outer_list_items[1].a['href'] == url_for('.organization_dashboard', org_id='o2')
|
||||
assert normalize_spaces(outer_list_items[1].select_one('.browse-list-hint').text) == (
|
||||
'2 live services'
|
||||
)
|
||||
|
||||
# third org
|
||||
assert outer_list_items[2].a.text == 'Org 3'
|
||||
assert outer_list_items[2].a['href'] == url_for('.organisation_dashboard', org_id='o3')
|
||||
assert outer_list_items[2].a['href'] == url_for('.organization_dashboard', org_id='o3')
|
||||
assert normalize_spaces(outer_list_items[2].select_one('.browse-list-hint').text) == (
|
||||
'0 live services'
|
||||
)
|
||||
@@ -134,17 +134,17 @@ def test_choose_account_should_show_choose_accounts_page(
|
||||
assert trial_services_list_items[1].a.text == 'service three'
|
||||
assert trial_services_list_items[1].a['href'] == url_for('.service_dashboard', service_id='abcde')
|
||||
|
||||
assert mock_get_organisation.call_args_list == []
|
||||
assert mock_get_organization.call_args_list == []
|
||||
|
||||
|
||||
def test_choose_account_should_show_choose_accounts_page_if_no_services(
|
||||
client_request,
|
||||
mock_get_orgs_and_services,
|
||||
mock_get_organisation,
|
||||
mock_get_organisation_services,
|
||||
mock_get_organization,
|
||||
mock_get_organization_services,
|
||||
):
|
||||
mock_get_orgs_and_services.return_value = {
|
||||
'organisations': [],
|
||||
'organizations': [],
|
||||
'services': []
|
||||
}
|
||||
resp = client_request.get('main.choose_account')
|
||||
@@ -161,7 +161,7 @@ def test_choose_account_should_show_choose_accounts_page_if_no_services(
|
||||
|
||||
@pytest.mark.parametrize('orgs_and_services, expected_headings', (
|
||||
({
|
||||
'organisations': [],
|
||||
'organizations': [],
|
||||
'services': []
|
||||
}, [
|
||||
'Platform admin',
|
||||
@@ -172,37 +172,37 @@ def test_choose_account_should_show_choose_accounts_page_if_no_services(
|
||||
'Trial mode services',
|
||||
]),
|
||||
({
|
||||
'organisations': [],
|
||||
'organizations': [],
|
||||
'services': [{
|
||||
'name': 'Live service',
|
||||
'id': OS2,
|
||||
'restricted': False,
|
||||
'organisation': None,
|
||||
'organization': None,
|
||||
}],
|
||||
}, [
|
||||
'Platform admin',
|
||||
'Live services',
|
||||
]),
|
||||
({
|
||||
'organisations': [],
|
||||
'organizations': [],
|
||||
'services': [{
|
||||
'name': 'Trial service',
|
||||
'id': OS2,
|
||||
'restricted': True,
|
||||
'organisation': None,
|
||||
'organization': None,
|
||||
}],
|
||||
}, [
|
||||
'Platform admin',
|
||||
'Trial mode services',
|
||||
]),
|
||||
))
|
||||
def test_choose_account_should_should_organisations_link_for_platform_admin(
|
||||
def test_choose_account_should_should_organizations_link_for_platform_admin(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
mock_get_orgs_and_services,
|
||||
mock_get_organisation_services,
|
||||
mock_get_service_and_organisation_counts,
|
||||
mock_get_organization_services,
|
||||
mock_get_service_and_organization_counts,
|
||||
orgs_and_services,
|
||||
expected_headings,
|
||||
):
|
||||
@@ -214,9 +214,9 @@ def test_choose_account_should_should_organisations_link_for_platform_admin(
|
||||
first_item = page.select_one('.browse-list-item')
|
||||
first_link = first_item.select_one('a')
|
||||
first_hint = first_item.select_one('.browse-list-hint')
|
||||
assert first_link.text == 'All organisations'
|
||||
assert first_link['href'] == url_for('main.organisations')
|
||||
assert normalize_spaces(first_hint.text) == '3 organisations, 9,999 live services'
|
||||
assert first_link.text == 'All organizations'
|
||||
assert first_link['href'] == url_for('main.organizations')
|
||||
assert normalize_spaces(first_hint.text) == '3 organizations, 9,999 live services'
|
||||
|
||||
assert [
|
||||
normalize_spaces(h2.text) for h2 in page.select('main h2')
|
||||
@@ -226,8 +226,8 @@ def test_choose_account_should_should_organisations_link_for_platform_admin(
|
||||
def test_choose_account_should_show_back_to_service_link(
|
||||
client_request,
|
||||
mock_get_orgs_and_services,
|
||||
mock_get_organisation,
|
||||
mock_get_organisation_services,
|
||||
mock_get_organization,
|
||||
mock_get_organization_services,
|
||||
):
|
||||
resp = client_request.get('main.choose_account')
|
||||
|
||||
@@ -241,8 +241,8 @@ def test_choose_account_should_show_back_to_service_link(
|
||||
def test_choose_account_should_not_show_back_to_service_link_if_no_service_in_session(
|
||||
client_request,
|
||||
mock_get_orgs_and_services,
|
||||
mock_get_organisation,
|
||||
mock_get_organisation_services,
|
||||
mock_get_organization,
|
||||
mock_get_organization_services,
|
||||
):
|
||||
with client_request.session_transaction() as session:
|
||||
session['service_id'] = None
|
||||
@@ -273,8 +273,8 @@ def test_choose_account_should_not_show_back_to_service_link_if_service_archived
|
||||
client_request,
|
||||
service_one,
|
||||
mock_get_orgs_and_services,
|
||||
mock_get_organisation,
|
||||
mock_get_organisation_services,
|
||||
mock_get_organization,
|
||||
mock_get_organization_services,
|
||||
active,
|
||||
):
|
||||
service_one['active'] = active
|
||||
|
||||
@@ -7,7 +7,7 @@ from tests import user_json
|
||||
def user_with_orgs_and_services(num_orgs, num_services, platform_admin=False):
|
||||
return user_json(
|
||||
name='leo',
|
||||
organisations=['org{}'.format(i) for i in range(1, num_orgs + 1)],
|
||||
organizations=['org{}'.format(i) for i in range(1, num_orgs + 1)],
|
||||
services=['service{}'.format(i) for i in range(1, num_services + 1)],
|
||||
platform_admin=platform_admin
|
||||
)
|
||||
@@ -17,18 +17,18 @@ def user_with_orgs_and_services(num_orgs, num_services, platform_admin=False):
|
||||
(0, 0, '.choose_account', {}),
|
||||
(0, 2, '.choose_account', {}),
|
||||
|
||||
# assumption is that live service is part of user’s organisation
|
||||
# assumption is that live service is part of user’s organization
|
||||
# – real users shouldn’t have orphaned live services, or access to
|
||||
# services belonging to other organisations
|
||||
(1, 1, '.organisation_dashboard', {'org_id': 'org1'}),
|
||||
# services belonging to other organizations
|
||||
(1, 1, '.organization_dashboard', {'org_id': 'org1'}),
|
||||
|
||||
(2, 0, '.choose_account', {}),
|
||||
(0, 1, '.service_dashboard', {'service_id': 'service1'}),
|
||||
(1, 0, '.organisation_dashboard', {'org_id': 'org1'}),
|
||||
(1, 0, '.organization_dashboard', {'org_id': 'org1'}),
|
||||
])
|
||||
def test_show_accounts_or_dashboard_redirects_to_choose_account_or_service_dashboard(
|
||||
client_request,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
num_orgs,
|
||||
num_services,
|
||||
endpoint,
|
||||
@@ -46,7 +46,7 @@ def test_show_accounts_or_dashboard_redirects_if_service_in_session(client_reque
|
||||
client_request.login(user_with_orgs_and_services(num_orgs=1, num_services=1))
|
||||
with client_request.session_transaction() as session:
|
||||
session['service_id'] = 'service1'
|
||||
session['organisation_id'] = None
|
||||
session['organization_id'] = None
|
||||
|
||||
client_request.get(
|
||||
'.show_accounts_or_dashboard',
|
||||
@@ -61,12 +61,12 @@ def test_show_accounts_or_dashboard_redirects_if_org_in_session(client_request):
|
||||
client_request.login(user_with_orgs_and_services(num_orgs=1, num_services=1))
|
||||
with client_request.session_transaction() as session:
|
||||
session['service_id'] = None
|
||||
session['organisation_id'] = 'org1'
|
||||
session['organization_id'] = 'org1'
|
||||
|
||||
client_request.get(
|
||||
'.show_accounts_or_dashboard',
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
'main.organization_dashboard',
|
||||
org_id='org1',
|
||||
),
|
||||
)
|
||||
@@ -74,32 +74,32 @@ def test_show_accounts_or_dashboard_redirects_if_org_in_session(client_request):
|
||||
|
||||
def test_show_accounts_or_dashboard_doesnt_redirect_to_service_dashboard_if_user_not_part_of_service_in_session(
|
||||
client_request,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
mock_get_service
|
||||
):
|
||||
client_request.login(user_with_orgs_and_services(num_orgs=1, num_services=1))
|
||||
with client_request.session_transaction() as session:
|
||||
session['service_id'] = 'service2'
|
||||
session['organisation_id'] = None
|
||||
session['organization_id'] = None
|
||||
|
||||
client_request.get(
|
||||
'.show_accounts_or_dashboard',
|
||||
_expected_redirect=url_for('main.organisation_dashboard', org_id='org1')
|
||||
_expected_redirect=url_for('main.organization_dashboard', org_id='org1')
|
||||
)
|
||||
|
||||
|
||||
def test_show_accounts_or_dashboard_doesnt_redirect_to_org_dashboard_if_user_not_part_of_org_in_session(
|
||||
client_request,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
):
|
||||
client_request.login(user_with_orgs_and_services(num_orgs=1, num_services=1))
|
||||
with client_request.session_transaction() as session:
|
||||
session['service_id'] = None
|
||||
session['organisation_id'] = 'org2'
|
||||
session['organization_id'] = 'org2'
|
||||
|
||||
client_request.get(
|
||||
'.show_accounts_or_dashboard',
|
||||
_expected_redirect=url_for('main.organisation_dashboard', org_id='org1')
|
||||
_expected_redirect=url_for('main.organization_dashboard', org_id='org1')
|
||||
)
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ def test_show_accounts_or_dashboard_redirects_to_service_dashboard_if_platform_a
|
||||
client_request.login(user_with_orgs_and_services(num_orgs=1, num_services=1, platform_admin=True))
|
||||
with client_request.session_transaction() as session:
|
||||
session['service_id'] = 'service2'
|
||||
session['organisation_id'] = None
|
||||
session['organization_id'] = None
|
||||
|
||||
client_request.get(
|
||||
'.show_accounts_or_dashboard',
|
||||
@@ -139,12 +139,12 @@ def test_show_accounts_or_dashboard_redirects_to_org_dashboard_if_platform_admin
|
||||
client_request.login(user_with_orgs_and_services(num_orgs=1, num_services=1, platform_admin=True))
|
||||
with client_request.session_transaction() as session:
|
||||
session['service_id'] = None
|
||||
session['organisation_id'] = 'org2'
|
||||
session['organization_id'] = 'org2'
|
||||
|
||||
client_request.get(
|
||||
'.show_accounts_or_dashboard',
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
'main.organization_dashboard',
|
||||
org_id='org2',
|
||||
),
|
||||
)
|
||||
|
||||
@@ -12,7 +12,7 @@ from tests.conftest import ORGANISATION_ID, normalize_spaces
|
||||
def test_invite_org_user(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
sample_org_invite,
|
||||
):
|
||||
|
||||
@@ -37,7 +37,7 @@ def test_invite_org_user(
|
||||
def test_invite_org_user_errors_when_same_email_as_inviter(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
sample_org_invite,
|
||||
):
|
||||
new_org_user_data = {
|
||||
@@ -62,10 +62,10 @@ def test_invite_org_user_errors_when_same_email_as_inviter(
|
||||
|
||||
def test_cancel_invited_org_user_cancels_user_invitations(
|
||||
client_request,
|
||||
mock_get_invites_for_organisation,
|
||||
mock_get_invites_for_organization,
|
||||
sample_org_invite,
|
||||
mock_get_organisation,
|
||||
mock_get_users_for_organisation,
|
||||
mock_get_organization,
|
||||
mock_get_users_for_organization,
|
||||
mocker,
|
||||
):
|
||||
mock_cancel = mocker.patch('app.org_invite_api_client.cancel_invited_user')
|
||||
@@ -108,7 +108,7 @@ def test_cancelled_invite_opened_by_user(
|
||||
client_request,
|
||||
api_user_active,
|
||||
mock_check_org_cancelled_invite_token,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
fake_uuid
|
||||
):
|
||||
client_request.logout()
|
||||
@@ -128,10 +128,10 @@ def test_cancelled_invite_opened_by_user(
|
||||
) == 'Test User decided to cancel this invitation.'
|
||||
assert normalize_spaces(
|
||||
page.select('main p')[1].text
|
||||
) == 'If you need access to Test organisation, you’ll have to ask them to invite you again.'
|
||||
) == 'If you need access to Test organization, you’ll have to ask them to invite you again.'
|
||||
|
||||
mock_get_user.assert_called_once_with(fake_uuid)
|
||||
mock_get_organisation.assert_called_once_with(ORGANISATION_ID)
|
||||
mock_get_organization.assert_called_once_with(ORGANISATION_ID)
|
||||
|
||||
|
||||
def test_user_invite_already_accepted(
|
||||
@@ -143,22 +143,22 @@ def test_user_invite_already_accepted(
|
||||
'main.accept_org_invite',
|
||||
token='thisisnotarealtoken',
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
'main.organization_dashboard',
|
||||
org_id=ORGANISATION_ID,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@freeze_time('2021-12-12 12:12:12')
|
||||
def test_existing_user_invite_already_is_member_of_organisation(
|
||||
def test_existing_user_invite_already_is_member_of_organization(
|
||||
client_request,
|
||||
mock_check_org_invite_token,
|
||||
mock_get_user,
|
||||
mock_get_user_by_email,
|
||||
api_user_active,
|
||||
mock_get_users_for_organisation,
|
||||
mock_get_users_for_organization,
|
||||
mock_accept_org_invite,
|
||||
mock_add_user_to_organisation,
|
||||
mock_add_user_to_organization,
|
||||
mock_update_user_attribute,
|
||||
):
|
||||
client_request.logout()
|
||||
@@ -167,7 +167,7 @@ def test_existing_user_invite_already_is_member_of_organisation(
|
||||
'main.accept_org_invite',
|
||||
token='thisisnotarealtoken',
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
'main.organization_dashboard',
|
||||
org_id=ORGANISATION_ID,
|
||||
),
|
||||
)
|
||||
@@ -175,7 +175,7 @@ def test_existing_user_invite_already_is_member_of_organisation(
|
||||
mock_check_org_invite_token.assert_called_once_with('thisisnotarealtoken')
|
||||
mock_accept_org_invite.assert_called_once_with(ORGANISATION_ID, ANY)
|
||||
mock_get_user_by_email.assert_called_once_with('invited_user@test.gsa.gov')
|
||||
mock_get_users_for_organisation.assert_called_once_with(ORGANISATION_ID)
|
||||
mock_get_users_for_organization.assert_called_once_with(ORGANISATION_ID)
|
||||
mock_update_user_attribute.assert_called_once_with(
|
||||
api_user_active['id'],
|
||||
email_access_validated_at='2021-12-12T12:12:12',
|
||||
@@ -183,14 +183,14 @@ def test_existing_user_invite_already_is_member_of_organisation(
|
||||
|
||||
|
||||
@freeze_time('2021-12-12 12:12:12')
|
||||
def test_existing_user_invite_not_a_member_of_organisation(
|
||||
def test_existing_user_invite_not_a_member_of_organization(
|
||||
client_request,
|
||||
api_user_active,
|
||||
mock_check_org_invite_token,
|
||||
mock_get_user_by_email,
|
||||
mock_get_users_for_organisation,
|
||||
mock_get_users_for_organization,
|
||||
mock_accept_org_invite,
|
||||
mock_add_user_to_organisation,
|
||||
mock_add_user_to_organization,
|
||||
mock_update_user_attribute,
|
||||
):
|
||||
client_request.logout()
|
||||
@@ -199,7 +199,7 @@ def test_existing_user_invite_not_a_member_of_organisation(
|
||||
'main.accept_org_invite',
|
||||
token='thisisnotarealtoken',
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
'main.organization_dashboard',
|
||||
org_id=ORGANISATION_ID,
|
||||
),
|
||||
)
|
||||
@@ -207,8 +207,8 @@ def test_existing_user_invite_not_a_member_of_organisation(
|
||||
mock_check_org_invite_token.assert_called_once_with('thisisnotarealtoken')
|
||||
mock_accept_org_invite.assert_called_once_with(ORGANISATION_ID, ANY)
|
||||
mock_get_user_by_email.assert_called_once_with('invited_user@test.gsa.gov')
|
||||
mock_get_users_for_organisation.assert_called_once_with(ORGANISATION_ID)
|
||||
mock_add_user_to_organisation.assert_called_once_with(
|
||||
mock_get_users_for_organization.assert_called_once_with(ORGANISATION_ID)
|
||||
mock_add_user_to_organization.assert_called_once_with(
|
||||
ORGANISATION_ID,
|
||||
api_user_active['id'],
|
||||
)
|
||||
@@ -222,7 +222,7 @@ def test_user_accepts_invite(
|
||||
client_request,
|
||||
mock_check_org_invite_token,
|
||||
mock_dont_get_user_by_email,
|
||||
mock_get_users_for_organisation,
|
||||
mock_get_users_for_organization,
|
||||
):
|
||||
client_request.logout()
|
||||
client_request.get(
|
||||
@@ -233,7 +233,7 @@ def test_user_accepts_invite(
|
||||
|
||||
mock_check_org_invite_token.assert_called_once_with('thisisnotarealtoken')
|
||||
mock_dont_get_user_by_email.assert_called_once_with('invited_user@test.gsa.gov')
|
||||
mock_get_users_for_organisation.assert_called_once_with(ORGANISATION_ID)
|
||||
mock_get_users_for_organization.assert_called_once_with(ORGANISATION_ID)
|
||||
|
||||
|
||||
def test_registration_from_org_invite_404s_if_user_not_in_session(
|
||||
@@ -281,10 +281,10 @@ def test_registration_from_org_invite_has_bad_data(
|
||||
|
||||
@pytest.mark.parametrize('diff_data', [
|
||||
['email_address'],
|
||||
['organisation'],
|
||||
['email_address', 'organisation']
|
||||
['organization'],
|
||||
['email_address', 'organization']
|
||||
])
|
||||
def test_registration_from_org_invite_has_different_email_or_organisation(
|
||||
def test_registration_from_org_invite_has_different_email_or_organization(
|
||||
client_request,
|
||||
sample_org_invite,
|
||||
diff_data,
|
||||
@@ -299,7 +299,7 @@ def test_registration_from_org_invite_has_different_email_or_organisation(
|
||||
'mobile_number': '+12024900460',
|
||||
'password': 'validPassword!',
|
||||
'email_address': sample_org_invite['email_address'],
|
||||
'organisation': sample_org_invite['organisation']
|
||||
'organization': sample_org_invite['organization']
|
||||
}
|
||||
for field in diff_data:
|
||||
data[field] = 'different'
|
||||
@@ -316,7 +316,7 @@ def test_org_user_registers_with_email_already_in_use(
|
||||
sample_org_invite,
|
||||
mock_get_user_by_email,
|
||||
mock_accept_org_invite,
|
||||
mock_add_user_to_organisation,
|
||||
mock_add_user_to_organization,
|
||||
mock_send_already_registered_email,
|
||||
mock_register_user,
|
||||
mock_get_invited_org_user_by_id,
|
||||
@@ -332,7 +332,7 @@ def test_org_user_registers_with_email_already_in_use(
|
||||
'mobile_number': '+12024900460',
|
||||
'password': 'validPassword!',
|
||||
'email_address': sample_org_invite['email_address'],
|
||||
'organisation': sample_org_invite['organisation'],
|
||||
'organization': sample_org_invite['organization'],
|
||||
},
|
||||
_expected_redirect=url_for('main.verify'),
|
||||
)
|
||||
@@ -353,7 +353,7 @@ def test_org_user_registration(
|
||||
mock_get_user_by_email,
|
||||
mock_send_verify_email,
|
||||
mock_accept_org_invite,
|
||||
mock_add_user_to_organisation,
|
||||
mock_add_user_to_organization,
|
||||
mock_get_invited_org_user_by_id,
|
||||
):
|
||||
client_request.logout()
|
||||
@@ -367,7 +367,7 @@ def test_org_user_registration(
|
||||
'email_address': sample_org_invite['email_address'],
|
||||
'mobile_number': '+12024900460',
|
||||
'password': 'validPassword!',
|
||||
'organisation': sample_org_invite['organisation'],
|
||||
'organization': sample_org_invite['organization'],
|
||||
},
|
||||
_expected_redirect=url_for('main.verify')
|
||||
)
|
||||
@@ -401,13 +401,13 @@ def test_verified_org_user_redirects_to_dashboard(
|
||||
with client_request.session_transaction() as session:
|
||||
session['expiry_date'] = str(datetime.utcnow() + timedelta(hours=1))
|
||||
session['user_details'] = {"email": invited_org_user['email_address'], "id": invited_org_user['id']}
|
||||
session['organisation_id'] = invited_org_user['organisation']
|
||||
session['organization_id'] = invited_org_user['organization']
|
||||
|
||||
client_request.post(
|
||||
'main.verify',
|
||||
_data={'sms_code': '123456'},
|
||||
_expected_redirect=url_for(
|
||||
'main.organisation_dashboard',
|
||||
org_id=invited_org_user['organisation'],
|
||||
'main.organization_dashboard',
|
||||
org_id=invited_org_user['organization'],
|
||||
),
|
||||
)
|
||||
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ from tests import sample_uuid
|
||||
from tests.conftest import ORGANISATION_ID, SERVICE_ONE_ID, normalize_spaces
|
||||
|
||||
|
||||
@pytest.mark.parametrize('organisation_type, expected_options', (
|
||||
@pytest.mark.parametrize('organization_type, expected_options', (
|
||||
('other', [
|
||||
('something_else', 'Something else'),
|
||||
]),
|
||||
@@ -20,11 +20,11 @@ def test_email_branding_request_page_when_no_branding_is_set(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_email_branding,
|
||||
organisation_type,
|
||||
organization_type,
|
||||
expected_options,
|
||||
):
|
||||
service_one['email_branding'] = None
|
||||
service_one['organisation_type'] = organisation_type
|
||||
service_one['organization_type'] = organization_type
|
||||
|
||||
mocker.patch(
|
||||
'app.models.service.Service.email_branding_id',
|
||||
@@ -57,7 +57,7 @@ def test_email_branding_request_page_shows_branding_if_set(
|
||||
service_one,
|
||||
client_request,
|
||||
mock_get_email_branding,
|
||||
mock_get_service_organisation,
|
||||
mock_get_service_organization,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.models.service.Service.email_branding_id',
|
||||
@@ -111,18 +111,18 @@ def test_email_branding_request_submit(
|
||||
service_one,
|
||||
mocker,
|
||||
mock_get_email_branding,
|
||||
organisation_one,
|
||||
organization_one,
|
||||
data,
|
||||
org_type,
|
||||
endpoint,
|
||||
):
|
||||
organisation_one['organisation_type'] = org_type
|
||||
organization_one['organization_type'] = org_type
|
||||
service_one['email_branding'] = sample_uuid()
|
||||
service_one['organisation'] = organisation_one
|
||||
service_one['organization'] = organization_one
|
||||
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_one,
|
||||
'app.organizations_client.get_organization',
|
||||
return_value=organization_one,
|
||||
)
|
||||
|
||||
client_request.post(
|
||||
@@ -160,17 +160,17 @@ def test_email_branding_description_pages_for_org_branding(
|
||||
client_request,
|
||||
mocker,
|
||||
service_one,
|
||||
organisation_one,
|
||||
organization_one,
|
||||
mock_get_email_branding,
|
||||
endpoint,
|
||||
expected_heading,
|
||||
):
|
||||
service_one['email_branding'] = sample_uuid()
|
||||
service_one['organisation'] = organisation_one
|
||||
service_one['organization'] = organization_one
|
||||
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_one,
|
||||
'app.organizations_client.get_organization',
|
||||
return_value=organization_one,
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
@@ -190,19 +190,19 @@ def test_email_branding_govuk_and_nhs_pages(
|
||||
client_request,
|
||||
mocker,
|
||||
service_one,
|
||||
organisation_one,
|
||||
organization_one,
|
||||
mock_get_email_branding,
|
||||
endpoint,
|
||||
service_org_type,
|
||||
branding_preview_id,
|
||||
):
|
||||
organisation_one['organisation_type'] = service_org_type
|
||||
organization_one['organization_type'] = service_org_type
|
||||
service_one['email_branding'] = sample_uuid()
|
||||
service_one['organisation'] = organisation_one
|
||||
service_one['organization'] = organization_one
|
||||
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_one,
|
||||
'app.organizations_client.get_organization',
|
||||
return_value=organization_one,
|
||||
)
|
||||
|
||||
page = client_request.get(
|
||||
@@ -219,7 +219,7 @@ def test_email_branding_govuk_and_nhs_pages(
|
||||
def test_email_branding_something_else_page(client_request, service_one):
|
||||
# expect to have a "NHS" option as well as the
|
||||
# fallback, so back button goes to choices page
|
||||
service_one['organisation_type'] = 'nhs_central'
|
||||
service_one['organization_type'] = 'nhs_central'
|
||||
|
||||
page = client_request.get(
|
||||
'main.email_branding_something_else',
|
||||
@@ -236,7 +236,7 @@ def test_email_branding_something_else_page(client_request, service_one):
|
||||
def test_get_email_branding_something_else_page_is_only_option(client_request, service_one):
|
||||
# should only have a "something else" option
|
||||
# so back button goes back to settings page
|
||||
service_one['organisation_type'] = 'other'
|
||||
service_one['organization_type'] = 'other'
|
||||
|
||||
page = client_request.get(
|
||||
'main.email_branding_something_else',
|
||||
@@ -250,7 +250,7 @@ def test_get_email_branding_something_else_page_is_only_option(client_request, s
|
||||
@pytest.mark.parametrize('endpoint', [
|
||||
('main.email_branding_govuk'),
|
||||
('main.email_branding_govuk_and_org'),
|
||||
('main.email_branding_organisation'),
|
||||
('main.email_branding_organization'),
|
||||
])
|
||||
def test_email_branding_pages_give_404_if_selected_branding_not_allowed(
|
||||
client_request,
|
||||
@@ -269,18 +269,18 @@ def test_email_branding_govuk_submit(
|
||||
mocker,
|
||||
client_request,
|
||||
service_one,
|
||||
organisation_one,
|
||||
organization_one,
|
||||
no_reply_to_email_addresses,
|
||||
mock_get_email_branding,
|
||||
single_sms_sender,
|
||||
mock_update_service,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_one,
|
||||
'app.organizations_client.get_organization',
|
||||
return_value=organization_one,
|
||||
)
|
||||
mocker.patch(
|
||||
'app.models.service.Service.organisation_id',
|
||||
'app.models.service.Service.organization_id',
|
||||
new_callable=PropertyMock,
|
||||
return_value=ORGANISATION_ID,
|
||||
)
|
||||
@@ -305,17 +305,17 @@ def test_email_branding_govuk_and_org_submit(
|
||||
mocker,
|
||||
client_request,
|
||||
service_one,
|
||||
organisation_one,
|
||||
organization_one,
|
||||
no_reply_to_email_addresses,
|
||||
mock_get_email_branding,
|
||||
single_sms_sender,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_one,
|
||||
'app.organizations_client.get_organization',
|
||||
return_value=organization_one,
|
||||
)
|
||||
mocker.patch(
|
||||
'app.models.service.Service.organisation_id',
|
||||
'app.models.service.Service.organization_id',
|
||||
new_callable=PropertyMock,
|
||||
return_value=ORGANISATION_ID,
|
||||
)
|
||||
@@ -336,13 +336,13 @@ def test_email_branding_govuk_and_org_submit(
|
||||
mock_create_ticket.assert_called_once_with(
|
||||
ANY,
|
||||
message='\n'.join([
|
||||
'Organisation: organisation one',
|
||||
'Organization: organization one',
|
||||
'Service: service one',
|
||||
'http://localhost/services/596364a0-858e-42c8-9062-a8fe822260eb',
|
||||
'',
|
||||
'---',
|
||||
'Current branding: Organisation name',
|
||||
'Branding requested: GOV.UK and organisation one\n',
|
||||
'Current branding: Organization name',
|
||||
'Branding requested: GOV.UK and organization one\n',
|
||||
]),
|
||||
subject='Email branding request - service one',
|
||||
ticket_type='question',
|
||||
@@ -360,21 +360,21 @@ def test_email_branding_govuk_and_org_submit(
|
||||
|
||||
|
||||
@pytest.mark.skip(reason='Update for TTS')
|
||||
def test_email_branding_organisation_submit(
|
||||
def test_email_branding_organization_submit(
|
||||
mocker,
|
||||
client_request,
|
||||
service_one,
|
||||
organisation_one,
|
||||
organization_one,
|
||||
no_reply_to_email_addresses,
|
||||
mock_get_email_branding,
|
||||
single_sms_sender,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_one,
|
||||
'app.organizations_client.get_organization',
|
||||
return_value=organization_one,
|
||||
)
|
||||
mocker.patch(
|
||||
'app.models.service.Service.organisation_id',
|
||||
'app.models.service.Service.organization_id',
|
||||
new_callable=PropertyMock,
|
||||
return_value=ORGANISATION_ID,
|
||||
)
|
||||
@@ -387,7 +387,7 @@ def test_email_branding_organisation_submit(
|
||||
)
|
||||
|
||||
page = client_request.post(
|
||||
'.email_branding_organisation',
|
||||
'.email_branding_organization',
|
||||
service_id=SERVICE_ONE_ID,
|
||||
_follow_redirects=True,
|
||||
)
|
||||
@@ -395,13 +395,13 @@ def test_email_branding_organisation_submit(
|
||||
mock_create_ticket.assert_called_once_with(
|
||||
ANY,
|
||||
message='\n'.join([
|
||||
'Organisation: organisation one',
|
||||
'Organization: organization one',
|
||||
'Service: service one',
|
||||
'http://localhost/services/596364a0-858e-42c8-9062-a8fe822260eb',
|
||||
'',
|
||||
'---',
|
||||
'Current branding: Organisation name',
|
||||
'Branding requested: organisation one\n',
|
||||
'Current branding: Organization name',
|
||||
'Branding requested: organization one\n',
|
||||
]),
|
||||
subject='Email branding request - service one',
|
||||
ticket_type='question',
|
||||
@@ -427,7 +427,7 @@ def test_email_branding_something_else_submit(
|
||||
single_sms_sender,
|
||||
):
|
||||
service_one['email_branding'] = sample_uuid()
|
||||
service_one['organisation_type'] = 'nhs_local'
|
||||
service_one['organization_type'] = 'nhs_local'
|
||||
|
||||
mock_create_ticket = mocker.spy(NotifySupportTicket, '__init__')
|
||||
mock_send_ticket_to_zendesk = mocker.patch(
|
||||
@@ -445,12 +445,12 @@ def test_email_branding_something_else_submit(
|
||||
mock_create_ticket.assert_called_once_with(
|
||||
ANY,
|
||||
message='\n'.join([
|
||||
'Organisation: Can’t tell (domain is user.gsa.gov)',
|
||||
'Organization: Can’t tell (domain is user.gsa.gov)',
|
||||
'Service: service one',
|
||||
'http://localhost/services/596364a0-858e-42c8-9062-a8fe822260eb',
|
||||
'',
|
||||
'---',
|
||||
'Current branding: Organisation name',
|
||||
'Current branding: Organization name',
|
||||
'Branding requested: Something else\n',
|
||||
'Homer Simpson\n'
|
||||
]),
|
||||
|
||||
@@ -13,7 +13,7 @@ def get_service_settings_page(
|
||||
platform_admin_user,
|
||||
service_one,
|
||||
mock_get_inbound_number_for_service,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
mock_get_free_sms_fragment_limit,
|
||||
no_reply_to_email_addresses,
|
||||
single_sms_sender,
|
||||
@@ -68,7 +68,7 @@ def test_service_set_permission(
|
||||
platform_admin_user,
|
||||
service_one,
|
||||
mock_get_inbound_number_for_service,
|
||||
mock_update_service_organisation,
|
||||
mock_update_service_organization,
|
||||
permission,
|
||||
initial_permissions,
|
||||
form_data,
|
||||
@@ -102,7 +102,7 @@ def test_service_set_permission(
|
||||
])
|
||||
def test_service_setting_toggles_show(
|
||||
mocker,
|
||||
mock_get_service_organisation,
|
||||
mock_get_service_organization,
|
||||
get_service_settings_page,
|
||||
service_one,
|
||||
service_fields,
|
||||
@@ -195,7 +195,7 @@ def test_normal_user_doesnt_see_any_platform_admin_settings(
|
||||
client_request,
|
||||
service_one,
|
||||
no_reply_to_email_addresses,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
single_sms_sender,
|
||||
mock_get_inbound_number_for_service,
|
||||
mock_get_free_sms_fragment_limit,
|
||||
|
||||
@@ -16,7 +16,7 @@ import app
|
||||
from tests import (
|
||||
find_element_by_tag_and_partial_text,
|
||||
invite_json,
|
||||
organisation_json,
|
||||
organization_json,
|
||||
sample_uuid,
|
||||
service_json,
|
||||
validate_route_permission,
|
||||
@@ -45,7 +45,7 @@ def mock_get_service_settings_page_common(
|
||||
mock_get_inbound_number_for_service,
|
||||
mock_get_free_sms_fragment_limit,
|
||||
mock_get_service_data_retention,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
):
|
||||
return
|
||||
|
||||
@@ -78,7 +78,7 @@ def mock_get_service_settings_page_common(
|
||||
'Count in list of live services Yes Change if service is counted in list of live services',
|
||||
'Billing details None Change billing details for service',
|
||||
'Notes None Change the notes for the service',
|
||||
'Organization Test organisation Federal government Change organization for service',
|
||||
'Organization Test organization Federal government Change organization for service',
|
||||
'Rate limit 3,000 per minute Change rate limit',
|
||||
'Message limit 1,000 per day Change daily message limit',
|
||||
'Free text message allowance 250,000 per year Change free text message allowance',
|
||||
@@ -102,7 +102,7 @@ def test_should_show_overview(
|
||||
SERVICE_ONE_ID,
|
||||
users=[api_user_active['id']],
|
||||
permissions=['sms', 'email'],
|
||||
organisation_id=ORGANISATION_ID,
|
||||
organization_id=ORGANISATION_ID,
|
||||
contact_link='contact_us@gsa.gov',
|
||||
)
|
||||
mocker.patch('app.service_api_client.get_service', return_value={'data': service_one})
|
||||
@@ -120,7 +120,7 @@ def test_should_show_overview(
|
||||
app.service_api_client.get_service.assert_called_with(SERVICE_ONE_ID)
|
||||
|
||||
|
||||
def test_no_go_live_link_for_service_without_organisation(
|
||||
def test_no_go_live_link_for_service_without_organization(
|
||||
client_request,
|
||||
mocker,
|
||||
no_reply_to_email_addresses,
|
||||
@@ -128,7 +128,7 @@ def test_no_go_live_link_for_service_without_organisation(
|
||||
platform_admin_user,
|
||||
mock_get_service_settings_page_common,
|
||||
):
|
||||
mocker.patch('app.organisations_client.get_organisation', return_value=None)
|
||||
mocker.patch('app.organizations_client.get_organization', return_value=None)
|
||||
client_request.login(platform_admin_user)
|
||||
page = client_request.get('main.service_settings', service_id=SERVICE_ONE_ID)
|
||||
|
||||
@@ -137,12 +137,12 @@ def test_no_go_live_link_for_service_without_organisation(
|
||||
is_live = find_element_by_tag_and_partial_text(page, tag='td', string='Live')
|
||||
assert normalize_spaces(is_live.find_next_sibling().text) == 'No (organization must be set first)'
|
||||
|
||||
organisation = find_element_by_tag_and_partial_text(page, tag='td', string='Organization')
|
||||
assert normalize_spaces(organisation.find_next_siblings()[0].text) == 'Not set Federal government'
|
||||
assert normalize_spaces(organisation.find_next_siblings()[1].text) == 'Change organization for service'
|
||||
organization = find_element_by_tag_and_partial_text(page, tag='td', string='Organization')
|
||||
assert normalize_spaces(organization.find_next_siblings()[0].text) == 'Not set Federal government'
|
||||
assert normalize_spaces(organization.find_next_siblings()[1].text) == 'Change organization for service'
|
||||
|
||||
|
||||
def test_organisation_name_links_to_org_dashboard(
|
||||
def test_organization_name_links_to_org_dashboard(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
no_reply_to_email_addresses,
|
||||
@@ -152,7 +152,7 @@ def test_organisation_name_links_to_org_dashboard(
|
||||
):
|
||||
service_one = service_json(SERVICE_ONE_ID,
|
||||
permissions=['sms', 'email'],
|
||||
organisation_id=ORGANISATION_ID)
|
||||
organization_id=ORGANISATION_ID)
|
||||
|
||||
mocker.patch('app.service_api_client.get_service', return_value={'data': service_one})
|
||||
|
||||
@@ -162,8 +162,8 @@ def test_organisation_name_links_to_org_dashboard(
|
||||
)
|
||||
|
||||
org_row = find_element_by_tag_and_partial_text(response, tag='tr', string='Organization')
|
||||
assert org_row.find('a')['href'] == url_for('main.organisation_dashboard', org_id=ORGANISATION_ID)
|
||||
assert normalize_spaces(org_row.find('a').text) == 'Test organisation'
|
||||
assert org_row.find('a')['href'] == url_for('main.organization_dashboard', org_id=ORGANISATION_ID)
|
||||
assert normalize_spaces(org_row.find('a').text) == 'Test organization'
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Email currently deactivated")
|
||||
@@ -184,7 +184,7 @@ def test_send_files_by_email_row_on_settings_page(
|
||||
service_one = service_json(
|
||||
SERVICE_ONE_ID,
|
||||
permissions=['sms', 'email'],
|
||||
organisation_id=ORGANISATION_ID,
|
||||
organization_id=ORGANISATION_ID,
|
||||
contact_link=service_contact_link
|
||||
)
|
||||
|
||||
@@ -267,17 +267,17 @@ def test_should_show_different_change_service_name_page_for_local_services(
|
||||
mocker,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
return_value=organisation_json(organisation_type='local'),
|
||||
'app.organizations_client.get_organization_by_domain',
|
||||
return_value=organization_json(organization_type='local'),
|
||||
)
|
||||
service_one['organisation_type'] = 'local'
|
||||
service_one['organization_type'] = 'local'
|
||||
page = client_request.get('main.service_name_change', service_id=SERVICE_ONE_ID)
|
||||
assert page.find('h1').text == 'Change your service name'
|
||||
assert page.find('input', attrs={"type": "text"})['value'] == 'service one'
|
||||
assert page.select_one('main .govuk-body').text.strip() == (
|
||||
'Your service name should tell users what the message is about as well as who it’s from. For example:'
|
||||
)
|
||||
# when no organisation on the service object, default org for the user is used for hint
|
||||
# when no organization on the service object, default org for the user is used for hint
|
||||
assert "School admissions - Test Org" in page.find_all("ul", class_="govuk-list govuk-list--bullet")[0].text
|
||||
|
||||
app.service_api_client.get_service.assert_called_with(SERVICE_ONE_ID)
|
||||
@@ -289,16 +289,16 @@ def test_should_show_service_org_in_hint_on_change_service_name_page_for_local_s
|
||||
mocker,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
return_value=organisation_json(organisation_type='local'),
|
||||
'app.organizations_client.get_organization_by_domain',
|
||||
return_value=organization_json(organization_type='local'),
|
||||
)
|
||||
mocker.patch('app.organisations_client.get_organisation', return_value=organisation_json(
|
||||
organisation_type='local', name="Local Authority")
|
||||
mocker.patch('app.organizations_client.get_organization', return_value=organization_json(
|
||||
organization_type='local', name="Local Authority")
|
||||
)
|
||||
service_one['organisation_type'] = 'local'
|
||||
service_one['organisation'] = '1234'
|
||||
service_one['organization_type'] = 'local'
|
||||
service_one['organization'] = '1234'
|
||||
page = client_request.get('main.service_name_change', service_id=SERVICE_ONE_ID)
|
||||
# when there is organisation on the service object, it is used for hint text instead of user default org
|
||||
# when there is organization on the service object, it is used for hint text instead of user default org
|
||||
assert "School admissions - Local Authority" in page.find_all("ul", class_="govuk-list govuk-list--bullet")[0].text
|
||||
|
||||
|
||||
@@ -555,7 +555,7 @@ def test_should_check_if_estimated_volumes_provided(
|
||||
single_reply_to_email_address,
|
||||
mock_get_service_templates,
|
||||
mock_get_users_by_service,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
mock_get_invites_for_service,
|
||||
volumes,
|
||||
consent_to_research,
|
||||
@@ -789,7 +789,7 @@ def test_should_not_show_go_live_button_if_checklist_not_complete(
|
||||
mocker,
|
||||
mock_get_service_templates,
|
||||
mock_get_users_by_service,
|
||||
mock_get_service_organisation,
|
||||
mock_get_service_organization,
|
||||
mock_get_invites_for_service,
|
||||
single_sms_sender,
|
||||
checklist_completed,
|
||||
@@ -857,7 +857,7 @@ def test_request_to_go_live_redirects_if_service_already_live(
|
||||
|
||||
@pytest.mark.parametrize((
|
||||
'estimated_sms_volume,'
|
||||
'organisation_type,'
|
||||
'organization_type,'
|
||||
'count_of_sms_templates,'
|
||||
'sms_senders,'
|
||||
'expected_sms_sender_checklist_item'
|
||||
@@ -919,15 +919,15 @@ def test_should_check_for_sms_sender_on_go_live(
|
||||
client_request,
|
||||
service_one,
|
||||
mocker,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
mock_get_invites_for_service,
|
||||
organisation_type,
|
||||
organization_type,
|
||||
count_of_sms_templates,
|
||||
sms_senders,
|
||||
expected_sms_sender_checklist_item,
|
||||
estimated_sms_volume,
|
||||
):
|
||||
service_one['organisation_type'] = organisation_type
|
||||
service_one['organization_type'] = organization_type
|
||||
|
||||
mocker.patch(
|
||||
'app.service_api_client.get_service_templates',
|
||||
@@ -972,8 +972,8 @@ def test_non_gov_user_is_told_they_cant_go_live(
|
||||
api_nongov_user_active,
|
||||
mock_get_invites_for_service,
|
||||
mocker,
|
||||
mock_get_organisations,
|
||||
mock_get_organisation,
|
||||
mock_get_organizations,
|
||||
mock_get_organization,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.models.service.Service.has_team_members',
|
||||
@@ -1190,7 +1190,7 @@ def test_should_not_default_to_zero_if_some_fields_dont_validate(
|
||||
def test_non_gov_users_cant_request_to_go_live(
|
||||
client_request,
|
||||
api_nongov_user_active,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
client_request.login(api_nongov_user_active)
|
||||
client_request.post(
|
||||
@@ -1224,7 +1224,7 @@ def test_should_redirect_after_request_to_go_live(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
single_reply_to_email_address,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
single_sms_sender,
|
||||
mock_get_service_settings_page_common,
|
||||
mock_get_service_templates,
|
||||
@@ -1258,7 +1258,7 @@ def test_should_redirect_after_request_to_go_live(
|
||||
'http://localhost/services/{service_id}\n'
|
||||
'\n'
|
||||
'---\n'
|
||||
'Organisation type: Federal government (domain is user.gsa.gov).\n'
|
||||
'Organization type: Federal government (domain is user.gsa.gov).\n'
|
||||
'\n'
|
||||
'{formatted_displayed_volumes}'
|
||||
'\n'
|
||||
@@ -1306,9 +1306,9 @@ def test_request_to_go_live_displays_go_live_notes_in_zendesk_ticket(
|
||||
mocker,
|
||||
active_user_with_permissions,
|
||||
single_reply_to_email_address,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
single_sms_sender,
|
||||
mock_get_service_organisation,
|
||||
mock_get_service_organization,
|
||||
mock_get_service_settings_page_common,
|
||||
mock_get_service_templates,
|
||||
mock_get_users_by_service,
|
||||
@@ -1318,8 +1318,8 @@ def test_request_to_go_live_displays_go_live_notes_in_zendesk_ticket(
|
||||
go_live_note = 'This service is not allowed to go live'
|
||||
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
side_effect=lambda org_id: organisation_json(
|
||||
'app.organizations_client.get_organization',
|
||||
side_effect=lambda org_id: organization_json(
|
||||
ORGANISATION_ID,
|
||||
'Org 1',
|
||||
request_to_go_live_notes=go_live_note,
|
||||
@@ -1341,7 +1341,7 @@ def test_request_to_go_live_displays_go_live_notes_in_zendesk_ticket(
|
||||
'http://localhost/services/{service_id}\n'
|
||||
'\n'
|
||||
'---\n'
|
||||
'Organisation type: Federal government (organisation is Org 1). {go_live_note}\n'
|
||||
'Organization type: Federal government (organization is Org 1). {go_live_note}\n'
|
||||
'\n'
|
||||
'Emails in next year: 111,111\n'
|
||||
'Text messages in next year: 222,222\n'
|
||||
@@ -1381,9 +1381,9 @@ def test_request_to_go_live_displays_mou_signatories(
|
||||
fake_uuid,
|
||||
active_user_with_permissions,
|
||||
single_reply_to_email_address,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
single_sms_sender,
|
||||
mock_get_service_organisation,
|
||||
mock_get_service_organization,
|
||||
mock_get_service_settings_page_common,
|
||||
mock_get_service_templates,
|
||||
mock_get_users_by_service,
|
||||
@@ -1391,8 +1391,8 @@ def test_request_to_go_live_displays_mou_signatories(
|
||||
mock_get_invites_without_manage_permission,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
side_effect=lambda org_id: organisation_json(
|
||||
'app.organizations_client.get_organization',
|
||||
side_effect=lambda org_id: organization_json(
|
||||
ORGANISATION_ID,
|
||||
'Org 1',
|
||||
agreement_signed=True,
|
||||
@@ -1412,7 +1412,7 @@ def test_request_to_go_live_displays_mou_signatories(
|
||||
)
|
||||
|
||||
assert (
|
||||
'Organisation type: Federal government'
|
||||
'Organization type: Federal government'
|
||||
) in mock_create_ticket.call_args[1]['message']
|
||||
|
||||
assert (
|
||||
@@ -1420,11 +1420,11 @@ def test_request_to_go_live_displays_mou_signatories(
|
||||
) in mock_create_ticket.call_args[1]['message']
|
||||
|
||||
|
||||
def test_should_be_able_to_request_to_go_live_with_no_organisation(
|
||||
def test_should_be_able_to_request_to_go_live_with_no_organization(
|
||||
client_request,
|
||||
mocker,
|
||||
single_reply_to_email_address,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
single_sms_sender,
|
||||
mock_get_service_settings_page_common,
|
||||
mock_get_service_templates,
|
||||
@@ -1557,7 +1557,7 @@ def test_should_be_able_to_request_to_go_live_with_no_organisation(
|
||||
def test_ready_to_go_live(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_service_organisation,
|
||||
mock_get_service_organization,
|
||||
has_team_members,
|
||||
has_templates,
|
||||
has_email_templates,
|
||||
@@ -1571,8 +1571,8 @@ def test_ready_to_go_live(
|
||||
agreement_signed,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
return_value=organisation_json(agreement_signed=agreement_signed)
|
||||
'app.organizations_client.get_organization',
|
||||
return_value=organization_json(agreement_signed=agreement_signed)
|
||||
)
|
||||
|
||||
for prop in {
|
||||
@@ -1732,7 +1732,7 @@ def test_and_more_hint_appears_on_settings_with_more_than_just_a_single_sender(
|
||||
def test_api_ids_dont_show_on_option_pages_with_a_single_sender(
|
||||
client_request,
|
||||
single_reply_to_email_address,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
single_sms_sender,
|
||||
sender_list_page,
|
||||
index,
|
||||
@@ -2683,7 +2683,7 @@ def test_does_not_show_research_mode_indicator(
|
||||
{'service_id': SERVICE_ONE_ID},
|
||||
),
|
||||
(
|
||||
'main.edit_organisation_email_branding',
|
||||
'main.edit_organization_email_branding',
|
||||
{'org_id': ORGANISATION_ID},
|
||||
),
|
||||
))
|
||||
@@ -2701,8 +2701,8 @@ def test_should_show_branding_styles(
|
||||
):
|
||||
service_one['email_branding'] = current_branding
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation',
|
||||
side_effect=lambda org_id: organisation_json(
|
||||
'app.organizations_client.get_organization',
|
||||
side_effect=lambda org_id: organization_json(
|
||||
org_id,
|
||||
'Org 1',
|
||||
email_branding_id=current_branding,
|
||||
@@ -2744,16 +2744,16 @@ def test_should_show_branding_styles(
|
||||
'main.service_preview_email_branding',
|
||||
),
|
||||
(
|
||||
'main.edit_organisation_email_branding',
|
||||
'main.edit_organization_email_branding',
|
||||
{'org_id': ORGANISATION_ID},
|
||||
'main.organisation_preview_email_branding',
|
||||
'main.organization_preview_email_branding',
|
||||
),
|
||||
))
|
||||
def test_should_send_branding_and_organisations_to_preview(
|
||||
def test_should_send_branding_and_organizations_to_preview(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
service_one,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
mock_get_all_email_branding,
|
||||
mock_update_service,
|
||||
endpoint,
|
||||
@@ -2785,14 +2785,14 @@ def test_should_send_branding_and_organisations_to_preview(
|
||||
{'service_id': SERVICE_ONE_ID},
|
||||
),
|
||||
(
|
||||
'main.organisation_preview_email_branding',
|
||||
'main.organization_preview_email_branding',
|
||||
{'org_id': ORGANISATION_ID},
|
||||
),
|
||||
))
|
||||
def test_should_preview_email_branding(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
endpoint,
|
||||
extra_args,
|
||||
):
|
||||
@@ -2825,19 +2825,19 @@ def test_should_preview_email_branding(
|
||||
'main.service_settings',
|
||||
),
|
||||
(
|
||||
'main.organisation_preview_email_branding',
|
||||
'main.organization_preview_email_branding',
|
||||
{'org_id': ORGANISATION_ID},
|
||||
'main.organisation_settings',
|
||||
'main.organization_settings',
|
||||
),
|
||||
))
|
||||
def test_should_set_branding_and_organisations(
|
||||
def test_should_set_branding_and_organizations(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
service_one,
|
||||
mock_get_organisation,
|
||||
mock_get_organisation_services,
|
||||
mock_get_organization,
|
||||
mock_get_organization_services,
|
||||
mock_update_service,
|
||||
mock_update_organisation,
|
||||
mock_update_organization,
|
||||
posted_value,
|
||||
submitted_value,
|
||||
endpoint,
|
||||
@@ -2863,9 +2863,9 @@ def test_should_set_branding_and_organisations(
|
||||
SERVICE_ONE_ID,
|
||||
email_branding=submitted_value,
|
||||
)
|
||||
assert mock_update_organisation.called is False
|
||||
elif endpoint == 'main.organisation_preview_email_branding':
|
||||
mock_update_organisation.assert_called_once_with(
|
||||
assert mock_update_organization.called is False
|
||||
elif endpoint == 'main.organization_preview_email_branding':
|
||||
mock_update_organization.assert_called_once_with(
|
||||
ORGANISATION_ID,
|
||||
email_branding_id=submitted_value,
|
||||
cached_service_ids=[
|
||||
@@ -2885,7 +2885,7 @@ def test_should_set_branding_and_organisations(
|
||||
'main.set_message_limit',
|
||||
'main.set_rate_limit',
|
||||
])
|
||||
def test_organisation_type_pages_are_platform_admin_only(
|
||||
def test_organization_type_pages_are_platform_admin_only(
|
||||
client_request,
|
||||
method,
|
||||
endpoint,
|
||||
@@ -3197,9 +3197,9 @@ def test_switch_service_enable_international_sms(
|
||||
def test_archive_service_after_confirm(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_organisations,
|
||||
mock_get_service_and_organisation_counts,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations,
|
||||
mock_get_service_and_organization_counts,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
mock_get_users_by_service,
|
||||
mock_get_service_templates,
|
||||
service_one,
|
||||
@@ -3237,9 +3237,9 @@ def test_archive_service_after_confirm(
|
||||
def test_archive_service_after_confirm_error(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_organisations,
|
||||
mock_get_service_and_organisation_counts,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations,
|
||||
mock_get_service_and_organization_counts,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
mock_get_users_by_service,
|
||||
mock_get_service_templates,
|
||||
service_one,
|
||||
@@ -3700,7 +3700,7 @@ def test_service_settings_when_inbound_number_is_not_set(
|
||||
client_request,
|
||||
service_one,
|
||||
single_reply_to_email_address,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
single_sms_sender,
|
||||
mocker,
|
||||
mock_get_free_sms_fragment_limit,
|
||||
@@ -3809,16 +3809,16 @@ def test_updates_sms_prefixing(
|
||||
)
|
||||
|
||||
|
||||
def test_select_organisation(
|
||||
def test_select_organization(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
service_one,
|
||||
mock_get_organisation,
|
||||
mock_get_organisations
|
||||
mock_get_organization,
|
||||
mock_get_organizations
|
||||
):
|
||||
client_request.login(platform_admin_user)
|
||||
page = client_request.get(
|
||||
'.link_service_to_organisation',
|
||||
'.link_service_to_organization',
|
||||
service_id=service_one['id'],
|
||||
)
|
||||
|
||||
@@ -3829,18 +3829,18 @@ def test_select_organisation(
|
||||
) == 'Org {}'.format(i + 1)
|
||||
|
||||
|
||||
def test_select_organisation_shows_message_if_no_orgs(
|
||||
def test_select_organization_shows_message_if_no_orgs(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
service_one,
|
||||
mock_get_organisation,
|
||||
mock_get_organization,
|
||||
mocker
|
||||
):
|
||||
mocker.patch('app.organisations_client.get_organisations', return_value=[])
|
||||
mocker.patch('app.organizations_client.get_organizations', return_value=[])
|
||||
|
||||
client_request.login(platform_admin_user)
|
||||
page = client_request.get(
|
||||
'.link_service_to_organisation',
|
||||
'.link_service_to_organization',
|
||||
service_id=service_one['id'],
|
||||
)
|
||||
|
||||
@@ -3848,43 +3848,43 @@ def test_select_organisation_shows_message_if_no_orgs(
|
||||
assert not page.select_one('main button')
|
||||
|
||||
|
||||
def test_update_service_organisation(
|
||||
def test_update_service_organization(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
service_one,
|
||||
mock_get_organisation,
|
||||
mock_get_organisations,
|
||||
mock_update_service_organisation,
|
||||
mock_get_organization,
|
||||
mock_get_organizations,
|
||||
mock_update_service_organization,
|
||||
):
|
||||
client_request.login(platform_admin_user)
|
||||
client_request.post(
|
||||
'.link_service_to_organisation',
|
||||
'.link_service_to_organization',
|
||||
service_id=service_one['id'],
|
||||
_data={'organisations': '7aa5d4e9-4385-4488-a489-07812ba13384'},
|
||||
_data={'organizations': '7aa5d4e9-4385-4488-a489-07812ba13384'},
|
||||
)
|
||||
mock_update_service_organisation.assert_called_once_with(
|
||||
mock_update_service_organization.assert_called_once_with(
|
||||
service_one['id'],
|
||||
'7aa5d4e9-4385-4488-a489-07812ba13384'
|
||||
)
|
||||
|
||||
|
||||
def test_update_service_organisation_does_not_update_if_same_value(
|
||||
def test_update_service_organization_does_not_update_if_same_value(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
service_one,
|
||||
mock_get_organisation,
|
||||
mock_get_organisations,
|
||||
mock_update_service_organisation,
|
||||
mock_get_organization,
|
||||
mock_get_organizations,
|
||||
mock_update_service_organization,
|
||||
):
|
||||
org_id = "7aa5d4e9-4385-4488-a489-07812ba13383"
|
||||
service_one['organisation'] = org_id
|
||||
service_one['organization'] = org_id
|
||||
client_request.login(platform_admin_user)
|
||||
client_request.post(
|
||||
'.link_service_to_organisation',
|
||||
'.link_service_to_organization',
|
||||
service_id=service_one['id'],
|
||||
_data={'organisations': org_id},
|
||||
_data={'organizations': org_id},
|
||||
)
|
||||
assert mock_update_service_organisation.called is False
|
||||
assert mock_update_service_organization.called is False
|
||||
|
||||
|
||||
@pytest.mark.skip(reason="Email currently deactivated")
|
||||
@@ -3902,7 +3902,7 @@ def test_service_settings_links_to_branding_request_page_for_emails(
|
||||
if single_branding_option:
|
||||
# should only have a "something else" option
|
||||
# so we go straight to that form
|
||||
service_one['organisation_type'] = 'other'
|
||||
service_one['organization_type'] = 'other'
|
||||
|
||||
page = client_request.get(
|
||||
'.service_settings', service_id=SERVICE_ONE_ID
|
||||
|
||||
@@ -4,7 +4,7 @@ from freezegun import freeze_time
|
||||
from notifications_python_client.errors import HTTPError
|
||||
|
||||
from app.utils.user import is_gov_user
|
||||
from tests import organisation_json
|
||||
from tests import organization_json
|
||||
from tests.conftest import normalize_spaces
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ def test_non_gov_user_cannot_see_add_service_button(
|
||||
mock_login,
|
||||
mock_get_non_govuser,
|
||||
api_nongov_user_active,
|
||||
mock_get_organisations,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
):
|
||||
client_request.login(api_nongov_user_active)
|
||||
page = client_request.get('main.choose_account')
|
||||
@@ -23,7 +23,7 @@ def test_non_gov_user_cannot_see_add_service_button(
|
||||
|
||||
@pytest.mark.parametrize('org_json', (
|
||||
None,
|
||||
organisation_json(organisation_type=None),
|
||||
organization_json(organization_type=None),
|
||||
))
|
||||
def test_get_should_render_add_service_template(
|
||||
client_request,
|
||||
@@ -31,7 +31,7 @@ def test_get_should_render_add_service_template(
|
||||
org_json,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
'app.organizations_client.get_organization_by_domain',
|
||||
return_value=org_json,
|
||||
)
|
||||
page = client_request.get('main.add_service')
|
||||
@@ -58,8 +58,8 @@ def test_get_should_not_render_radios_if_org_type_known(
|
||||
mocker,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
return_value=organisation_json(organisation_type='central'),
|
||||
'app.organizations_client.get_organization_by_domain',
|
||||
return_value=organization_json(organization_type='central'),
|
||||
)
|
||||
page = client_request.get('main.add_service')
|
||||
assert page.select_one('h1').text.strip() == 'About your service'
|
||||
@@ -72,8 +72,8 @@ def test_show_different_page_if_user_org_type_is_local(
|
||||
mocker,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
return_value=organisation_json(organisation_type='local'),
|
||||
'app.organizations_client.get_organization_by_domain',
|
||||
return_value=organization_json(organization_type='local'),
|
||||
)
|
||||
page = client_request.get('main.add_service')
|
||||
assert page.select_one('h1').text.strip() == 'About your service'
|
||||
@@ -112,14 +112,14 @@ def test_should_add_service_and_redirect_to_tour_when_no_services(
|
||||
api_user_active['email_address'] = email_address
|
||||
client_request.login(api_user_active)
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
return_value=organisation_json(organisation_type=inherited),
|
||||
'app.organizations_client.get_organization_by_domain',
|
||||
return_value=organization_json(organization_type=inherited),
|
||||
)
|
||||
client_request.post(
|
||||
'main.add_service',
|
||||
_data={
|
||||
'name': 'testing the post',
|
||||
'organisation_type': posted,
|
||||
'organization_type': posted,
|
||||
},
|
||||
_expected_status=302,
|
||||
_expected_redirect=url_for(
|
||||
@@ -131,7 +131,7 @@ def test_should_add_service_and_redirect_to_tour_when_no_services(
|
||||
assert mock_get_services_with_no_services.called
|
||||
mock_create_service.assert_called_once_with(
|
||||
service_name='testing the post',
|
||||
organisation_type=persisted,
|
||||
organization_type=persisted,
|
||||
message_limit=50,
|
||||
restricted=True,
|
||||
user_id=api_user_active['id'],
|
||||
@@ -160,7 +160,7 @@ def test_add_service_has_to_choose_org_type(
|
||||
mock_get_all_email_branding,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
'app.organizations_client.get_organization_by_domain',
|
||||
return_value=None,
|
||||
)
|
||||
page = client_request.post(
|
||||
@@ -193,7 +193,7 @@ def test_get_should_only_show_nhs_org_types_radios_if_user_has_nhs_email(
|
||||
api_user_active['email_address'] = email_address
|
||||
client_request.login(api_user_active)
|
||||
mocker.patch(
|
||||
'app.organisations_client.get_organisation_by_domain',
|
||||
'app.organizations_client.get_organization_by_domain',
|
||||
return_value=None,
|
||||
)
|
||||
page = client_request.get('main.add_service')
|
||||
@@ -215,7 +215,7 @@ def test_get_should_only_show_nhs_org_types_radios_if_user_has_nhs_email(
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize('organisation_type, free_allowance', [
|
||||
@pytest.mark.parametrize('organization_type, free_allowance', [
|
||||
('federal', 150_000),
|
||||
('state', 150_000),
|
||||
])
|
||||
@@ -226,9 +226,9 @@ def test_should_add_service_and_redirect_to_dashboard_when_existing_service(
|
||||
mock_create_service,
|
||||
mock_create_service_template,
|
||||
mock_get_services,
|
||||
mock_get_no_organisation_by_domain,
|
||||
mock_get_no_organization_by_domain,
|
||||
api_user_active,
|
||||
organisation_type,
|
||||
organization_type,
|
||||
free_allowance,
|
||||
mock_get_all_email_branding,
|
||||
):
|
||||
@@ -236,7 +236,7 @@ def test_should_add_service_and_redirect_to_dashboard_when_existing_service(
|
||||
'main.add_service',
|
||||
_data={
|
||||
'name': 'testing the post',
|
||||
'organisation_type': organisation_type,
|
||||
'organization_type': organization_type,
|
||||
},
|
||||
_expected_status=302,
|
||||
_expected_redirect=url_for(
|
||||
@@ -247,7 +247,7 @@ def test_should_add_service_and_redirect_to_dashboard_when_existing_service(
|
||||
assert mock_get_services.called
|
||||
mock_create_service.assert_called_once_with(
|
||||
service_name='testing the post',
|
||||
organisation_type=organisation_type,
|
||||
organization_type=organization_type,
|
||||
message_limit=notify_admin.config['DEFAULT_SERVICE_LIMIT'],
|
||||
restricted=True,
|
||||
user_id=api_user_active['id'],
|
||||
@@ -265,7 +265,7 @@ def test_should_add_service_and_redirect_to_dashboard_when_existing_service(
|
||||
])
|
||||
def test_add_service_fails_if_service_name_fails_validation(
|
||||
client_request,
|
||||
mock_get_organisation_by_domain,
|
||||
mock_get_organization_by_domain,
|
||||
name,
|
||||
error_message,
|
||||
):
|
||||
@@ -280,7 +280,7 @@ def test_add_service_fails_if_service_name_fails_validation(
|
||||
@freeze_time("2021-01-01")
|
||||
def test_should_return_form_errors_with_duplicate_service_name_regardless_of_case(
|
||||
client_request,
|
||||
mock_get_organisation_by_domain,
|
||||
mock_get_organization_by_domain,
|
||||
mocker,
|
||||
):
|
||||
def _create(**_kwargs):
|
||||
@@ -298,7 +298,7 @@ def test_should_return_form_errors_with_duplicate_service_name_regardless_of_cas
|
||||
'main.add_service',
|
||||
_data={
|
||||
'name': 'SERVICE ONE',
|
||||
'organisation_type': 'federal',
|
||||
'organization_type': 'federal',
|
||||
},
|
||||
_expected_status=200,
|
||||
)
|
||||
@@ -309,7 +309,7 @@ def test_non_government_user_cannot_access_create_service_page(
|
||||
client_request,
|
||||
mock_get_non_govuser,
|
||||
api_nongov_user_active,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
assert is_gov_user(api_nongov_user_active['email_address']) is False
|
||||
client_request.login(api_nongov_user_active)
|
||||
@@ -323,7 +323,7 @@ def test_non_government_user_cannot_create_service(
|
||||
client_request,
|
||||
mock_get_non_govuser,
|
||||
api_nongov_user_active,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
assert is_gov_user(api_nongov_user_active['email_address']) is False
|
||||
client_request.login(api_nongov_user_active)
|
||||
|
||||
@@ -15,7 +15,7 @@ from app.main.views.dashboard import (
|
||||
get_tuples_of_financial_years,
|
||||
)
|
||||
from tests import (
|
||||
organisation_json,
|
||||
organization_json,
|
||||
service_json,
|
||||
validate_route_permission,
|
||||
validate_route_permission_with_client,
|
||||
@@ -1304,7 +1304,7 @@ def test_org_breadcrumbs_do_not_show_if_service_has_no_org(
|
||||
):
|
||||
page = client_request.get('main.service_dashboard', service_id=SERVICE_ONE_ID)
|
||||
|
||||
assert not page.select('.navigation-organisation-link')
|
||||
assert not page.select('.navigation-organization-link')
|
||||
|
||||
|
||||
def test_org_breadcrumbs_do_not_show_if_user_is_not_an_org_member(
|
||||
@@ -1321,13 +1321,13 @@ def test_org_breadcrumbs_do_not_show_if_user_is_not_an_org_member(
|
||||
service_one_json = service_json(SERVICE_ONE_ID,
|
||||
users=[active_caseworking_user['id']],
|
||||
restricted=False,
|
||||
organisation_id=ORGANISATION_ID)
|
||||
organization_id=ORGANISATION_ID)
|
||||
mocker.patch('app.service_api_client.get_service', return_value={'data': service_one_json})
|
||||
|
||||
client_request.login(active_caseworking_user, service=service_one_json)
|
||||
page = client_request.get('main.service_dashboard', service_id=SERVICE_ONE_ID, _follow_redirects=True)
|
||||
|
||||
assert not page.select('.navigation-organisation-link')
|
||||
assert not page.select('.navigation-organization-link')
|
||||
|
||||
|
||||
def test_org_breadcrumbs_show_if_user_is_a_member_of_the_services_org(
|
||||
@@ -1345,16 +1345,16 @@ def test_org_breadcrumbs_show_if_user_is_a_member_of_the_services_org(
|
||||
service_one_json = service_json(SERVICE_ONE_ID,
|
||||
users=[active_user_with_permissions['id']],
|
||||
restricted=False,
|
||||
organisation_id=ORGANISATION_ID)
|
||||
organization_id=ORGANISATION_ID)
|
||||
|
||||
mocker.patch('app.service_api_client.get_service', return_value={'data': service_one_json})
|
||||
mocker.patch('app.organisations_client.get_organisation', return_value=organisation_json(
|
||||
mocker.patch('app.organizations_client.get_organization', return_value=organization_json(
|
||||
id_=ORGANISATION_ID,
|
||||
))
|
||||
|
||||
page = client_request.get('main.service_dashboard', service_id=SERVICE_ONE_ID)
|
||||
assert page.select_one('.navigation-organisation-link')['href'] == url_for(
|
||||
'main.organisation_dashboard',
|
||||
assert page.select_one('.navigation-organization-link')['href'] == url_for(
|
||||
'main.organization_dashboard',
|
||||
org_id=ORGANISATION_ID,
|
||||
)
|
||||
|
||||
@@ -1373,10 +1373,10 @@ def test_org_breadcrumbs_do_not_show_if_user_is_a_member_of_the_services_org_but
|
||||
|
||||
service_one_json = service_json(SERVICE_ONE_ID,
|
||||
users=[active_user_with_permissions['id']],
|
||||
organisation_id=ORGANISATION_ID)
|
||||
organization_id=ORGANISATION_ID)
|
||||
|
||||
mocker.patch('app.service_api_client.get_service', return_value={'data': service_one_json})
|
||||
mocker.patch('app.models.service.Organisation')
|
||||
mocker.patch('app.models.service.Organization')
|
||||
|
||||
page = client_request.get('main.service_dashboard', service_id=SERVICE_ONE_ID)
|
||||
|
||||
@@ -1395,18 +1395,18 @@ def test_org_breadcrumbs_show_if_user_is_platform_admin(
|
||||
):
|
||||
service_one_json = service_json(SERVICE_ONE_ID,
|
||||
users=[platform_admin_user['id']],
|
||||
organisation_id=ORGANISATION_ID)
|
||||
organization_id=ORGANISATION_ID)
|
||||
|
||||
mocker.patch('app.service_api_client.get_service', return_value={'data': service_one_json})
|
||||
mocker.patch('app.organisations_client.get_organisation', return_value=organisation_json(
|
||||
mocker.patch('app.organizations_client.get_organization', return_value=organization_json(
|
||||
id_=ORGANISATION_ID,
|
||||
))
|
||||
|
||||
client_request.login(platform_admin_user, service_one_json)
|
||||
page = client_request.get('main.service_dashboard', service_id=SERVICE_ONE_ID)
|
||||
|
||||
assert page.select_one('.navigation-organisation-link')['href'] == url_for(
|
||||
'main.organisation_dashboard',
|
||||
assert page.select_one('.navigation-organization-link')['href'] == url_for(
|
||||
'main.organization_dashboard',
|
||||
org_id=ORGANISATION_ID,
|
||||
)
|
||||
|
||||
|
||||
@@ -58,9 +58,9 @@ def test_edit_email_branding_shows_the_correct_branding_info(
|
||||
)
|
||||
|
||||
assert page.select_one('#logo-img > img')['src'].endswith('/example.png')
|
||||
assert page.select_one('#name').attrs.get('value') == 'Organisation name'
|
||||
assert page.select_one('#name').attrs.get('value') == 'Organization name'
|
||||
assert page.select_one('#file').attrs.get('accept') == '.png'
|
||||
assert page.select_one('#text').attrs.get('value') == 'Organisation text'
|
||||
assert page.select_one('#text').attrs.get('value') == 'Organization text'
|
||||
assert page.select_one('#colour').attrs.get('value') == '#f00'
|
||||
|
||||
|
||||
@@ -359,7 +359,7 @@ def test_temp_logo_is_shown_after_uploading_logo(
|
||||
assert page.select_one('#logo-img > img').attrs['src'].endswith(temp_filename)
|
||||
|
||||
|
||||
def test_logo_persisted_when_organisation_saved(
|
||||
def test_logo_persisted_when_organization_saved(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
mock_create_email_branding,
|
||||
|
||||
@@ -41,7 +41,7 @@ def test_displays_both_branding(client_request, mock_get_email_branding_with_bot
|
||||
assert page.find("a", attrs={"href": "https://www.gov.uk"})
|
||||
assert page.find("img", attrs={"src": re.compile("example.png$")})
|
||||
assert page.select("body > table:nth-of-type(3) table > tr:nth-of-type(1) > td:nth-of-type(2)")[0]\
|
||||
.get_text().strip() == 'Organisation text' # brand text is set
|
||||
.get_text().strip() == 'Organization text' # brand text is set
|
||||
|
||||
|
||||
def test_displays_org_branding(client_request, mock_get_email_branding):
|
||||
@@ -54,7 +54,7 @@ def test_displays_org_branding(client_request, mock_get_email_branding):
|
||||
assert page.find("img", attrs={"src": re.compile("example.png")})
|
||||
assert not page.select("body > table > tr > td[bgcolor='#f00']") # banner colour is not set
|
||||
assert page.select("body > table:nth-of-type(1) > tr:nth-of-type(1) > td:nth-of-type(2)")[0]\
|
||||
.get_text().strip() == 'Organisation text' # brand text is set
|
||||
.get_text().strip() == 'Organization text' # brand text is set
|
||||
|
||||
|
||||
def test_displays_org_branding_with_banner(
|
||||
@@ -68,7 +68,7 @@ def test_displays_org_branding_with_banner(
|
||||
assert page.find("img", attrs={"src": re.compile("example.png")})
|
||||
assert page.select("body > table > tr > td[bgcolor='#f00']") # banner colour is set
|
||||
assert page.select("body > table table > tr > td > span")[0]\
|
||||
.get_text().strip() == 'Organisation text' # brand text is set
|
||||
.get_text().strip() == 'Organization text' # brand text is set
|
||||
|
||||
|
||||
def test_displays_org_branding_with_banner_without_brand_text(
|
||||
|
||||
@@ -74,7 +74,7 @@ def test_get_support_index_page_when_signed_out(
|
||||
])
|
||||
def test_choose_support_type(
|
||||
client_request,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
support_type,
|
||||
expected_h1
|
||||
):
|
||||
@@ -197,7 +197,7 @@ def test_passed_non_logged_in_user_details_through_flow(client_request, mocker,
|
||||
])
|
||||
def test_passes_user_details_through_flow(
|
||||
client_request,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
mocker,
|
||||
ticket_type,
|
||||
zendesk_ticket_type,
|
||||
@@ -318,7 +318,7 @@ def test_email_address_must_be_valid_if_provided_to_support_form(
|
||||
])
|
||||
def test_urgency(
|
||||
client_request,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
mocker,
|
||||
ticket_type,
|
||||
severe,
|
||||
@@ -522,7 +522,7 @@ def test_triage_redirects_to_correct_url(
|
||||
@freeze_time('2012-12-12 12:12')
|
||||
def test_back_link_from_form(
|
||||
client_request,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
extra_args,
|
||||
expected_back_link,
|
||||
):
|
||||
@@ -585,7 +585,7 @@ def test_should_be_shown_the_bat_email(
|
||||
active_user_with_permissions,
|
||||
mocker,
|
||||
service_one,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
is_in_business_hours,
|
||||
severe,
|
||||
expected_status_code,
|
||||
@@ -641,7 +641,7 @@ def test_should_be_shown_the_bat_email_for_general_questions(
|
||||
active_user_with_permissions,
|
||||
mocker,
|
||||
service_one,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
severe,
|
||||
expected_status_code,
|
||||
expected_redirect,
|
||||
|
||||
@@ -103,8 +103,8 @@ def test_user_information_page_shows_information_about_user(
|
||||
], autospec=True)
|
||||
|
||||
mocker.patch(
|
||||
'app.user_api_client.get_organisations_and_services_for_user',
|
||||
return_value={'organisations': [], 'services': [
|
||||
'app.user_api_client.get_organizations_and_services_for_user',
|
||||
return_value={'organizations': [], 'services': [
|
||||
{"id": user_service_one, "name": "Fresh Orchard Juice", "restricted": True},
|
||||
{"id": user_service_two, "name": "Nature Therapy", "restricted": False},
|
||||
]},
|
||||
@@ -146,7 +146,7 @@ def test_user_information_page_shows_change_auth_type_link(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
api_user_active,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
mocker
|
||||
):
|
||||
client_request.login(platform_admin_user)
|
||||
@@ -167,7 +167,7 @@ def test_user_information_page_doesnt_show_change_auth_type_link_if_user_on_weba
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
api_user_active,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
mocker
|
||||
):
|
||||
client_request.login(platform_admin_user)
|
||||
@@ -252,8 +252,8 @@ def test_user_information_page_displays_if_there_are_failed_login_attempts(
|
||||
], autospec=True)
|
||||
|
||||
mocker.patch(
|
||||
'app.user_api_client.get_organisations_and_services_for_user',
|
||||
return_value={'organisations': [], 'services': []},
|
||||
'app.user_api_client.get_organizations_and_services_for_user',
|
||||
return_value={'organizations': [], 'services': []},
|
||||
autospec=True
|
||||
)
|
||||
page = client_request.get('main.user_information', user_id=fake_uuid)
|
||||
@@ -267,7 +267,7 @@ def test_user_information_page_shows_archive_link_for_active_users(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
api_user_active,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
):
|
||||
client_request.login(platform_admin_user)
|
||||
page = client_request.get(
|
||||
@@ -283,7 +283,7 @@ def test_user_information_page_does_not_show_archive_link_for_inactive_users(
|
||||
mocker,
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
):
|
||||
inactive_user_id = uuid.uuid4()
|
||||
inactive_user = user_json(id_=inactive_user_id, state='inactive')
|
||||
@@ -302,7 +302,7 @@ def test_archive_user_prompts_for_confirmation(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
api_user_active,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
):
|
||||
client_request.login(platform_admin_user)
|
||||
page = client_request.get(
|
||||
@@ -340,7 +340,7 @@ def test_archive_user_shows_error_message_if_user_cannot_be_archived(
|
||||
platform_admin_user,
|
||||
api_user_active,
|
||||
mocker,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
):
|
||||
mocker.patch(
|
||||
'app.user_api_client.post',
|
||||
|
||||
@@ -4,7 +4,7 @@ from re import search
|
||||
def test_owasp_useful_headers_set(
|
||||
client_request,
|
||||
mocker,
|
||||
mock_get_service_and_organisation_counts,
|
||||
mock_get_service_and_organization_counts,
|
||||
):
|
||||
client_request.logout()
|
||||
response = client_request.get_response('.index')
|
||||
|
||||
@@ -10,7 +10,7 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces, sample_uuid
|
||||
|
||||
def test_non_logged_in_user_can_see_homepage(
|
||||
client_request,
|
||||
mock_get_service_and_organisation_counts,
|
||||
mock_get_service_and_organization_counts,
|
||||
):
|
||||
client_request.logout()
|
||||
page = client_request.get('main.index', _test_page_title=False)
|
||||
@@ -77,7 +77,7 @@ def test_robots(client_request):
|
||||
@freeze_time('2012-12-12 12:12') # So we don’t go out of business hours
|
||||
def test_hiding_pages_from_search_engines(
|
||||
client_request,
|
||||
mock_get_service_and_organisation_counts,
|
||||
mock_get_service_and_organization_counts,
|
||||
endpoint,
|
||||
kwargs,
|
||||
):
|
||||
@@ -102,7 +102,7 @@ def test_hiding_pages_from_search_engines(
|
||||
])
|
||||
def test_static_pages(
|
||||
client_request,
|
||||
mock_get_organisation_by_domain,
|
||||
mock_get_organization_by_domain,
|
||||
view,
|
||||
):
|
||||
request = partial(client_request.get, 'main.{}'.format(view))
|
||||
@@ -284,7 +284,7 @@ def test_email_branding_preview(
|
||||
|
||||
def test_font_preload(
|
||||
client_request,
|
||||
mock_get_service_and_organisation_counts,
|
||||
mock_get_service_and_organization_counts,
|
||||
):
|
||||
client_request.logout()
|
||||
page = client_request.get('main.index', _test_page_title=False)
|
||||
@@ -304,7 +304,7 @@ def test_font_preload(
|
||||
@pytest.mark.skip(reason="Currently hidden for TTS")
|
||||
def test_sms_price(
|
||||
client_request,
|
||||
mock_get_service_and_organisation_counts,
|
||||
mock_get_service_and_organization_counts,
|
||||
current_date,
|
||||
expected_rate,
|
||||
):
|
||||
|
||||
@@ -849,11 +849,11 @@ def test_should_show_page_for_inviting_user_with_email_prefilled(
|
||||
fake_uuid,
|
||||
active_user_with_permissions,
|
||||
active_user_with_permission_to_other_service,
|
||||
mock_get_organisation_by_domain,
|
||||
mock_get_organization_by_domain,
|
||||
mock_get_invites_for_service,
|
||||
):
|
||||
client_request.login(active_user_with_permissions)
|
||||
service_one['organisation'] = ORGANISATION_ID
|
||||
service_one['organization'] = ORGANISATION_ID
|
||||
mocker.patch('app.models.user.user_api_client.get_user', side_effect=[
|
||||
active_user_with_permission_to_other_service,
|
||||
])
|
||||
@@ -943,7 +943,7 @@ def test_should_show_page_if_prefilled_user_is_already_invited(
|
||||
assert not page.select("form")
|
||||
|
||||
|
||||
def test_should_403_if_trying_to_prefill_email_address_for_user_with_no_organisation(
|
||||
def test_should_403_if_trying_to_prefill_email_address_for_user_with_no_organization(
|
||||
mocker,
|
||||
client_request,
|
||||
service_one,
|
||||
@@ -952,9 +952,9 @@ def test_should_403_if_trying_to_prefill_email_address_for_user_with_no_organisa
|
||||
active_user_with_permissions,
|
||||
active_user_with_permission_to_other_service,
|
||||
mock_get_invites_for_service,
|
||||
mock_get_no_organisation_by_domain,
|
||||
mock_get_no_organization_by_domain,
|
||||
):
|
||||
service_one['organisation'] = ORGANISATION_ID
|
||||
service_one['organization'] = ORGANISATION_ID
|
||||
client_request.login(active_user_with_permissions)
|
||||
mocker.patch('app.models.user.user_api_client.get_user', side_effect=[
|
||||
active_user_with_permission_to_other_service,
|
||||
@@ -967,7 +967,7 @@ def test_should_403_if_trying_to_prefill_email_address_for_user_with_no_organisa
|
||||
)
|
||||
|
||||
|
||||
def test_should_403_if_trying_to_prefill_email_address_for_user_from_other_organisation(
|
||||
def test_should_403_if_trying_to_prefill_email_address_for_user_from_other_organization(
|
||||
mocker,
|
||||
client_request,
|
||||
service_one,
|
||||
@@ -976,9 +976,9 @@ def test_should_403_if_trying_to_prefill_email_address_for_user_from_other_organ
|
||||
active_user_with_permissions,
|
||||
active_user_with_permission_to_other_service,
|
||||
mock_get_invites_for_service,
|
||||
mock_get_organisation_by_domain,
|
||||
mock_get_organization_by_domain,
|
||||
):
|
||||
service_one['organisation'] = ORGANISATION_TWO_ID
|
||||
service_one['organization'] = ORGANISATION_TWO_ID
|
||||
client_request.login(active_user_with_permissions)
|
||||
mocker.patch('app.models.user.user_api_client.get_user', side_effect=[
|
||||
active_user_with_permission_to_other_service,
|
||||
@@ -1025,7 +1025,7 @@ def test_invite_user(
|
||||
email_address,
|
||||
gov_user,
|
||||
mock_get_template_folders,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
sample_invite['email_address'] = email_address
|
||||
|
||||
@@ -1072,9 +1072,9 @@ def test_invite_user_when_email_address_is_prefilled(
|
||||
sample_invite,
|
||||
mock_get_template_folders,
|
||||
mock_get_invites_for_service,
|
||||
mock_get_organisation_by_domain,
|
||||
mock_get_organization_by_domain,
|
||||
):
|
||||
service_one['organisation'] = ORGANISATION_ID
|
||||
service_one['organization'] = ORGANISATION_ID
|
||||
client_request.login(active_user_with_permissions)
|
||||
mocker.patch('app.models.user.user_api_client.get_user', side_effect=[
|
||||
active_user_with_permission_to_other_service,
|
||||
@@ -1119,7 +1119,7 @@ def test_invite_user_with_email_auth_service(
|
||||
gov_user,
|
||||
mocker,
|
||||
auth_type,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
mock_get_template_folders,
|
||||
):
|
||||
service_one['permissions'].append('email_auth')
|
||||
@@ -1508,7 +1508,7 @@ def test_edit_user_email_can_change_any_email_address_to_a_gov_email_address(
|
||||
mock_get_user_by_email_not_found,
|
||||
mock_get_users_by_service,
|
||||
mock_update_user_attribute,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
original_email_address,
|
||||
):
|
||||
active_user_with_permissions['email_address'] = original_email_address
|
||||
@@ -1535,7 +1535,7 @@ def test_edit_user_email_can_change_a_non_gov_email_address_to_another_non_gov_e
|
||||
mock_get_user_by_email_not_found,
|
||||
mock_get_users_by_service,
|
||||
mock_update_user_attribute,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
active_user_with_permissions['email_address'] = 'old@example.com'
|
||||
|
||||
@@ -1561,7 +1561,7 @@ def test_edit_user_email_cannot_change_a_gov_email_address_to_a_non_gov_email_ad
|
||||
mock_get_user_by_email_not_found,
|
||||
mock_get_users_by_service,
|
||||
mock_update_user_attribute,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
page = client_request.post(
|
||||
'main.edit_user_email',
|
||||
|
||||
@@ -75,29 +75,29 @@ def _get_example_performance_data():
|
||||
],
|
||||
"services_using_notify": [
|
||||
{
|
||||
"organisation_id": uuid.uuid4(),
|
||||
"organisation_name": "Department of Examples and Patterns",
|
||||
"organization_id": uuid.uuid4(),
|
||||
"organization_name": "Department of Examples and Patterns",
|
||||
"service_id": uuid.uuid4(),
|
||||
"service_name": "Example service"
|
||||
},
|
||||
{
|
||||
"organisation_id": uuid.uuid4(),
|
||||
"organisation_name": "Department of Examples and Patterns",
|
||||
"organization_id": uuid.uuid4(),
|
||||
"organization_name": "Department of Examples and Patterns",
|
||||
"service_id": uuid.uuid4(),
|
||||
"service_name": "Example service 2"
|
||||
},
|
||||
{
|
||||
"organisation_id": uuid.uuid4(),
|
||||
"organisation_name": "Department of One Service",
|
||||
"organization_id": uuid.uuid4(),
|
||||
"organization_name": "Department of One Service",
|
||||
"service_id": uuid.uuid4(),
|
||||
"service_name": "Example service 3"
|
||||
},
|
||||
{
|
||||
# On production there should be no live services without an
|
||||
# organisation, but this isn’t always true in people’s local
|
||||
# organization, but this isn’t always true in people’s local
|
||||
# environments
|
||||
"organisation_id": None,
|
||||
"organisation_name": None,
|
||||
"organization_id": None,
|
||||
"organization_name": None,
|
||||
"service_id": uuid.uuid4(),
|
||||
"service_name": "Example service 4"
|
||||
},
|
||||
@@ -109,7 +109,7 @@ def _get_example_performance_data():
|
||||
def test_should_render_performance_page(
|
||||
mocker,
|
||||
client_request,
|
||||
mock_get_service_and_organisation_counts,
|
||||
mock_get_service_and_organization_counts,
|
||||
):
|
||||
mock_get_performance_data = mocker.patch(
|
||||
'app.performance_dashboard_api_client.get_performance_dashboard_stats',
|
||||
|
||||
@@ -660,7 +660,7 @@ def test_clear_cache_shows_form(
|
||||
'service',
|
||||
'template',
|
||||
'email_branding',
|
||||
'organisation',
|
||||
'organization',
|
||||
}
|
||||
|
||||
|
||||
@@ -670,17 +670,17 @@ def test_clear_cache_shows_form(
|
||||
call('service-????????-????-????-????-????????????-template-????????-????-????-????-????????????-version-*'),
|
||||
call('service-????????-????-????-????-????????????-template-????????-????-????-????-????????????-versions'),
|
||||
], 'Removed 6 objects across 3 key formats for template'),
|
||||
(['service', 'organisation'], [
|
||||
(['service', 'organization'], [
|
||||
call('has_jobs-????????-????-????-????-????????????'),
|
||||
call('service-????????-????-????-????-????????????'),
|
||||
call('service-????????-????-????-????-????????????-templates'),
|
||||
call('service-????????-????-????-????-????????????-data-retention'),
|
||||
call('service-????????-????-????-????-????????????-template-folders'),
|
||||
call('organisations'),
|
||||
call('organizations'),
|
||||
call('domains'),
|
||||
call('live-service-and-organisation-counts'),
|
||||
call('organisation-????????-????-????-????-????????????-name'),
|
||||
], 'Removed 18 objects across 9 key formats for service, organisation'),
|
||||
call('live-service-and-organization-counts'),
|
||||
call('organization-????????-????-????-????-????????????-name'),
|
||||
], 'Removed 18 objects across 9 key formats for service, organization'),
|
||||
))
|
||||
def test_clear_cache_submits_and_tells_you_how_many_things_were_deleted(
|
||||
client_request,
|
||||
@@ -745,14 +745,14 @@ def test_get_live_services_report(
|
||||
mocker.patch(
|
||||
'app.service_api_client.get_live_services_data',
|
||||
return_value={'data': [
|
||||
{'service_id': 1, 'service_name': 'jessie the oak tree', 'organisation_name': 'Forest',
|
||||
'consent_to_research': True, 'contact_name': 'Forest fairy', 'organisation_type': 'Ecosystem',
|
||||
{'service_id': 1, 'service_name': 'jessie the oak tree', 'organization_name': 'Forest',
|
||||
'consent_to_research': True, 'contact_name': 'Forest fairy', 'organization_type': 'Ecosystem',
|
||||
'contact_email': 'forest.fairy@digital.cabinet-office.gov.uk', 'contact_mobile': '+12028675109',
|
||||
'live_date': 'Sat, 29 Mar 2014 00:00:00 GMT', 'sms_volume_intent': 100, 'email_volume_intent': 50,
|
||||
'sms_totals': 300, 'email_totals': 1200,
|
||||
'free_sms_fragment_limit': 100},
|
||||
{'service_id': 2, 'service_name': 'james the pine tree', 'organisation_name': 'Forest',
|
||||
'consent_to_research': None, 'contact_name': None, 'organisation_type': 'Ecosystem',
|
||||
{'service_id': 2, 'service_name': 'james the pine tree', 'organization_name': 'Forest',
|
||||
'consent_to_research': None, 'contact_name': None, 'organization_type': 'Ecosystem',
|
||||
'contact_email': None, 'contact_mobile': None,
|
||||
'live_date': None, 'sms_volume_intent': None, 'email_volume_intent': 60,
|
||||
'sms_totals': 0, 'email_totals': 0,
|
||||
@@ -839,8 +839,8 @@ def test_get_billing_report_calls_api_and_download_data(
|
||||
mocker.patch(
|
||||
"app.main.views.platform_admin.billing_api_client.get_data_for_billing_report",
|
||||
return_value=[{
|
||||
'organisation_id': '7832a1be-a1f0-4f2a-982f-05adfd3d6354',
|
||||
'organisation_name': 'Org for a - with sms',
|
||||
'organization_id': '7832a1be-a1f0-4f2a-982f-05adfd3d6354',
|
||||
'organization_name': 'Org for a - with sms',
|
||||
'service_id': '48e82ac0-c8c4-4e46-8712-c83c35a94006',
|
||||
'service_name': 'a - with sms',
|
||||
'sms_cost': 0,
|
||||
@@ -865,7 +865,7 @@ def test_get_billing_report_calls_api_and_download_data(
|
||||
)
|
||||
|
||||
assert response.get_data(as_text=True) == (
|
||||
'organisation_id,organisation_name,service_id,service_name,sms_cost,sms_chargeable_units,' +
|
||||
'organization_id,organization_name,service_id,service_name,sms_cost,sms_chargeable_units,' +
|
||||
'purchase_order_number,contact_names,contact_email_addresses,' +
|
||||
'billing_reference\r\n' +
|
||||
|
||||
@@ -927,8 +927,8 @@ def test_get_volumes_by_service_report_calls_api_and_download_data(
|
||||
mocker.patch(
|
||||
"app.main.views.platform_admin.billing_api_client.get_data_for_volumes_by_service_report",
|
||||
return_value=[{
|
||||
"organisation_id": "7832a1be-a1f0-4f2a-982f-05adfd3d6354",
|
||||
"organisation_name": "Org name",
|
||||
"organization_id": "7832a1be-a1f0-4f2a-982f-05adfd3d6354",
|
||||
"organization_name": "Org name",
|
||||
"service_id": "48e82ac0-c8c4-4e46-8712-c83c35a94006",
|
||||
"service_name": "service name",
|
||||
"free_allowance": 10000,
|
||||
@@ -951,7 +951,7 @@ def test_get_volumes_by_service_report_calls_api_and_download_data(
|
||||
)
|
||||
|
||||
assert response.get_data(as_text=True) == (
|
||||
"organisation id,organisation name,service id,service name,free allowance,sms notifications," +
|
||||
"organization id,organization name,service id,service name,free allowance,sms notifications," +
|
||||
"sms chargeable units,email totals\r\n" +
|
||||
|
||||
'7832a1be-a1f0-4f2a-982f-05adfd3d6354,' +
|
||||
|
||||
@@ -107,7 +107,7 @@ def test_process_register_returns_200_when_mobile_number_is_invalid(
|
||||
|
||||
def test_should_return_200_when_email_is_not_gov_uk(
|
||||
client_request,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
client_request.logout()
|
||||
page = client_request.post(
|
||||
@@ -139,7 +139,7 @@ def test_should_add_user_details_to_session(
|
||||
mock_send_verify_code,
|
||||
mock_register_user,
|
||||
mock_get_user_by_email_not_found,
|
||||
mock_get_organisations_with_unusual_domains,
|
||||
mock_get_organizations_with_unusual_domains,
|
||||
mock_email_is_not_already_in_use,
|
||||
mock_send_verify_email,
|
||||
mock_login,
|
||||
|
||||
@@ -61,7 +61,7 @@ def test_sign_in_explains_other_browser(client_request, api_user_active, mocker)
|
||||
def test_doesnt_redirect_to_sign_in_if_no_session_info(
|
||||
client_request,
|
||||
api_user_active,
|
||||
mock_get_organisation_by_domain,
|
||||
mock_get_organization_by_domain,
|
||||
):
|
||||
api_user_active['current_session_id'] = str(uuid.UUID(int=1))
|
||||
|
||||
|
||||
@@ -770,7 +770,7 @@ def test_choose_a_template_to_copy_when_user_has_one_service(
|
||||
mock_get_service_templates,
|
||||
mock_get_template_folders,
|
||||
mock_get_no_api_keys,
|
||||
mock_get_empty_organisations_and_one_service_for_user,
|
||||
mock_get_empty_organizations_and_one_service_for_user,
|
||||
):
|
||||
page = client_request.get(
|
||||
'main.choose_template_to_copy',
|
||||
@@ -816,7 +816,7 @@ def test_choose_a_template_to_copy_from_folder_within_service(
|
||||
mocker,
|
||||
client_request,
|
||||
mock_get_template_folders,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
mock_get_no_api_keys,
|
||||
):
|
||||
mock_get_template_folders.return_value = [
|
||||
@@ -944,7 +944,7 @@ def test_load_edit_template_with_copy_of_template(
|
||||
active_user_with_permission_to_two_services,
|
||||
mock_get_service_templates,
|
||||
mock_get_service_email_template,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
existing_template_names,
|
||||
expected_name,
|
||||
):
|
||||
@@ -978,7 +978,7 @@ def test_copy_template_loads_template_from_within_subfolder(
|
||||
client_request,
|
||||
active_user_with_permission_to_two_services,
|
||||
mock_get_service_templates,
|
||||
mock_get_non_empty_organisations_and_services_for_user,
|
||||
mock_get_non_empty_organizations_and_services_for_user,
|
||||
mocker
|
||||
):
|
||||
template = template_json(
|
||||
@@ -1013,7 +1013,7 @@ def test_copy_template_loads_template_from_within_subfolder(
|
||||
def test_cant_copy_template_from_non_member_service(
|
||||
client_request,
|
||||
mock_get_service_email_template,
|
||||
mock_get_organisations_and_services_for_user,
|
||||
mock_get_organizations_and_services_for_user,
|
||||
):
|
||||
client_request.get(
|
||||
'main.copy_template',
|
||||
|
||||
@@ -120,7 +120,7 @@ def test_should_redirect_after_email_change(
|
||||
def test_should_show_errors_if_new_email_address_does_not_validate(
|
||||
client_request,
|
||||
mock_email_is_not_already_in_use,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
email_address,
|
||||
error_message,
|
||||
):
|
||||
@@ -387,7 +387,7 @@ def test_should_redirect_after_password_change(
|
||||
def test_non_gov_user_cannot_see_change_email_link(
|
||||
client_request,
|
||||
api_nongov_user_active,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
client_request.login(api_nongov_user_active)
|
||||
page = client_request.get('main.user_profile')
|
||||
@@ -398,7 +398,7 @@ def test_non_gov_user_cannot_see_change_email_link(
|
||||
def test_non_gov_user_cannot_access_change_email_page(
|
||||
client_request,
|
||||
api_nongov_user_active,
|
||||
mock_get_organisations,
|
||||
mock_get_organizations,
|
||||
):
|
||||
client_request.login(api_nongov_user_active)
|
||||
client_request.get('main.user_profile_email', _expected_status=403)
|
||||
|
||||
Reference in New Issue
Block a user