diff --git a/app/__init__.py b/app/__init__.py index bfd3da0f4..95808a225 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -81,7 +81,7 @@ from app.formatters import ( square_metres_to_square_miles, valid_phone_number, ) -from app.models.organisation import Organisation +from app.models.organization import Organization from app.models.service import Service from app.models.user import AnonymousUser, User from app.navigation import ( @@ -101,7 +101,7 @@ from app.notify_client.invite_api_client import invite_api_client from app.notify_client.job_api_client import job_api_client from app.notify_client.notification_api_client import notification_api_client from app.notify_client.org_invite_api_client import org_invite_api_client -from app.notify_client.organisations_api_client import organisations_client +from app.notify_client.organizations_api_client import organizations_client from app.notify_client.performance_dashboard_api_client import ( performance_dashboard_api_client, ) @@ -135,8 +135,8 @@ basic_auth = CustomBasicAuth() # The current service attached to the request stack. current_service = LocalProxy(partial(getattr, request_ctx, 'service')) -# The current organisation attached to the request stack. -current_organisation = LocalProxy(partial(getattr, request_ctx, 'organisation')) +# The current organization attached to the request stack. +current_organization = LocalProxy(partial(getattr, request_ctx, 'organization')) navigation = { 'casework_navigation': CaseworkNavigation(), @@ -215,7 +215,7 @@ def create_app(application): job_api_client, notification_api_client, org_invite_api_client, - organisations_client, + organizations_client, performance_dashboard_api_client, platform_stats_api_client, provider_client, @@ -285,7 +285,7 @@ def create_app(application): def init_app(application): application.before_request(load_service_before_request) - application.before_request(load_organisation_before_request) + application.before_request(load_organization_before_request) application.before_request(request_helper.check_proxy_header_before_request) application.before_request(make_session_permanent) application.after_request(save_service_or_org_after_request) @@ -300,8 +300,8 @@ def init_app(application): return {'current_service': current_service} @application.context_processor - def _attach_current_organisation(): - return {'current_org': current_organisation} + def _attach_current_organization(): + return {'current_org': current_organization} @application.context_processor def _attach_current_user(): @@ -394,19 +394,19 @@ def load_service_before_request(): raise -def load_organisation_before_request(): +def load_organization_before_request(): if '/static/' in request.url: - request_ctx.organisation = None + request_ctx.organization = None return if request_ctx is not None: - request_ctx.organisation = None + request_ctx.organization = None if request.view_args: org_id = request.view_args.get('org_id') if org_id: try: - request_ctx.organisation = Organisation.from_id(org_id) + request_ctx.organization = Organization.from_id(org_id) except HTTPError as exc: # if org id isn't real, then 404 rather than 500ing later because we expect org to be set if exc.status_code == 404: @@ -418,14 +418,14 @@ def load_organisation_before_request(): def save_service_or_org_after_request(response): # Only save the current session if the request is 200 service_id = request.view_args.get('service_id', None) if request.view_args else None - organisation_id = request.view_args.get('org_id', None) if request.view_args else None + organization_id = request.view_args.get('org_id', None) if request.view_args else None if response.status_code == 200: if service_id: session['service_id'] = service_id - session['organisation_id'] = None - elif organisation_id: + session['organization_id'] = None + elif organization_id: session['service_id'] = None - session['organisation_id'] = organisation_id + session['organization_id'] = organization_id return response diff --git a/app/assets/stylesheets/components/navigation.scss b/app/assets/stylesheets/components/navigation.scss index 66c0e62fc..8db69d98f 100644 --- a/app/assets/stylesheets/components/navigation.scss +++ b/app/assets/stylesheets/components/navigation.scss @@ -7,7 +7,7 @@ $padding-bottom: 11px; &-service-name, - &-organisation-link { + &-organization-link { display: inline-block; overflow: hidden; // aligning to the baseline with overflow: hidden adds to the parent's height @@ -59,7 +59,7 @@ &-service-switch, &-service-back-to, - &-organisation-link { + &-organization-link { &:link, &:visited { @@ -115,7 +115,7 @@ } - &-organisation-link { + &-organization-link { max-width: 25%; padding: $padding-top 20px $padding-bottom 0; diff --git a/app/main/__init__.py b/app/main/__init__.py index c0a5adeb1..9d2e0730b 100644 --- a/app/main/__init__.py +++ b/app/main/__init__.py @@ -22,7 +22,7 @@ from app.main.views import ( # noqa isort:skip manage_users, new_password, notifications, - organisations, + organizations, performance, platform_admin, pricing, diff --git a/app/main/forms.py b/app/main/forms.py index 17954f614..f396e2b51 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -65,7 +65,7 @@ from app.main.validators import ( ValidGovEmail, ) from app.models.feedback import PROBLEM_TICKET_TYPE, QUESTION_TICKET_TYPE -from app.models.organisation import Organisation +from app.models.organization import Organization from app.utils import branding, merge_jsonlike from app.utils.user_permissions import all_ui_permissions, permission_options @@ -627,7 +627,7 @@ class RegisterUserFromInviteForm(RegisterUserForm): class RegisterUserFromOrgInviteForm(StripWhitespaceForm): def __init__(self, invited_org_user): super().__init__( - organisation=invited_org_user.organisation, + organization=invited_org_user.organization, email_address=invited_org_user.email_address, ) @@ -638,7 +638,7 @@ class RegisterUserFromOrgInviteForm(StripWhitespaceForm): mobile_number = InternationalPhoneNumber('Mobile number', validators=[DataRequired(message='Cannot be empty')]) password = password() - organisation = HiddenField('organisation') + organization = HiddenField('organization') email_address = HiddenField('email_address') auth_type = HiddenField('auth_type', validators=[DataRequired()]) @@ -964,7 +964,7 @@ class OnOffField(GovukRadiosField): ) -class OrganisationTypeField(GovukRadiosField): +class OrganizationTypeField(GovukRadiosField): def __init__( self, *args, @@ -975,7 +975,7 @@ class OrganisationTypeField(GovukRadiosField): super().__init__( *args, choices=[ - (value, label) for value, label in Organisation.TYPE_LABELS.items() + (value, label) for value, label in Organization.TYPE_LABELS.items() if not include_only or value in include_only ], thing='the type of organization', @@ -1130,7 +1130,7 @@ class RenameServiceForm(StripWhitespaceForm): ]) -class RenameOrganisationForm(StripWhitespaceForm): +class RenameOrganizationForm(StripWhitespaceForm): name = GovukTextInputField( u'Organization name', validators=[ @@ -1140,11 +1140,11 @@ class RenameOrganisationForm(StripWhitespaceForm): ]) -class OrganisationOrganisationTypeForm(StripWhitespaceForm): - organisation_type = OrganisationTypeField('What type of organization is this?') +class OrganizationOrganizationTypeForm(StripWhitespaceForm): + organization_type = OrganizationTypeField('What type of organization is this?') -class AdminOrganisationDomainsForm(StripWhitespaceForm): +class AdminOrganizationDomainsForm(StripWhitespaceForm): def populate(self, domains_list): for index, value in enumerate(domains_list): @@ -1172,12 +1172,12 @@ class CreateServiceForm(StripWhitespaceForm): MustContainAlphanumericCharacters(), Length(max=255, message='Service name must be 255 characters or fewer') ]) - organisation_type = OrganisationTypeField('Where is this service run?') + organization_type = OrganizationTypeField('Where is this service run?') -class AdminNewOrganisationForm( - RenameOrganisationForm, - OrganisationOrganisationTypeForm +class AdminNewOrganizationForm( + RenameOrganizationForm, + OrganizationOrganizationTypeForm ): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -1834,13 +1834,13 @@ class SetTemplateSenderForm(StripWhitespaceForm): sender = GovukRadiosField() -class AdminSetOrganisationForm(StripWhitespaceForm): +class AdminSetOrganizationForm(StripWhitespaceForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) - self.organisations.choices = kwargs['choices'] + self.organizations.choices = kwargs['choices'] - organisations = GovukRadiosField( + organizations = GovukRadiosField( 'Select an organization', validators=[ DataRequired() @@ -2059,7 +2059,7 @@ class AdminClearCacheForm(StripWhitespaceForm): raise ValidationError('Select at least one option') -class AdminOrganisationGoLiveNotesForm(StripWhitespaceForm): +class AdminOrganizationGoLiveNotesForm(StripWhitespaceForm): request_to_go_live_notes = TextAreaField( 'Go live notes', filters=[lambda x: x or None], diff --git a/app/main/views/add_service.py b/app/main/views/add_service.py index 2f0e5ee3b..88f498969 100644 --- a/app/main/views/add_service.py +++ b/app/main/views/add_service.py @@ -9,12 +9,12 @@ from app.main.forms import CreateServiceForm from app.utils.user import user_is_gov_user, user_is_logged_in -def _create_service(service_name, organisation_type, email_from, form): +def _create_service(service_name, organization_type, email_from, form): try: service_id = service_api_client.create_service( service_name=service_name, - organisation_type=organisation_type, + organization_type=organization_type, message_limit=current_app.config['DEFAULT_SERVICE_LIMIT'], restricted=True, user_id=session['user_id'], @@ -45,11 +45,11 @@ def _create_example_template(service_id): @user_is_logged_in @user_is_gov_user def add_service(): - default_organisation_type = current_user.default_organisation_type + default_organization_type = current_user.default_organization_type form = CreateServiceForm( # avoid setting a default for now; the US gov email addresses aren't as useful as the UK # ones for guessing the org type - organisation_type=None + organization_type=None ) if form.validate_on_submit(): @@ -58,12 +58,12 @@ def add_service(): service_id, error = _create_service( service_name, - default_organisation_type or form.organisation_type.data, + default_organization_type or form.organization_type.data, email_from, form, ) if error: - return _render_add_service_page(form, default_organisation_type) + return _render_add_service_page(form, default_organization_type) if len(service_api_client.get_active_services({'user_id': session['user_id']}).get('data', [])) > 1: return redirect(url_for('main.service_dashboard', service_id=service_id)) @@ -75,23 +75,23 @@ def add_service(): template_id=example_sms_template['data']['id'] )) else: - return _render_add_service_page(form, default_organisation_type) + return _render_add_service_page(form, default_organization_type) -def _render_add_service_page(form, default_organisation_type): +def _render_add_service_page(form, default_organization_type): heading = 'About your service' - if default_organisation_type == 'local': + if default_organization_type == 'local': return render_template( 'views/add-service-local.html', form=form, heading=heading, - default_organisation_type=default_organisation_type, + default_organization_type=default_organization_type, ) return render_template( 'views/add-service.html', form=form, heading=heading, - default_organisation_type=default_organisation_type, + default_organization_type=default_organization_type, ) diff --git a/app/main/views/choose_account.py b/app/main/views/choose_account.py index 2509b111d..e1d9ffb42 100644 --- a/app/main/views/choose_account.py +++ b/app/main/views/choose_account.py @@ -3,7 +3,7 @@ from flask_login import current_user from app import status_api_client from app.main import main -from app.models.organisation import AllOrganisations +from app.models.organization import AllOrganizations from app.utils import PermanentRedirect from app.utils.user import user_is_logged_in @@ -24,8 +24,8 @@ def choose_account(): org_count, live_service_count = None, None if current_user.platform_admin: org_count, live_service_count = ( - len(AllOrganisations()), - status_api_client.get_count_of_live_services_and_organisations()['services'], + len(AllOrganizations()), + status_api_client.get_count_of_live_services_and_organizations()['services'], ) return render_template( 'views/choose-account.html', @@ -45,14 +45,14 @@ def show_accounts_or_dashboard(): if service_id and (current_user.belongs_to_service(service_id) or current_user.platform_admin): return redirect(url_for('.service_dashboard', service_id=service_id)) - organisation_id = session.get('organisation_id') - if organisation_id and (current_user.belongs_to_organisation(organisation_id) or current_user.platform_admin): - return redirect(url_for('.organisation_dashboard', org_id=organisation_id)) + organization_id = session.get('organization_id') + if organization_id and (current_user.belongs_to_organization(organization_id) or current_user.platform_admin): + return redirect(url_for('.organization_dashboard', org_id=organization_id)) - if len(current_user.service_ids) == 1 and not current_user.organisation_ids: + if len(current_user.service_ids) == 1 and not current_user.organization_ids: return redirect(url_for('.service_dashboard', service_id=current_user.service_ids[0])) - if len(current_user.organisation_ids) == 1 and not current_user.trial_mode_services: - return redirect(url_for('.organisation_dashboard', org_id=current_user.organisation_ids[0])) + if len(current_user.organization_ids) == 1 and not current_user.trial_mode_services: + return redirect(url_for('.organization_dashboard', org_id=current_user.organization_ids[0])) return redirect(url_for('.choose_account')) diff --git a/app/main/views/feedback.py b/app/main/views/feedback.py index ed9d31ffa..ab0bd3328 100644 --- a/app/main/views/feedback.py +++ b/app/main/views/feedback.py @@ -127,8 +127,8 @@ def feedback(ticket_type): p1=out_of_hours_emergency, user_name=user_name, user_email=user_email, - org_id=current_service.organisation_id if current_service else None, - org_type=current_service.organisation_type if current_service else None, + org_id=current_service.organization_id if current_service else None, + org_type=current_service.organization_type if current_service else None, service_id=current_service.id if current_service else None, ) zendesk_client.send_ticket_to_zendesk(ticket) diff --git a/app/main/views/index.py b/app/main/views/index.py index dea9852ef..8ec0fc3ff 100644 --- a/app/main/views/index.py +++ b/app/main/views/index.py @@ -30,7 +30,7 @@ def index(): return render_template( 'views/signedout.html', sms_rate=CURRENT_SMS_RATE, - counts=status_api_client.get_count_of_live_services_and_organisations(), + counts=status_api_client.get_count_of_live_services_and_organizations(), ) diff --git a/app/main/views/invites.py b/app/main/views/invites.py index f5c6fd2a9..72f6719fa 100644 --- a/app/main/views/invites.py +++ b/app/main/views/invites.py @@ -3,12 +3,12 @@ from flask_login import current_user from markupsafe import Markup from app.main import main -from app.models.organisation import Organisation +from app.models.organization import Organization from app.models.service import Service from app.models.user import ( InvitedOrgUser, InvitedUser, - OrganisationUsers, + OrganizationUsers, User, Users, ) @@ -74,7 +74,7 @@ def accept_invite(token): return redirect(url_for('main.register_from_invite')) -@main.route("/organisation-invitation/") +@main.route("/organization-invitation/") def accept_org_invite(token): invited_org_user = InvitedOrgUser.from_token(token) @@ -93,25 +93,25 @@ def accept_org_invite(token): abort(403) if invited_org_user.status == 'cancelled': - organisation = Organisation.from_id(invited_org_user.organisation) + organization = Organization.from_id(invited_org_user.organization) return render_template('views/cancelled-invitation.html', from_user=invited_org_user.invited_by.name, - organisation_name=organisation.name) + organization_name=organization.name) if invited_org_user.status == 'accepted': session.pop('invited_org_user_id', None) - return redirect(url_for('main.organisation_dashboard', org_id=invited_org_user.organisation)) + return redirect(url_for('main.organization_dashboard', org_id=invited_org_user.organization)) session['invited_org_user_id'] = invited_org_user.id existing_user = User.from_email_address_or_none(invited_org_user.email_address) - organisation_users = OrganisationUsers(invited_org_user.organisation) + organization_users = OrganizationUsers(invited_org_user.organization) if existing_user: existing_user.update_email_access_validated_at() invited_org_user.accept_invite() - if existing_user not in organisation_users: - existing_user.add_to_organisation(organisation_id=invited_org_user.organisation) - return redirect(url_for('main.organisation_dashboard', org_id=invited_org_user.organisation)) + if existing_user not in organization_users: + existing_user.add_to_organization(organization_id=invited_org_user.organization) + return redirect(url_for('main.organization_dashboard', org_id=invited_org_user.organization)) else: return redirect(url_for('main.register_from_org_invite')) diff --git a/app/main/views/manage_users.py b/app/main/views/manage_users.py index 52cb5c7d8..b85e8980d 100644 --- a/app/main/views/manage_users.py +++ b/app/main/views/manage_users.py @@ -71,9 +71,9 @@ def invite_user(service_id, user_id=None): 'views/user-already-invited.html', user_to_invite=user_to_invite, ) - if not user_to_invite.default_organisation: + if not user_to_invite.default_organization: abort(403) - if user_to_invite.default_organisation.id != current_service.organisation_id: + if user_to_invite.default_organization.id != current_service.organization_id: abort(403) form.email_address.data = user_to_invite.email_address else: diff --git a/app/main/views/organisations.py b/app/main/views/organizations.py similarity index 60% rename from app/main/views/organisations.py rename to app/main/views/organizations.py index 06aa44e8e..fbd2214aa 100644 --- a/app/main/views/organisations.py +++ b/app/main/views/organizations.py @@ -7,23 +7,23 @@ from flask_login import current_user from notifications_python_client.errors import HTTPError from app import ( - current_organisation, + current_organization, email_branding_client, org_invite_api_client, - organisations_client, + organizations_client, ) from app.main import main from app.main.forms import ( AdminBillingDetailsForm, - AdminNewOrganisationForm, + AdminNewOrganizationForm, AdminNotesForm, - AdminOrganisationDomainsForm, - AdminOrganisationGoLiveNotesForm, + AdminOrganizationDomainsForm, + AdminOrganizationGoLiveNotesForm, AdminPreviewBrandingForm, AdminSetEmailBrandingForm, InviteOrgUserForm, - OrganisationOrganisationTypeForm, - RenameOrganisationForm, + OrganizationOrganizationTypeForm, + RenameOrganizationForm, SearchByNameForm, SearchUsersForm, ) @@ -32,32 +32,32 @@ from app.main.views.dashboard import ( requested_and_current_financial_year, ) from app.main.views.service_settings import get_branding_as_value_and_label -from app.models.organisation import AllOrganisations, Organisation +from app.models.organization import AllOrganizations, Organization from app.models.user import InvitedOrgUser, User from app.utils.csv import Spreadsheet from app.utils.user import user_has_permissions, user_is_platform_admin -@main.route("/organisations", methods=['GET']) +@main.route("/organizations", methods=['GET']) @user_is_platform_admin -def organisations(): +def organizations(): return render_template( - 'views/organisations/index.html', - organisations=AllOrganisations(), + 'views/organizations/index.html', + organizations=AllOrganizations(), search_form=SearchByNameForm(), ) -@main.route("/organisations/add", methods=['GET', 'POST']) +@main.route("/organizations/add", methods=['GET', 'POST']) @user_is_platform_admin -def add_organisation(): - form = AdminNewOrganisationForm() +def add_organization(): + form = AdminNewOrganizationForm() if form.validate_on_submit(): try: return redirect(url_for( - '.organisation_settings', - org_id=Organisation.create_from_form(form).id, + '.organization_settings', + org_id=Organization.create_from_form(form).id, )) except HTTPError as e: msg = 'Organization name already exists' @@ -67,23 +67,23 @@ def add_organisation(): raise e return render_template( - 'views/organisations/add-organisation.html', + 'views/organizations/add-organization.html', form=form ) -@main.route("/organisations/", methods=['GET']) +@main.route("/organizations/", methods=['GET']) @user_has_permissions() -def organisation_dashboard(org_id): +def organization_dashboard(org_id): year, current_financial_year = requested_and_current_financial_year(request) - services = current_organisation.services_and_usage( + services = current_organization.services_and_usage( financial_year=year )['services'] return render_template( - 'views/organisations/organisation/index.html', + 'views/organizations/organization/index.html', services=services, years=get_tuples_of_financial_years( - partial(url_for, '.organisation_dashboard', org_id=current_organisation.id), + partial(url_for, '.organization_dashboard', org_id=current_organization.id), start=current_financial_year - 2, end=current_financial_year, ), @@ -94,18 +94,18 @@ def organisation_dashboard(org_id): for key in ('emails_sent', 'sms_cost') }, download_link=url_for( - '.download_organisation_usage_report', + '.download_organization_usage_report', org_id=org_id, selected_year=year ) ) -@main.route("/organisations//download-usage-report.csv", methods=['GET']) +@main.route("/organizations//download-usage-report.csv", methods=['GET']) @user_has_permissions() -def download_organisation_usage_report(org_id): +def download_organization_usage_report(org_id): selected_year = request.args.get('selected_year') - services_usage = current_organisation.services_and_usage( + services_usage = current_organization.services_and_usage( financial_year=selected_year )['services'] @@ -135,36 +135,36 @@ def download_organisation_usage_report(org_id): 'Content-Type': 'text/csv; charset=utf-8', 'Content-Disposition': ( 'inline;' - 'filename="{} organisation usage report for year {}' + 'filename="{} organization usage report for year {}' ' - generated on {}.csv"'.format( - current_organisation.name, + current_organization.name, selected_year, datetime.now().strftime("%Y-%m-%dT%H:%M:%S.%fZ") )) } -@main.route("/organisations//trial-services", methods=['GET']) +@main.route("/organizations//trial-services", methods=['GET']) @user_is_platform_admin -def organisation_trial_mode_services(org_id): +def organization_trial_mode_services(org_id): return render_template( - 'views/organisations/organisation/trial-mode-services.html', + 'views/organizations/organization/trial-mode-services.html', search_form=SearchByNameForm(), ) -@main.route("/organisations//users", methods=['GET']) +@main.route("/organizations//users", methods=['GET']) @user_has_permissions() def manage_org_users(org_id): return render_template( - 'views/organisations/organisation/users/index.html', - users=current_organisation.team_members, - show_search_box=(len(current_organisation.team_members) > 7), + 'views/organizations/organization/users/index.html', + users=current_organization.team_members, + show_search_box=(len(current_organization.team_members) > 7), form=SearchUsersForm(), ) -@main.route("/organisations//users/invite", methods=['GET', 'POST']) +@main.route("/organizations//users/invite", methods=['GET', 'POST']) @user_has_permissions() def invite_org_user(org_id): form = InviteOrgUserForm( @@ -182,36 +182,36 @@ def invite_org_user(org_id): return redirect(url_for('.manage_org_users', org_id=org_id)) return render_template( - 'views/organisations/organisation/users/invite-org-user.html', + 'views/organizations/organization/users/invite-org-user.html', form=form ) -@main.route("/organisations//users/", methods=['GET']) +@main.route("/organizations//users/", methods=['GET']) @user_has_permissions() -def edit_organisation_user(org_id, user_id): +def edit_organization_user(org_id, user_id): # The only action that can be done to an org user is to remove them from the org. # This endpoint is used to get the ID of the user to delete without passing it as a # query string, but it uses the template for all org team members in order to avoid # having a page containing a single link. return render_template( - 'views/organisations/organisation/users/index.html', - users=current_organisation.team_members, - show_search_box=(len(current_organisation.team_members) > 7), + 'views/organizations/organization/users/index.html', + users=current_organization.team_members, + show_search_box=(len(current_organization.team_members) > 7), form=SearchUsersForm(), user_to_remove=User.from_id(user_id) ) -@main.route("/organisations//users//delete", methods=['POST']) +@main.route("/organizations//users//delete", methods=['POST']) @user_has_permissions() -def remove_user_from_organisation(org_id, user_id): - organisations_client.remove_user_from_organisation(org_id, user_id) +def remove_user_from_organization(org_id, user_id): + organizations_client.remove_user_from_organization(org_id, user_id) return redirect(url_for('.show_accounts_or_dashboard')) -@main.route("/organisations//cancel-invited-user/", methods=['GET']) +@main.route("/organizations//cancel-invited-user/", methods=['GET']) @user_has_permissions() def cancel_invited_org_user(org_id, invited_user_id): org_invite_api_client.cancel_invited_user(org_id=org_id, invited_user_id=invited_user_id) @@ -222,23 +222,23 @@ def cancel_invited_org_user(org_id, invited_user_id): return redirect(url_for('main.manage_org_users', org_id=org_id)) -@main.route("/organisations//settings/", methods=['GET']) +@main.route("/organizations//settings/", methods=['GET']) @user_is_platform_admin -def organisation_settings(org_id): +def organization_settings(org_id): return render_template( - 'views/organisations/organisation/settings/index.html', + 'views/organizations/organization/settings/index.html', ) -@main.route("/organisations//settings/edit-name", methods=['GET', 'POST']) +@main.route("/organizations//settings/edit-name", methods=['GET', 'POST']) @user_is_platform_admin -def edit_organisation_name(org_id): - form = RenameOrganisationForm(name=current_organisation.name) +def edit_organization_name(org_id): + form = RenameOrganizationForm(name=current_organization.name) if form.validate_on_submit(): try: - current_organisation.update(name=form.name.data) + current_organization.update(name=form.name.data) except HTTPError as http_error: error_msg = 'Organization name already exists' if http_error.status_code == 400 and error_msg in http_error.message: @@ -246,91 +246,91 @@ def edit_organisation_name(org_id): else: raise http_error else: - return redirect(url_for('.organisation_settings', org_id=org_id)) + return redirect(url_for('.organization_settings', org_id=org_id)) return render_template( - 'views/organisations/organisation/settings/edit-name.html', + 'views/organizations/organization/settings/edit-name.html', form=form, ) -@main.route("/organisations//settings/edit-type", methods=['GET', 'POST']) +@main.route("/organizations//settings/edit-type", methods=['GET', 'POST']) @user_is_platform_admin -def edit_organisation_type(org_id): +def edit_organization_type(org_id): - form = OrganisationOrganisationTypeForm( - organisation_type=current_organisation.organisation_type + form = OrganizationOrganizationTypeForm( + organization_type=current_organization.organization_type ) if form.validate_on_submit(): - current_organisation.update( - organisation_type=form.organisation_type.data, + current_organization.update( + organization_type=form.organization_type.data, delete_services_cache=True, ) - return redirect(url_for('.organisation_settings', org_id=org_id)) + return redirect(url_for('.organization_settings', org_id=org_id)) return render_template( - 'views/organisations/organisation/settings/edit-type.html', + 'views/organizations/organization/settings/edit-type.html', form=form, ) -@main.route("/organisations//settings/set-email-branding", methods=['GET', 'POST']) +@main.route("/organizations//settings/set-email-branding", methods=['GET', 'POST']) @user_is_platform_admin -def edit_organisation_email_branding(org_id): +def edit_organization_email_branding(org_id): email_branding = email_branding_client.get_all_email_branding() form = AdminSetEmailBrandingForm( all_branding_options=get_branding_as_value_and_label(email_branding), - current_branding=current_organisation.email_branding_id, + current_branding=current_organization.email_branding_id, ) if form.validate_on_submit(): return redirect(url_for( - '.organisation_preview_email_branding', + '.organization_preview_email_branding', org_id=org_id, branding_style=form.branding_style.data, )) return render_template( - 'views/organisations/organisation/settings/set-email-branding.html', + 'views/organizations/organization/settings/set-email-branding.html', form=form, search_form=SearchByNameForm() ) -@main.route("/organisations//settings/preview-email-branding", methods=['GET', 'POST']) +@main.route("/organizations//settings/preview-email-branding", methods=['GET', 'POST']) @user_is_platform_admin -def organisation_preview_email_branding(org_id): +def organization_preview_email_branding(org_id): branding_style = request.args.get('branding_style', None) form = AdminPreviewBrandingForm(branding_style=branding_style) if form.validate_on_submit(): - current_organisation.update( + current_organization.update( email_branding_id=form.branding_style.data, delete_services_cache=True, ) - return redirect(url_for('.organisation_settings', org_id=org_id)) + return redirect(url_for('.organization_settings', org_id=org_id)) return render_template( - 'views/organisations/organisation/settings/preview-email-branding.html', + 'views/organizations/organization/settings/preview-email-branding.html', form=form, - action=url_for('main.organisation_preview_email_branding', org_id=org_id), + action=url_for('main.organization_preview_email_branding', org_id=org_id), ) -@main.route("/organisations//settings/edit-organisation-domains", methods=['GET', 'POST']) +@main.route("/organizations//settings/edit-organization-domains", methods=['GET', 'POST']) @user_is_platform_admin -def edit_organisation_domains(org_id): +def edit_organization_domains(org_id): - form = AdminOrganisationDomainsForm() + form = AdminOrganizationDomainsForm() if form.validate_on_submit(): try: - organisations_client.update_organisation( + organizations_client.update_organization( org_id, domains=list(OrderedDict.fromkeys( domain.lower() @@ -342,94 +342,94 @@ def edit_organisation_domains(org_id): if e.status_code == 400 and error_message in e.message: flash("This domain is already in use", "error") return render_template( - 'views/organisations/organisation/settings/edit-domains.html', + 'views/organizations/organization/settings/edit-domains.html', form=form, ) else: raise e - return redirect(url_for('.organisation_settings', org_id=org_id)) + return redirect(url_for('.organization_settings', org_id=org_id)) - form.populate(current_organisation.domains) + form.populate(current_organization.domains) return render_template( - 'views/organisations/organisation/settings/edit-domains.html', + 'views/organizations/organization/settings/edit-domains.html', form=form, ) -@main.route("/organisations//settings/edit-go-live-notes", methods=['GET', 'POST']) +@main.route("/organizations//settings/edit-go-live-notes", methods=['GET', 'POST']) @user_is_platform_admin -def edit_organisation_go_live_notes(org_id): +def edit_organization_go_live_notes(org_id): - form = AdminOrganisationGoLiveNotesForm() + form = AdminOrganizationGoLiveNotesForm() if form.validate_on_submit(): - organisations_client.update_organisation( + organizations_client.update_organization( org_id, request_to_go_live_notes=form.request_to_go_live_notes.data ) - return redirect(url_for('.organisation_settings', org_id=org_id)) + return redirect(url_for('.organization_settings', org_id=org_id)) - org = organisations_client.get_organisation(org_id) + org = organizations_client.get_organization(org_id) form.request_to_go_live_notes.data = org['request_to_go_live_notes'] return render_template( - 'views/organisations/organisation/settings/edit-go-live-notes.html', + 'views/organizations/organization/settings/edit-go-live-notes.html', form=form, ) -@main.route("/organisations//settings/notes", methods=['GET', 'POST']) +@main.route("/organizations//settings/notes", methods=['GET', 'POST']) @user_is_platform_admin -def edit_organisation_notes(org_id): - form = AdminNotesForm(notes=current_organisation.notes) +def edit_organization_notes(org_id): + form = AdminNotesForm(notes=current_organization.notes) if form.validate_on_submit(): - if form.notes.data == current_organisation.notes: - return redirect(url_for('.organisation_settings', org_id=org_id)) + if form.notes.data == current_organization.notes: + return redirect(url_for('.organization_settings', org_id=org_id)) - current_organisation.update( + current_organization.update( notes=form.notes.data ) - return redirect(url_for('.organisation_settings', org_id=org_id)) + return redirect(url_for('.organization_settings', org_id=org_id)) return render_template( - 'views/organisations/organisation/settings/edit-organisation-notes.html', + 'views/organizations/organization/settings/edit-organization-notes.html', form=form, ) -@main.route("/organisations//settings/edit-billing-details", methods=['GET', 'POST']) +@main.route("/organizations//settings/edit-billing-details", methods=['GET', 'POST']) @user_is_platform_admin -def edit_organisation_billing_details(org_id): +def edit_organization_billing_details(org_id): form = AdminBillingDetailsForm( - billing_contact_email_addresses=current_organisation.billing_contact_email_addresses, - billing_contact_names=current_organisation.billing_contact_names, - billing_reference=current_organisation.billing_reference, - purchase_order_number=current_organisation.purchase_order_number, - notes=current_organisation.notes, + billing_contact_email_addresses=current_organization.billing_contact_email_addresses, + billing_contact_names=current_organization.billing_contact_names, + billing_reference=current_organization.billing_reference, + purchase_order_number=current_organization.purchase_order_number, + notes=current_organization.notes, ) if form.validate_on_submit(): - current_organisation.update( + current_organization.update( billing_contact_email_addresses=form.billing_contact_email_addresses.data, billing_contact_names=form.billing_contact_names.data, billing_reference=form.billing_reference.data, purchase_order_number=form.purchase_order_number.data, notes=form.notes.data, ) - return redirect(url_for('.organisation_settings', org_id=org_id)) + return redirect(url_for('.organization_settings', org_id=org_id)) return render_template( - 'views/organisations/organisation/settings/edit-organisation-billing-details.html', + 'views/organizations/organization/settings/edit-organization-billing-details.html', form=form, ) -@main.route("/organisations//billing") +@main.route("/organizations//billing") @user_is_platform_admin -def organisation_billing(org_id): +def organization_billing(org_id): return render_template( - 'views/organisations/organisation/billing.html' + 'views/organizations/organization/billing.html' ) diff --git a/app/main/views/performance.py b/app/main/views/performance.py index e9dae91cf..efd41ed18 100644 --- a/app/main/views/performance.py +++ b/app/main/views/performance.py @@ -16,25 +16,25 @@ def performance(): start_date=(datetime.now(pytz.utc) - timedelta(days=7)).date(), end_date=datetime.now(pytz.utc).date(), ) - stats['organisations_using_notify'] = sorted( + stats['organizations_using_notify'] = sorted( [ { - 'organisation_name': organisation_name or 'No organization', + 'organization_name': organization_name or 'No organization', 'count_of_live_services': len(list(group)), } - for organisation_name, group in groupby( + for organization_name, group in groupby( stats['services_using_notify'], - itemgetter('organisation_name'), + itemgetter('organization_name'), ) ], - key=itemgetter('organisation_name'), + key=itemgetter('organization_name'), ) stats['average_percentage_under_10_seconds'] = mean([ row['percentage_under_10_seconds'] for row in stats['processing_time'] ] or [0]) - stats['count_of_live_services_and_organisations'] = ( - status_api_client.get_count_of_live_services_and_organisations() + stats['count_of_live_services_and_organizations'] = ( + status_api_client.get_count_of_live_services_and_organizations() ) return render_template( 'views/performance.html', diff --git a/app/main/views/platform_admin.py b/app/main/views/platform_admin.py index ba2ef401b..a34ea51c4 100644 --- a/app/main/views/platform_admin.py +++ b/app/main/views/platform_admin.py @@ -193,8 +193,8 @@ def live_services_csv(): column_names = OrderedDict([ ('service_id', 'Service ID'), - ('organisation_name', 'Organization'), - ('organisation_type', 'Organization type'), + ('organization_name', 'Organization'), + ('organization_type', 'Organization type'), ('service_name', 'Service name'), ('consent_to_research', 'Consent to research'), ('contact_name', 'Main contact'), @@ -258,7 +258,7 @@ def get_billing_report(): start_date = form.start_date.data end_date = form.end_date.data headers = [ - "organisation_id", "organisation_name", "service_id", "service_name", + "organization_id", "organization_name", "service_id", "service_name", "sms_cost", "sms_chargeable_units", "purchase_order_number", "contact_names", "contact_email_addresses", "billing_reference" ] @@ -273,7 +273,7 @@ def get_billing_report(): raise e rows = [ [ - r["organisation_id"], r["organisation_name"], r["service_id"], r["service_name"], + r["organization_id"], r["organization_name"], r["service_id"], r["service_name"], r["sms_cost"], r["sms_chargeable_units"], r.get("purchase_order_number"), r.get("contact_names"), r.get("contact_email_addresses"), r.get("billing_reference") @@ -301,14 +301,14 @@ def get_volumes_by_service(): start_date = form.start_date.data end_date = form.end_date.data headers = [ - "organisation id", "organisation name", "service id", "service name", + "organization id", "organization name", "service id", "service name", "free allowance", "sms notifications", "sms chargeable units", "email totals", ] result = billing_api_client.get_data_for_volumes_by_service_report(start_date, end_date) rows = [ [ - r["organisation_id"], r["organisation_name"], r["service_id"], r["service_name"], + r["organization_id"], r["organization_name"], r["service_id"], r["service_name"], r["free_allowance"], r["sms_notifications"], r["sms_chargeable_units"], r["email_totals"], ] for r in result @@ -447,11 +447,11 @@ def clear_cache(): 'email_branding', 'email_branding-????????-????-????-????-????????????', ]), - ('organisation', [ - 'organisations', + ('organization', [ + 'organizations', 'domains', - 'live-service-and-organisation-counts', - 'organisation-????????-????-????-????-????????????-name', + 'live-service-and-organization-counts', + 'organization-????????-????-????-????-????????????-name', ]), ]) diff --git a/app/main/views/register.py b/app/main/views/register.py index 35693a5ee..51136989c 100644 --- a/app/main/views/register.py +++ b/app/main/views/register.py @@ -63,17 +63,17 @@ def register_from_org_invite(): form.auth_type.data = 'sms_auth' if form.validate_on_submit(): - if (form.organisation.data != invited_org_user.organisation or + if (form.organization.data != invited_org_user.organization or form.email_address.data != invited_org_user.email_address): abort(400) - _do_registration(form, send_email=False, send_sms=True, organisation_id=invited_org_user.organisation) + _do_registration(form, send_email=False, send_sms=True, organization_id=invited_org_user.organization) invited_org_user.accept_invite() return redirect(url_for('main.verify')) return render_template('views/register-from-org-invite.html', invited_org_user=invited_org_user, form=form) -def _do_registration(form, send_sms=True, send_email=True, organisation_id=None): +def _do_registration(form, send_sms=True, send_email=True, organization_id=None): user = User.from_email_address_or_none(form.email_address.data) if user: if send_email: @@ -96,8 +96,8 @@ def _do_registration(form, send_sms=True, send_email=True, organisation_id=None) user.send_verify_code() session['expiry_date'] = str(datetime.utcnow() + timedelta(hours=1)) session['user_details'] = {"email": user.email_address, "id": user.id} - if organisation_id: - session['organisation_id'] = organisation_id + if organization_id: + session['organization_id'] = organization_id @main.route('/registration-continue') diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index 96382cdcc..78c5bee1b 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -23,7 +23,7 @@ from app import ( email_branding_client, inbound_number_client, notification_api_client, - organisations_client, + organizations_client, service_api_client, ) from app.event_handlers import ( @@ -45,7 +45,7 @@ from app.main.forms import ( AdminServiceRateLimitForm, AdminServiceSMSAllowanceForm, AdminSetEmailBrandingForm, - AdminSetOrganisationForm, + AdminSetOrganizationForm, ChooseEmailBrandingForm, EstimateUsageForm, RenameServiceForm, @@ -108,7 +108,7 @@ def service_name_change(service_id): else: return redirect(url_for('.service_settings', service_id=service_id)) - if current_service.organisation_type == 'local': + if current_service.organization_type == 'local': return render_template( 'views/service-settings/name-local.html', form=form, @@ -174,8 +174,8 @@ def submit_request_to_go_live(service_id): user_name=current_user.name, user_email=current_user.email_address, requester_sees_message_content=False, - org_id=current_service.organisation_id, - org_type=current_service.organisation_type, + org_id=current_service.organization_id, + org_type=current_service.organization_type, service_id=current_service.id, ) zendesk_client.send_ticket_to_zendesk(ticket) @@ -818,28 +818,28 @@ def service_preview_email_branding(service_id): ) -@main.route("/services//service-settings/link-service-to-organisation", methods=['GET', 'POST']) +@main.route("/services//service-settings/link-service-to-organization", methods=['GET', 'POST']) @user_is_platform_admin -def link_service_to_organisation(service_id): +def link_service_to_organization(service_id): - all_organisations = organisations_client.get_organisations() + all_organizations = organizations_client.get_organizations() - form = AdminSetOrganisationForm( - choices=convert_dictionary_to_wtforms_choices_format(all_organisations, 'id', 'name'), - organisations=current_service.organisation_id + form = AdminSetOrganizationForm( + choices=convert_dictionary_to_wtforms_choices_format(all_organizations, 'id', 'name'), + organizations=current_service.organization_id ) if form.validate_on_submit(): - if form.organisations.data != current_service.organisation_id: - organisations_client.update_service_organisation( + if form.organizations.data != current_service.organization_id: + organizations_client.update_service_organization( service_id, - form.organisations.data + form.organizations.data ) return redirect(url_for('.service_settings', service_id=service_id)) return render_template( - 'views/service-settings/link-service-to-organisation.html', - has_organisations=all_organisations, + 'views/service-settings/link-service-to-organization.html', + has_organizations=all_organizations, form=form, search_form=SearchByNameForm(), ) @@ -860,8 +860,8 @@ def create_email_branding_zendesk_ticket(form_option_selected, detail=None): ticket_type=NotifySupportTicket.TYPE_QUESTION, user_name=current_user.name, user_email=current_user.email_address, - org_id=current_service.organisation_id, - org_type=current_service.organisation_type, + org_id=current_service.organization_id, + org_type=current_service.organization_type, service_id=current_service.id ) zendesk_client.send_ticket_to_zendesk(ticket) @@ -941,18 +941,18 @@ def email_branding_nhs(service_id): ) -@main.route("/services//service-settings/email-branding/organisation", methods=['GET', 'POST']) +@main.route("/services//service-settings/email-branding/organization", methods=['GET', 'POST']) @user_has_permissions('manage_service') -def email_branding_organisation(service_id): - check_email_branding_allowed_for_service('organisation') +def email_branding_organization(service_id): + check_email_branding_allowed_for_service('organization') if request.method == 'POST': - create_email_branding_zendesk_ticket('organisation') + create_email_branding_zendesk_ticket('organization') flash('Thanks for your branding request. We’ll get back to you within one working day.', 'default') return redirect(url_for('.service_settings', service_id=current_service.id)) - return render_template('views/service-settings/branding/email-branding-organisation.html') + return render_template('views/service-settings/branding/email-branding-organization.html') @main.route("/services//service-settings/email-branding/something-else", methods=['GET', 'POST']) diff --git a/app/main/views/verify.py b/app/main/views/verify.py index e98aa5e45..25e5d2df0 100644 --- a/app/main/views/verify.py +++ b/app/main/views/verify.py @@ -72,7 +72,7 @@ def activate_user(user_id): user = User.from_id(user_id) # the user will have a new current_session_id set by the API - store it in the cookie for future requests session['current_session_id'] = user.current_session_id - organisation_id = session.get('organisation_id') + organization_id = session.get('organization_id') activated_user = user.activate() activated_user.login() @@ -83,10 +83,10 @@ def activate_user(user_id): invited_org_user = InvitedOrgUser.from_session() if invited_org_user: - user_api_client.add_user_to_organisation(invited_org_user.organisation, user_id) + user_api_client.add_user_to_organization(invited_org_user.organization, user_id) - if organisation_id: - return redirect(url_for('main.organisation_dashboard', org_id=organisation_id)) + if organization_id: + return redirect(url_for('main.organization_dashboard', org_id=organization_id)) else: return redirect(url_for('main.add_service', first='first')) diff --git a/app/models/organisation.py b/app/models/organization.py similarity index 71% rename from app/models/organisation.py rename to app/models/organization.py index dc5543d94..2e5977a7d 100644 --- a/app/models/organisation.py +++ b/app/models/organization.py @@ -9,10 +9,10 @@ from app.models import ( SortByNameMixin, ) from app.notify_client.email_branding_client import email_branding_client -from app.notify_client.organisations_api_client import organisations_client +from app.notify_client.organizations_api_client import organizations_client -class Organisation(JSONModel, SortByNameMixin): +class Organization(JSONModel, SortByNameMixin): TYPE_FEDERAL = 'federal' TYPE_STATE = 'state' @@ -28,7 +28,7 @@ class Organisation(JSONModel, SortByNameMixin): 'id', 'name', 'active', - 'organisation_type', + 'organization_type', 'email_branding_id', 'domains', 'request_to_go_live_notes', @@ -44,28 +44,28 @@ class Organisation(JSONModel, SortByNameMixin): def from_id(cls, org_id): if not org_id: return cls({}) - return cls(organisations_client.get_organisation(org_id)) + return cls(organizations_client.get_organization(org_id)) @classmethod def from_domain(cls, domain): - return cls(organisations_client.get_organisation_by_domain(domain)) + return cls(organizations_client.get_organization_by_domain(domain)) @classmethod def from_service(cls, service_id): - return cls(organisations_client.get_service_organisation(service_id)) + return cls(organizations_client.get_service_organization(service_id)) @classmethod def create_from_form(cls, form): return cls.create( name=form.name.data, - organisation_type=form.organisation_type.data, + organization_type=form.organization_type.data, ) @classmethod - def create(cls, name, organisation_type): - return cls(organisations_client.create_organisation( + def create(cls, name, organization_type): + return cls(organizations_client.create_organization( name=name, - organisation_type=organisation_type, + organization_type=organization_type, )) def __init__(self, _dict): @@ -75,13 +75,13 @@ class Organisation(JSONModel, SortByNameMixin): if self._dict == {}: self.name = None self.domains = [] - self.organisation_type = None + self.organization_type = None self.request_to_go_live_notes = None self.email_branding_id = None @property - def organisation_type_label(self): - return self.TYPE_LABELS.get(self.organisation_type) + def organization_type_label(self): + return self.TYPE_LABELS.get(self.organization_type) @property def billing_details(self): @@ -98,7 +98,7 @@ class Organisation(JSONModel, SortByNameMixin): @cached_property def services(self): - return organisations_client.get_organisation_services(self.id) + return organizations_client.get_organization_services(self.id) @cached_property def service_ids(self): @@ -114,13 +114,13 @@ class Organisation(JSONModel, SortByNameMixin): @cached_property def invited_users(self): - from app.models.user import OrganisationInvitedUsers - return OrganisationInvitedUsers(self.id) + from app.models.user import OrganizationInvitedUsers + return OrganizationInvitedUsers(self.id) @cached_property def active_users(self): - from app.models.user import OrganisationUsers - return OrganisationUsers(self.id) + from app.models.user import OrganizationUsers + return OrganizationUsers(self.id) @cached_property def team_members(self): @@ -143,7 +143,7 @@ class Organisation(JSONModel, SortByNameMixin): return 'GOV.UK' def update(self, delete_services_cache=False, **kwargs): - response = organisations_client.update_organisation( + response = organizations_client.update_organization( self.id, cached_service_ids=self.service_ids if delete_services_cache else None, **kwargs @@ -151,18 +151,18 @@ class Organisation(JSONModel, SortByNameMixin): self.__init__(response) def associate_service(self, service_id): - organisations_client.update_service_organisation( + organizations_client.update_service_organization( service_id, self.id ) def services_and_usage(self, financial_year): - return organisations_client.get_services_and_usage(self.id, financial_year) + return organizations_client.get_services_and_usage(self.id, financial_year) -class Organisations(SerialisedModelCollection): - model = Organisation +class Organizations(SerialisedModelCollection): + model = Organization -class AllOrganisations(ModelList, Organisations): - client_method = organisations_client.get_organisations +class AllOrganizations(ModelList, Organizations): + client_method = organizations_client.get_organizations diff --git a/app/models/service.py b/app/models/service.py index d3a32a0c6..9bd5cc1b4 100644 --- a/app/models/service.py +++ b/app/models/service.py @@ -9,7 +9,7 @@ from app.models.job import ( PaginatedUploads, ScheduledJobs, ) -from app.models.organisation import Organisation +from app.models.organization import Organization from app.models.user import InvitedUsers, User, Users from app.notify_client.api_key_api_client import api_key_api_client from app.notify_client.billing_api_client import billing_api_client @@ -17,7 +17,7 @@ from app.notify_client.email_branding_client import email_branding_client from app.notify_client.inbound_number_client import inbound_number_client from app.notify_client.invite_api_client import invite_api_client from app.notify_client.job_api_client import job_api_client -from app.notify_client.organisations_api_client import organisations_client +from app.notify_client.organizations_api_client import organizations_client from app.notify_client.service_api_client import service_api_client from app.notify_client.template_folder_api_client import ( template_folder_api_client, @@ -314,7 +314,7 @@ class Service(JSONModel, SortByNameMixin): @property def shouldnt_use_govuk_as_sms_sender(self): - return self.organisation_type != Organisation.TYPE_CENTRAL + return self.organization_type != Organization.TYPE_CENTRAL @cached_property def sms_senders(self): @@ -417,29 +417,29 @@ class Service(JSONModel, SortByNameMixin): @property def needs_to_change_email_branding(self): - return self.email_branding_id is None and self.organisation_type != Organisation.TYPE_CENTRAL + return self.email_branding_id is None and self.organization_type != Organization.TYPE_CENTRAL @cached_property - def organisation(self): - return Organisation.from_id(self.organisation_id) + def organization(self): + return Organization.from_id(self.organization_id) @property - def organisation_id(self): - return self._dict['organisation'] + def organization_id(self): + return self._dict['organization'] @property - def organisation_type(self): - return self.organisation.organisation_type or self._dict['organisation_type'] + def organization_type(self): + return self.organization.organization_type or self._dict['organization_type'] @property - def organisation_name(self): - if not self.organisation_id: + def organization_name(self): + if not self.organization_id: return None - return organisations_client.get_organisation_name(self.organisation_id) + return organizations_client.get_organization_name(self.organization_id) @property - def organisation_type_label(self): - return Organisation.TYPE_LABELS.get(self.organisation_type) + def organization_type_label(self): + return Organization.TYPE_LABELS.get(self.organization_type) @cached_property def inbound_number(self): diff --git a/app/models/user.py b/app/models/user.py index bb1403e6c..e62006348 100644 --- a/app/models/user.py +++ b/app/models/user.py @@ -10,7 +10,7 @@ from app.event_handlers import ( create_set_user_permissions_event, ) from app.models import JSONModel, ModelList -from app.models.organisation import Organisation, Organisations +from app.models.organization import Organization, Organizations from app.models.webauthn_credential import WebAuthnCredentials from app.notify_client import InviteTokenError from app.notify_client.invite_api_client import invite_api_client @@ -223,7 +223,7 @@ class User(JSONModel, UserMixin): org_id = _get_org_id_from_view_args() if not service_id and not org_id: - # we shouldn't have any pages that require permissions, but don't specify a service or organisation. + # we shouldn't have any pages that require permissions, but don't specify a service or organization. # use @user_is_platform_admin for platform admin only pages raise NotImplementedError @@ -234,7 +234,7 @@ class User(JSONModel, UserMixin): return True if org_id: - value = self.belongs_to_organisation(org_id) + value = self.belongs_to_organization(org_id) current_app.logger.warn(f"{log_msg} org: {org_id} returning {value}") return value @@ -250,8 +250,8 @@ class User(JSONModel, UserMixin): from app.models.service import Service - org_value = allow_org_user and self.belongs_to_organisation( - Service.from_id(service_id).organisation_id + org_value = allow_org_user and self.belongs_to_organization( + Service.from_id(service_id).organization_id ) current_app.logger.warn(f"{log_msg} returning {org_value}") return org_value @@ -294,8 +294,8 @@ class User(JSONModel, UserMixin): if not self.belongs_to_service(service_id): abort(403) - def belongs_to_organisation(self, organisation_id): - return str(organisation_id) in self.organisation_ids + def belongs_to_organization(self, organization_id): + return str(organization_id) in self.organization_ids @property def locked(self): @@ -307,7 +307,7 @@ class User(JSONModel, UserMixin): @cached_property def orgs_and_services(self): - return user_api_client.get_organisations_and_services_for_user(self.id) + return user_api_client.get_organizations_and_services_for_user(self.id) @property def services(self): @@ -315,10 +315,10 @@ class User(JSONModel, UserMixin): return Services(self.orgs_and_services['services']) @property - def services_with_organisation(self): + def services_with_organization(self): return [ service for service in self.services - if self.belongs_to_organisation(service.organisation_id) + if self.belongs_to_organization(service.organization_id) ] @property @@ -338,21 +338,21 @@ class User(JSONModel, UserMixin): ] @property - def organisations(self): - return Organisations(self.orgs_and_services['organisations']) + def organizations(self): + return Organizations(self.orgs_and_services['organizations']) @property - def organisation_ids(self): - return self._dict['organisations'] + def organization_ids(self): + return self._dict['organizations'] @cached_property - def default_organisation(self): - return Organisation.from_domain(self.email_domain) + def default_organization(self): + return Organization.from_domain(self.email_domain) @property - def default_organisation_type(self): - if self.default_organisation: - return self.default_organisation.organisation_type + def default_organization_type(self): + if self.default_organization: + return self.default_organization.organization_type if self.has_nhs_email_address: return 'nhs' return None @@ -360,7 +360,7 @@ class User(JSONModel, UserMixin): @property def has_access_to_live_and_trial_mode_services(self): return ( - self.organisations or self.live_services + self.organizations or self.live_services ) and ( self.trial_mode_services ) @@ -390,7 +390,7 @@ class User(JSONModel, UserMixin): "state": self.state, "failed_login_count": self.failed_login_count, "permissions": [x for x in self._permissions], - "organisations": self.organisation_ids, + "organizations": self.organization_ids, "current_session_id": self.current_session_id } if hasattr(self, '_password'): @@ -450,9 +450,9 @@ class User(JSONModel, UserMixin): else: raise exception - def add_to_organisation(self, organisation_id): - user_api_client.add_user_to_organisation( - organisation_id, + def add_to_organization(self, organization_id): + user_api_client.add_user_to_organization( + organization_id, self.id, ) @@ -611,7 +611,7 @@ class InvitedOrgUser(JSONModel): ALLOWED_PROPERTIES = { 'id', - 'organisation', + 'organization', 'email_address', 'status', 'created_at', @@ -623,11 +623,11 @@ class InvitedOrgUser(JSONModel): def __eq__(self, other): return ((self.id, - self.organisation, + self.organization, self._invited_by, self.email_address, self.status) == (other.id, - other.organisation, + other.organization, other._invited_by, other.email_address, other.status)) @@ -657,7 +657,7 @@ class InvitedOrgUser(JSONModel): def serialize(self, permissions_as_string=False): data = {'id': self.id, - 'organisation': self.organisation, + 'organization': self.organization, 'invited_by': self._invited_by, 'email_address': self.email_address, 'status': self.status, @@ -680,7 +680,7 @@ class InvitedOrgUser(JSONModel): raise exception def accept_invite(self): - org_invite_api_client.accept_invite(self.organisation, self.id) + org_invite_api_client.accept_invite(self.organization, self.id) class AnonymousUser(AnonymousUserMixin): @@ -690,8 +690,8 @@ class AnonymousUser(AnonymousUserMixin): return False @property - def default_organisation(self): - return Organisation(None) + def default_organization(self): + return Organization(None) class Users(ModelList): @@ -712,8 +712,8 @@ class Users(ModelList): return 'Unknown' -class OrganisationUsers(Users): - client_method = user_api_client.get_users_for_organisation +class OrganizationUsers(Users): + client_method = user_api_client.get_users_for_organization class InvitedUsers(Users): @@ -728,6 +728,6 @@ class InvitedUsers(Users): ] -class OrganisationInvitedUsers(InvitedUsers): - client_method = org_invite_api_client.get_invites_for_organisation +class OrganizationInvitedUsers(InvitedUsers): + client_method = org_invite_api_client.get_invites_for_organization model = InvitedOrgUser diff --git a/app/navigation.py b/app/navigation.py index 116c95176..09065c58a 100644 --- a/app/navigation.py +++ b/app/navigation.py @@ -98,7 +98,7 @@ class HeaderNavigation(Navigation): 'get_daily_volumes', 'get_daily_sms_provider_volumes', 'get_volumes_by_service', - 'organisations', + 'organizations', 'platform_admin', 'platform_admin_list_complaints', 'platform_admin_reports', @@ -182,16 +182,16 @@ class MainNavigation(Navigation): 'usage', }, 'settings': { - # 'add_organisation_from_gp_service', - # 'add_organisation_from_nhs_local_service', + # 'add_organization_from_gp_service', + # 'add_organization_from_nhs_local_service', 'email_branding_govuk', 'email_branding_govuk_and_org', 'email_branding_nhs', - 'email_branding_organisation', + 'email_branding_organization', 'email_branding_request', 'email_branding_something_else', 'estimate_usage', - 'link_service_to_organisation', + 'link_service_to_organization', 'request_to_go_live', 'service_add_email_reply_to', 'service_add_sms_sender', @@ -260,31 +260,31 @@ class OrgNavigation(Navigation): mapping = { 'dashboard': { - 'organisation_dashboard', + 'organization_dashboard', }, 'settings': { - 'edit_organisation_billing_details', - 'edit_organisation_domains', - 'edit_organisation_email_branding', - 'edit_organisation_domains', - 'edit_organisation_go_live_notes', - 'edit_organisation_name', - 'edit_organisation_notes', - 'edit_organisation_type', - 'organisation_preview_email_branding', - 'organisation_settings', + 'edit_organization_billing_details', + 'edit_organization_domains', + 'edit_organization_email_branding', + 'edit_organization_domains', + 'edit_organization_go_live_notes', + 'edit_organization_name', + 'edit_organization_notes', + 'edit_organization_type', + 'organization_preview_email_branding', + 'organization_settings', }, 'team-members': { - 'edit_organisation_user', + 'edit_organization_user', 'invite_org_user', 'manage_org_users', - 'remove_user_from_organisation', + 'remove_user_from_organization', }, 'trial-services': { - 'organisation_trial_mode_services', + 'organization_trial_mode_services', }, 'billing': { - 'organisation_billing', + 'organization_billing', } } diff --git a/app/notify_client/org_invite_api_client.py b/app/notify_client/org_invite_api_client.py index 23c1d7b99..60563a537 100644 --- a/app/notify_client/org_invite_api_client.py +++ b/app/notify_client/org_invite_api_client.py @@ -15,37 +15,37 @@ class OrgInviteApiClient(NotifyAdminAPIClient): 'invite_link_host': self.admin_url, } data = _attach_current_user(data) - resp = self.post(url='/organisation/{}/invite'.format(org_id), data=data) + resp = self.post(url='/organization/{}/invite'.format(org_id), data=data) return resp['data'] - def get_invites_for_organisation(self, org_id): - endpoint = '/organisation/{}/invite'.format(org_id) + def get_invites_for_organization(self, org_id): + endpoint = '/organization/{}/invite'.format(org_id) resp = self.get(endpoint) return resp['data'] def get_invited_user_for_org(self, org_id, invited_org_user_id): return self.get( - f'/organisation/{org_id}/invite/{invited_org_user_id}' + f'/organization/{org_id}/invite/{invited_org_user_id}' )['data'] def get_invited_user(self, invited_user_id): return self.get( - f'/invite/organisation/{invited_user_id}' + f'/invite/organization/{invited_user_id}' )['data'] def check_token(self, token): - resp = self.get(url='/invite/organisation/check/{}'.format(token)) + resp = self.get(url='/invite/organization/check/{}'.format(token)) return resp['data'] def cancel_invited_user(self, org_id, invited_user_id): data = {'status': 'cancelled'} data = _attach_current_user(data) - self.post(url='/organisation/{0}/invite/{1}'.format(org_id, invited_user_id), + self.post(url='/organization/{0}/invite/{1}'.format(org_id, invited_user_id), data=data) def accept_invite(self, org_id, invited_user_id): data = {'status': 'accepted'} - self.post(url='/organisation/{0}/invite/{1}'.format(org_id, invited_user_id), + self.post(url='/organization/{0}/invite/{1}'.format(org_id, invited_user_id), data=data) diff --git a/app/notify_client/organisations_api_client.py b/app/notify_client/organisations_api_client.py deleted file mode 100644 index 21e9e4450..000000000 --- a/app/notify_client/organisations_api_client.py +++ /dev/null @@ -1,88 +0,0 @@ -from itertools import chain - -from notifications_python_client.errors import HTTPError - -from app.extensions import redis_client -from app.notify_client import NotifyAdminAPIClient, cache - - -class OrganisationsClient(NotifyAdminAPIClient): - - @cache.set('organisations') - def get_organisations(self): - return self.get(url='/organisations') - - @cache.set('domains') - def get_domains(self): - return list(chain.from_iterable( - organisation['domains'] - for organisation in self.get_organisations() - )) - - def get_organisation(self, org_id): - return self.get(url='/organisations/{}'.format(org_id)) - - @cache.set('organisation-{org_id}-name') - def get_organisation_name(self, org_id): - return self.get_organisation(org_id)['name'] - - def get_organisation_by_domain(self, domain): - try: - return self.get( - url='/organisations/by-domain?domain={}'.format(domain), - ) - except HTTPError as error: - if error.status_code == 404: - return None - raise error - - @cache.delete('organisations') - def create_organisation(self, name, organisation_type): - return self.post( - url="/organisations", - data={ - "name": name, - "organisation_type": organisation_type, - } - ) - - @cache.delete('domains') - @cache.delete('organisations') - def update_organisation(self, org_id, cached_service_ids=None, **kwargs): - api_response = self.post(url="/organisations/{}".format(org_id), data=kwargs) - - if cached_service_ids: - redis_client.delete(*map('service-{}'.format, cached_service_ids)) - - if 'name' in kwargs: - redis_client.delete(f'organisation-{org_id}-name') - - return api_response - - @cache.delete('service-{service_id}') - @cache.delete('live-service-and-organisation-counts') - @cache.delete('organisations') - def update_service_organisation(self, service_id, org_id): - data = { - 'service_id': service_id - } - return self.post( - url="/organisations/{}/service".format(org_id), - data=data - ) - - def get_organisation_services(self, org_id): - return self.get(url="/organisations/{}/services".format(org_id)) - - @cache.delete('user-{user_id}') - def remove_user_from_organisation(self, org_id, user_id): - return self.delete(f'/organisations/{org_id}/users/{user_id}') - - def get_services_and_usage(self, org_id, year): - return self.get( - url=f"/organisations/{org_id}/services-with-usage", - params={"year": str(year)} - ) - - -organisations_client = OrganisationsClient() diff --git a/app/notify_client/organizations_api_client.py b/app/notify_client/organizations_api_client.py new file mode 100644 index 000000000..18935c47a --- /dev/null +++ b/app/notify_client/organizations_api_client.py @@ -0,0 +1,88 @@ +from itertools import chain + +from notifications_python_client.errors import HTTPError + +from app.extensions import redis_client +from app.notify_client import NotifyAdminAPIClient, cache + + +class OrganizationsClient(NotifyAdminAPIClient): + + @cache.set('organizations') + def get_organizations(self): + return self.get(url='/organizations') + + @cache.set('domains') + def get_domains(self): + return list(chain.from_iterable( + organization['domains'] + for organization in self.get_organizations() + )) + + def get_organization(self, org_id): + return self.get(url='/organizations/{}'.format(org_id)) + + @cache.set('organization-{org_id}-name') + def get_organization_name(self, org_id): + return self.get_organization(org_id)['name'] + + def get_organization_by_domain(self, domain): + try: + return self.get( + url='/organizations/by-domain?domain={}'.format(domain), + ) + except HTTPError as error: + if error.status_code == 404: + return None + raise error + + @cache.delete('organizations') + def create_organization(self, name, organization_type): + return self.post( + url="/organizations", + data={ + "name": name, + "organization_type": organization_type, + } + ) + + @cache.delete('domains') + @cache.delete('organizations') + def update_organization(self, org_id, cached_service_ids=None, **kwargs): + api_response = self.post(url="/organizations/{}".format(org_id), data=kwargs) + + if cached_service_ids: + redis_client.delete(*map('service-{}'.format, cached_service_ids)) + + if 'name' in kwargs: + redis_client.delete(f'organization-{org_id}-name') + + return api_response + + @cache.delete('service-{service_id}') + @cache.delete('live-service-and-organization-counts') + @cache.delete('organizations') + def update_service_organization(self, service_id, org_id): + data = { + 'service_id': service_id + } + return self.post( + url="/organizations/{}/service".format(org_id), + data=data + ) + + def get_organization_services(self, org_id): + return self.get(url="/organizations/{}/services".format(org_id)) + + @cache.delete('user-{user_id}') + def remove_user_from_organization(self, org_id, user_id): + return self.delete(f'/organizations/{org_id}/users/{user_id}') + + def get_services_and_usage(self, org_id, year): + return self.get( + url=f"/organizations/{org_id}/services-with-usage", + params={"year": str(year)} + ) + + +organizations_client = OrganizationsClient() diff --git a/app/notify_client/service_api_client.py b/app/notify_client/service_api_client.py index 0fdcc8b85..ffa3a8315 100644 --- a/app/notify_client/service_api_client.py +++ b/app/notify_client/service_api_client.py @@ -14,7 +14,7 @@ class ServiceAPIClient(NotifyAdminAPIClient): def create_service( self, service_name, - organisation_type, + organization_type, message_limit, restricted, user_id, @@ -25,7 +25,7 @@ class ServiceAPIClient(NotifyAdminAPIClient): """ data = { "name": service_name, - "organisation_type": organisation_type, + "organization_type": organization_type, "active": True, "message_limit": message_limit, "user_id": user_id, @@ -94,7 +94,7 @@ class ServiceAPIClient(NotifyAdminAPIClient): 'message_limit', 'name', 'notes', - 'organisation_type', + 'organization_type', 'permissions', 'prefix_sms', 'purchase_order_number', @@ -114,7 +114,7 @@ class ServiceAPIClient(NotifyAdminAPIClient): endpoint = "/service/{0}".format(service_id) return self.post(endpoint, data) - @cache.delete('live-service-and-organisation-counts') + @cache.delete('live-service-and-organization-counts') def update_status(self, service_id, live): return self.update_service( service_id, @@ -123,7 +123,7 @@ class ServiceAPIClient(NotifyAdminAPIClient): go_live_at=str(datetime.utcnow()) if live else None ) - @cache.delete('live-service-and-organisation-counts') + @cache.delete('live-service-and-organization-counts') def update_count_as_live(self, service_id, count_as_live): return self.update_service( service_id, diff --git a/app/notify_client/status_api_client.py b/app/notify_client/status_api_client.py index 277140ff3..910ff0181 100644 --- a/app/notify_client/status_api_client.py +++ b/app/notify_client/status_api_client.py @@ -6,13 +6,13 @@ class StatusApiClient(NotifyAdminAPIClient): def get_status(self, *params): return self.get(url='/_status', *params) - @cache.set('live-service-and-organisation-counts', ttl_in_seconds=3600) - def get_count_of_live_services_and_organisations(self): - return self.get(url='/_status/live-service-and-organisation-counts') + @cache.set('live-service-and-organization-counts', ttl_in_seconds=3600) + def get_count_of_live_services_and_organizations(self): + return self.get(url='/_status/live-service-and-organization-counts') - @cache.set('live-service-and-organisation-counts', ttl_in_seconds=3600) - def get_count_of_live_services_and_organisations_cached(self): - return self.get(url='/_status/live-service-and-organisation-counts') + @cache.set('live-service-and-organization-counts', ttl_in_seconds=3600) + def get_count_of_live_services_and_organizations_cached(self): + return self.get(url='/_status/live-service-and-organization-counts') status_api_client = StatusApiClient() diff --git a/app/notify_client/user_api_client.py b/app/notify_client/user_api_client.py index 94a437d0f..2d4cefaa9 100644 --- a/app/notify_client/user_api_client.py +++ b/app/notify_client/user_api_client.py @@ -150,8 +150,8 @@ class UserApiClient(NotifyAdminAPIClient): endpoint = '/service/{}/users'.format(service_id) return self.get(endpoint)['data'] - def get_users_for_organisation(self, org_id): - endpoint = '/organisations/{}/users'.format(org_id) + def get_users_for_organization(self, org_id): + endpoint = '/organizations/{}/users'.format(org_id) return self.get(endpoint)['data'] @cache.delete('service-{service_id}') @@ -168,8 +168,8 @@ class UserApiClient(NotifyAdminAPIClient): self.post(endpoint, data=data) @cache.delete('user-{user_id}') - def add_user_to_organisation(self, org_id, user_id): - resp = self.post('/organisations/{}/users/{}'.format(org_id, user_id), data={}) + def add_user_to_organization(self, org_id, user_id): + resp = self.post('/organizations/{}/users/{}'.format(org_id, user_id), data={}) return resp['data'] @cache.delete('service-{service_id}-template-folders') @@ -211,8 +211,8 @@ class UserApiClient(NotifyAdminAPIClient): data = {'email': new_email} self.post(endpoint, data) - def get_organisations_and_services_for_user(self, user_id): - endpoint = '/user/{}/organisations-and-services'.format(user_id) + def get_organizations_and_services_for_user(self, user_id): + endpoint = '/user/{}/organizations-and-services'.format(user_id) return self.get(endpoint) def get_webauthn_credentials_for_user(self, user_id): diff --git a/app/status/views/healthcheck.py b/app/status/views/healthcheck.py index a447bcb80..bb84b7512 100644 --- a/app/status/views/healthcheck.py +++ b/app/status/views/healthcheck.py @@ -47,7 +47,7 @@ def show_redis_status(): except RedisError as err: current_app.logger.exception(f"Redis service failed to respond with {err}") - api_status = status_api_client.get_count_of_live_services_and_organisations_cached() + api_status = status_api_client.get_count_of_live_services_and_organizations_cached() except HTTPError as err: current_app.logger.exception("API failed to respond") return jsonify(status="error", message=str(err.message)), 500 diff --git a/app/templates/org_nav.html b/app/templates/org_nav.html index 4e775e619..4363f94cf 100644 --- a/app/templates/org_nav.html +++ b/app/templates/org_nav.html @@ -1,11 +1,11 @@ diff --git a/app/templates/org_template.html b/app/templates/org_template.html index d37a563c4..82928fc34 100644 --- a/app/templates/org_template.html +++ b/app/templates/org_template.html @@ -8,7 +8,7 @@
  • - All organisations + All organizations

    - {{ org_count|format_thousands }} organisations, {{ live_service_count|format_thousands }} live services + {{ org_count|format_thousands }} organizations, {{ live_service_count|format_thousands }} live services

@@ -74,11 +74,11 @@
{% endif %} - {% if current_user.organisations %} + {% if current_user.organizations %} {{ service_list( heading='Live services', show_heading=current_user.trial_mode_services or current_user.platform_admin, - organisations=current_user.organisations, + organizations=current_user.organizations, services=current_user.live_services ) }} {% else %} @@ -92,7 +92,7 @@ {% if current_user.trial_mode_services %} {{ service_list( heading='Trial mode services', - show_heading=(current_user.organisations or current_user.live_services or current_user.platform_admin), + show_heading=(current_user.organizations or current_user.live_services or current_user.platform_admin), services=current_user.trial_mode_services ) }} {% endif %} diff --git a/app/templates/views/organisations/add-gp-organisation.html b/app/templates/views/organizations/add-gp-organization.html similarity index 87% rename from app/templates/views/organisations/add-gp-organisation.html rename to app/templates/views/organizations/add-gp-organization.html index 120ad22ba..351c69ec5 100644 --- a/app/templates/views/organisations/add-gp-organisation.html +++ b/app/templates/views/organizations/add-gp-organization.html @@ -15,10 +15,10 @@ {% call form_wrapper() %} {% call select_wrapper(form.same_as_service_name) %} {% for option in form.same_as_service_name %} - {{ radio(option, data_target='custom-organisation-name' if option.data == False else '') }} + {{ radio(option, data_target='custom-organization-name' if option.data == False else '') }} {% endfor %} {% endcall %} - {% call conditional_radio_panel('custom-organisation-name') %} + {% call conditional_radio_panel('custom-organization-name') %} {{ form.name }} {% endcall %} {{ page_footer('Continue') }} diff --git a/app/templates/views/organisations/add-nhs-local-organisation.html b/app/templates/views/organizations/add-nhs-local-organization.html similarity index 92% rename from app/templates/views/organisations/add-nhs-local-organisation.html rename to app/templates/views/organizations/add-nhs-local-organization.html index 24abf8ebf..e31fec59c 100644 --- a/app/templates/views/organisations/add-nhs-local-organisation.html +++ b/app/templates/views/organizations/add-nhs-local-organization.html @@ -17,7 +17,7 @@ {{ page_header(page_title) }} {% call form_wrapper() %}

- {{ form.organisations.label.text }} + {{ form.organizations.label.text }}

{{ live_search( target_selector='.govuk-radios__item', @@ -26,7 +26,7 @@ label='Search by name', autofocus=True) }} - {{ form.organisations }} + {{ form.organizations }} {{ sticky_page_footer('Continue') }} {% endcall %} {% endblock %} diff --git a/app/templates/views/organisations/add-organisation.html b/app/templates/views/organizations/add-organization.html similarity index 92% rename from app/templates/views/organisations/add-organisation.html rename to app/templates/views/organizations/add-organization.html index a8241c758..6004f53a2 100644 --- a/app/templates/views/organisations/add-organisation.html +++ b/app/templates/views/organizations/add-organization.html @@ -10,7 +10,7 @@ {% block main %}
@@ -25,7 +25,7 @@ {{ page_header('New organization') }} {% call form_wrapper() %} {{ form.name }} - {{ form.organisation_type }} + {{ form.organization_type }} {{ page_footer('Save') }} {% endcall %} {% endblock %} diff --git a/app/templates/views/organisations/index.html b/app/templates/views/organizations/index.html similarity index 88% rename from app/templates/views/organisations/index.html rename to app/templates/views/organizations/index.html index 6e00866ed..6a527448c 100644 --- a/app/templates/views/organisations/index.html +++ b/app/templates/views/organizations/index.html @@ -14,9 +14,9 @@
diff --git a/app/templates/views/organisations/organisation/billing.html b/app/templates/views/organizations/organization/billing.html similarity index 100% rename from app/templates/views/organisations/organisation/billing.html rename to app/templates/views/organizations/organization/billing.html diff --git a/app/templates/views/organisations/organisation/index.html b/app/templates/views/organizations/organization/index.html similarity index 96% rename from app/templates/views/organisations/organisation/index.html rename to app/templates/views/organizations/organization/index.html index edf2f0932..87543f061 100644 --- a/app/templates/views/organisations/organisation/index.html +++ b/app/templates/views/organizations/organization/index.html @@ -43,7 +43,7 @@ {% if search_form %}
{{ live_search( - target_selector='.organisation-service', + target_selector='.organization-service', show=True, form=search_form, label='Search by service' @@ -54,7 +54,7 @@

By service

{% for service in services %} -
+

{{ service.service_name }}

diff --git a/app/templates/views/organisations/organisation/settings/edit-domains.html b/app/templates/views/organizations/organization/settings/edit-domains.html similarity index 94% rename from app/templates/views/organisations/organisation/settings/edit-domains.html rename to app/templates/views/organizations/organization/settings/edit-domains.html index f4f9a1bdc..894f8f3bf 100644 --- a/app/templates/views/organisations/organisation/settings/edit-domains.html +++ b/app/templates/views/organizations/organization/settings/edit-domains.html @@ -10,7 +10,7 @@ {% endblock %} {% block backLink %} - {{ govukBackLink({ "href": url_for('.organisation_settings', org_id=current_org.id) }) }} + {{ govukBackLink({ "href": url_for('.organization_settings', org_id=current_org.id) }) }} {% endblock %} {% block maincolumn_content %} diff --git a/app/templates/views/organisations/organisation/settings/edit-go-live-notes.html b/app/templates/views/organizations/organization/settings/edit-go-live-notes.html similarity index 94% rename from app/templates/views/organisations/organisation/settings/edit-go-live-notes.html rename to app/templates/views/organizations/organization/settings/edit-go-live-notes.html index 22d741971..4e7add4a9 100644 --- a/app/templates/views/organisations/organisation/settings/edit-go-live-notes.html +++ b/app/templates/views/organizations/organization/settings/edit-go-live-notes.html @@ -10,7 +10,7 @@ {% endblock %} {% block backLink %} - {{ govukBackLink({ "href": url_for('.organisation_settings', org_id=current_org.id) }) }} + {{ govukBackLink({ "href": url_for('.organization_settings', org_id=current_org.id) }) }} {% endblock %} {% block maincolumn_content %} diff --git a/app/templates/views/organisations/organisation/settings/edit-name.html b/app/templates/views/organizations/organization/settings/edit-name.html similarity index 90% rename from app/templates/views/organisations/organisation/settings/edit-name.html rename to app/templates/views/organizations/organization/settings/edit-name.html index 6eaca1e6e..227376128 100644 --- a/app/templates/views/organisations/organisation/settings/edit-name.html +++ b/app/templates/views/organizations/organization/settings/edit-name.html @@ -9,7 +9,7 @@ {% endblock %} {% block backLink %} - {{ govukBackLink({ "href": url_for('.organisation_settings', org_id=current_org.id) }) }} + {{ govukBackLink({ "href": url_for('.organization_settings', org_id=current_org.id) }) }} {% endblock %} {% block maincolumn_content %} diff --git a/app/templates/views/organisations/organisation/settings/edit-organisation-billing-details.html b/app/templates/views/organizations/organization/settings/edit-organization-billing-details.html similarity index 95% rename from app/templates/views/organisations/organisation/settings/edit-organisation-billing-details.html rename to app/templates/views/organizations/organization/settings/edit-organization-billing-details.html index a88caa25a..93b2ce2b1 100644 --- a/app/templates/views/organisations/organisation/settings/edit-organisation-billing-details.html +++ b/app/templates/views/organizations/organization/settings/edit-organization-billing-details.html @@ -10,7 +10,7 @@ {% endblock %} {% block backLink %} - {{ govukBackLink({ "href": url_for('.organisation_settings', org_id=current_org.id) }) }} + {{ govukBackLink({ "href": url_for('.organization_settings', org_id=current_org.id) }) }} {% endblock %} {% block maincolumn_content %} diff --git a/app/templates/views/organisations/organisation/settings/edit-organisation-notes.html b/app/templates/views/organizations/organization/settings/edit-organization-notes.html similarity index 92% rename from app/templates/views/organisations/organisation/settings/edit-organisation-notes.html rename to app/templates/views/organizations/organization/settings/edit-organization-notes.html index a708f8770..4f5d8e41b 100644 --- a/app/templates/views/organisations/organisation/settings/edit-organisation-notes.html +++ b/app/templates/views/organizations/organization/settings/edit-organization-notes.html @@ -10,7 +10,7 @@ {% endblock %} {% block backLink %} - {{ govukBackLink({ "href": url_for('.organisation_settings', org_id=current_org.id) }) }} + {{ govukBackLink({ "href": url_for('.organization_settings', org_id=current_org.id) }) }} {% endblock %} {% block maincolumn_content %} diff --git a/app/templates/views/organisations/organisation/settings/edit-type.html b/app/templates/views/organizations/organization/settings/edit-type.html similarity index 85% rename from app/templates/views/organisations/organisation/settings/edit-type.html rename to app/templates/views/organizations/organization/settings/edit-type.html index ebc5bed4a..9d1d7a598 100644 --- a/app/templates/views/organisations/organisation/settings/edit-type.html +++ b/app/templates/views/organizations/organization/settings/edit-type.html @@ -9,13 +9,13 @@ {% endblock %} {% block backLink %} - {{ govukBackLink({ "href": url_for('.organisation_settings', org_id=current_org.id) }) }} + {{ govukBackLink({ "href": url_for('.organization_settings', org_id=current_org.id) }) }} {% endblock %} {% block maincolumn_content %} {{ page_header("Organization sector") }} {% call form_wrapper() %} - {{ form.organisation_type }} + {{ form.organization_type }} {{ page_footer('Save') }} {% endcall %} {% endblock %} diff --git a/app/templates/views/organisations/organisation/settings/index.html b/app/templates/views/organizations/organization/settings/index.html similarity index 83% rename from app/templates/views/organisations/organisation/settings/index.html rename to app/templates/views/organizations/organization/settings/index.html index 450c7601a..2f3ac9ca1 100644 --- a/app/templates/views/organisations/organisation/settings/index.html +++ b/app/templates/views/organizations/organization/settings/index.html @@ -19,17 +19,17 @@ {{ text_field(current_org.name) }} {{ edit_field( 'Change', - url_for('.edit_organisation_name', org_id=current_org.id), + url_for('.edit_organization_name', org_id=current_org.id), suffix='organization name' ) }} {% endcall %} {% call row() %} {{ text_field('Sector') }} - {{ optional_text_field(current_org.organisation_type_label) }} + {{ optional_text_field(current_org.organization_type_label) }} {{ edit_field( 'Change', - url_for('.edit_organisation_type', org_id=current_org.id), + url_for('.edit_organization_type', org_id=current_org.id), suffix='sector for the organization' ) }} @@ -39,7 +39,7 @@ {{ optional_text_field(current_org.request_to_go_live_notes, default='None') }} {{ edit_field( 'Change', - url_for('.edit_organisation_go_live_notes', org_id=current_org.id), + url_for('.edit_organization_go_live_notes', org_id=current_org.id), suffix='go live notes for the organization' ) }} @@ -50,7 +50,7 @@ {{ optional_text_field(current_org.billing_details, default="None", wrap=True) }} {{ edit_field( 'Change', - url_for('.edit_organisation_billing_details', org_id=current_org.id), + url_for('.edit_organization_billing_details', org_id=current_org.id), suffix='billing details for the organization' ) }} @@ -61,7 +61,7 @@ {{ optional_text_field(current_org.notes, default="None", wrap=True) }} {{ edit_field( 'Change', - url_for('.edit_organisation_notes', org_id=current_org.id), + url_for('.edit_organization_notes', org_id=current_org.id), suffix='the notes for the organization' ) }} @@ -72,7 +72,7 @@ {{ text_field(current_org.email_branding_name) }} {{ edit_field( 'Change', - url_for('.edit_organisation_email_branding', org_id=current_org.id), + url_for('.edit_organization_email_branding', org_id=current_org.id), suffix='default email branding for the organization' ) }} @@ -82,7 +82,7 @@ {{ optional_text_field(current_org.domains or None, default='None') }} {{ edit_field( 'Change', - url_for('.edit_organisation_domains', org_id=current_org.id), + url_for('.edit_organization_domains', org_id=current_org.id), suffix='known email domains for the organization' ) }} diff --git a/app/templates/views/organisations/organisation/settings/preview-email-branding.html b/app/templates/views/organizations/organization/settings/preview-email-branding.html similarity index 100% rename from app/templates/views/organisations/organisation/settings/preview-email-branding.html rename to app/templates/views/organizations/organization/settings/preview-email-branding.html diff --git a/app/templates/views/organisations/organisation/settings/set-email-branding.html b/app/templates/views/organizations/organization/settings/set-email-branding.html similarity index 95% rename from app/templates/views/organisations/organisation/settings/set-email-branding.html rename to app/templates/views/organizations/organization/settings/set-email-branding.html index 430aaed14..23d596611 100644 --- a/app/templates/views/organisations/organisation/settings/set-email-branding.html +++ b/app/templates/views/organizations/organization/settings/set-email-branding.html @@ -12,7 +12,7 @@ {% endblock %} {% block backLink %} - {{ govukBackLink({ "href": url_for('.organisation_settings', org_id=current_org.id) }) }} + {{ govukBackLink({ "href": url_for('.organization_settings', org_id=current_org.id) }) }} {% endblock %} {% block maincolumn_content %} diff --git a/app/templates/views/organisations/organisation/trial-mode-services.html b/app/templates/views/organizations/organization/trial-mode-services.html similarity index 100% rename from app/templates/views/organisations/organisation/trial-mode-services.html rename to app/templates/views/organizations/organization/trial-mode-services.html diff --git a/app/templates/views/organisations/organisation/users/index.html b/app/templates/views/organizations/organization/users/index.html similarity index 95% rename from app/templates/views/organisations/organisation/users/index.html rename to app/templates/views/organizations/organization/users/index.html index f341170d2..24cfa05e9 100644 --- a/app/templates/views/organisations/organisation/users/index.html +++ b/app/templates/views/organizations/organization/users/index.html @@ -15,7 +15,7 @@ 'Are you sure you want to remove {}?'.format(user_to_remove.name), type='dangerous', delete_button='Yes, remove', - action=url_for('.remove_user_from_organisation', org_id=current_org.id, user_id=user_to_remove.id) + action=url_for('.remove_user_from_organization', org_id=current_org.id, user_id=user_to_remove.id) ) }} {% endif %} @@ -55,7 +55,7 @@ {% if user.status == 'pending' %} Cancel invitation for {{ user.email_address }} {% elif user.status != 'cancelled' %} - Remove {{ user.name }} {{ user.email_address }} + Remove {{ user.name }} {{ user.email_address }} {% endif %}
diff --git a/app/templates/views/organisations/organisation/users/invite-org-user.html b/app/templates/views/organizations/organization/users/invite-org-user.html similarity index 100% rename from app/templates/views/organisations/organisation/users/invite-org-user.html rename to app/templates/views/organizations/organization/users/invite-org-user.html diff --git a/app/templates/views/performance.html b/app/templates/views/performance.html index b6350e59a..f0dfdbb00 100644 --- a/app/templates/views/performance.html +++ b/app/templates/views/performance.html @@ -110,19 +110,19 @@
There are -
{{ count_of_live_services_and_organisations.organisations|format_thousands }}
+
{{ count_of_live_services_and_organizations.organizations|format_thousands }}
organizations
and -
{{ count_of_live_services_and_organisations.services|format_thousands }}
+
{{ count_of_live_services_and_organizations.services|format_thousands }}
services using Notify.
{% call(item, row_number) list_table( - organisations_using_notify, + organizations_using_notify, caption='Organizations using Notify', caption_visible=False, field_headings=[ @@ -131,7 +131,7 @@ empty_message='No data to show' ) %} {% call field() %} - {{ item.organisation_name }} + {{ item.organization_name }} {% endcall %} {% call field() %} {{ item.count_of_live_services }} diff --git a/app/templates/views/platform-admin/_base_template.html b/app/templates/views/platform-admin/_base_template.html index 90e0b9bed..8570a07e8 100644 --- a/app/templates/views/platform-admin/_base_template.html +++ b/app/templates/views/platform-admin/_base_template.html @@ -16,7 +16,7 @@ ('Summary', url_for('main.platform_admin')), ('Live services', url_for('main.live_services')), ('Trial mode services', url_for('main.trial_services')), - ('Organizations', url_for('main.organisations')), + ('Organizations', url_for('main.organizations')), ('Providers', url_for('main.view_providers')), ('Reports', url_for('main.platform_admin_reports')), ('Email branding', url_for('main.email_branding')), diff --git a/app/templates/views/privacy.html b/app/templates/views/privacy.html index 8c0a6d44a..6b8c66aaa 100644 --- a/app/templates/views/privacy.html +++ b/app/templates/views/privacy.html @@ -60,7 +60,7 @@

We design, build and run our systems to make sure that your data is as safe as possible at any stage, both while it’s processed and when it’s stored.

- +

How we protect your data and keep it secure

diff --git a/app/templates/views/register-from-org-invite.html b/app/templates/views/register-from-org-invite.html index 58399ce59..b54da3c5a 100644 --- a/app/templates/views/register-from-org-invite.html +++ b/app/templates/views/register-from-org-invite.html @@ -26,7 +26,7 @@ Create an account "autocomplete": "new-password" }) }} {{ page_footer("Continue") }} - {{form.organisation}} + {{form.organization}} {{form.email_address}} {% endcall %}
diff --git a/app/templates/views/security.html b/app/templates/views/security.html index 639e1ed68..7c6820003 100644 --- a/app/templates/views/security.html +++ b/app/templates/views/security.html @@ -72,6 +72,6 @@

Classifications and security vetting

You can use Notify to send messages classified as ‘OFFICIAL’ or ‘OFFICIAL-SENSITIVE’ under the Government Security Classifications policy.

Notify does not process data classified as ‘SECRET’ or ‘TOP SECRET’.

-

The Notify team has Security Check (SC) level clearance from United Kingdom Security Vetting (UKSV).

--> +

The Notify team has Security Check (SC) level clearance from United Kingdom Security Vetting (UKSV).

--> {% endblock %} diff --git a/app/templates/views/service-settings.html b/app/templates/views/service-settings.html index 6de9fd348..99cb32788 100644 --- a/app/templates/views/service-settings.html +++ b/app/templates/views/service-settings.html @@ -240,7 +240,7 @@ {% call row() %} {{ text_field('Live')}} - {% if current_service.trial_mode and not current_service.organisation_id %} + {% if current_service.trial_mode and not current_service.organization_id %} {{ text_field('No (organization must be set first)') }} {{ text_field('') }} {% else %} @@ -269,20 +269,20 @@ {% call row() %} {{ text_field('Organization')}} {% call field() %} - {% if current_service.organisation_id %} - - {{ current_service.organisation_name }} + {% if current_service.organization_id %} + + {{ current_service.organization_name }} {% else %} Not set {% endif %} - {% if current_service.organisation_type %} + {% if current_service.organization_type %}
- {{ current_service.organisation_type_label }} + {{ current_service.organization_type_label }}
{% endif %} {% endcall %} - {{ edit_field('Change', url_for('.link_service_to_organisation', service_id=current_service.id), suffix='organization for service') }} + {{ edit_field('Change', url_for('.link_service_to_organization', service_id=current_service.id), suffix='organization for service') }} {% endcall %} {% call row() %} diff --git a/app/templates/views/service-settings/branding/email-branding-govuk-org.html b/app/templates/views/service-settings/branding/email-branding-govuk-org.html index cb0d58fa8..553f2dd0c 100644 --- a/app/templates/views/service-settings/branding/email-branding-govuk-org.html +++ b/app/templates/views/service-settings/branding/email-branding-govuk-org.html @@ -23,7 +23,7 @@

You cannot use U.S. Notify branding if your organization is independent + href="https://www.gov.uk/government/publications/govuk-proposition/govuk-proposition#organizations-independent-from-government">independent from government.

diff --git a/app/templates/views/service-settings/branding/email-branding-govuk.html b/app/templates/views/service-settings/branding/email-branding-govuk.html index a6b2e039f..e2ded9b3f 100644 --- a/app/templates/views/service-settings/branding/email-branding-govuk.html +++ b/app/templates/views/service-settings/branding/email-branding-govuk.html @@ -32,7 +32,7 @@

You cannot use U.S. Notify branding if your organization is independent + href="https://www.gov.uk/government/publications/govuk-proposition/govuk-proposition#organizations-independent-from-government">independent from government.

diff --git a/app/templates/views/service-settings/branding/email-branding-organisation.html b/app/templates/views/service-settings/branding/email-branding-organization.html similarity index 93% rename from app/templates/views/service-settings/branding/email-branding-organisation.html rename to app/templates/views/service-settings/branding/email-branding-organization.html index 4b727fa66..9e40a42a8 100644 --- a/app/templates/views/service-settings/branding/email-branding-organisation.html +++ b/app/templates/views/service-settings/branding/email-branding-organization.html @@ -18,7 +18,7 @@ {{ page_header('When you request new branding') }} -

We’ll check if we already have the {{organisation}} logo.

+

We’ll check if we already have the {{organization}} logo.

If we do, we’ll let you know when your new branding is ready to use.

diff --git a/app/templates/views/service-settings/link-service-to-organisation.html b/app/templates/views/service-settings/link-service-to-organization.html similarity index 94% rename from app/templates/views/service-settings/link-service-to-organisation.html rename to app/templates/views/service-settings/link-service-to-organization.html index 1604c3ee2..4df5bb50c 100644 --- a/app/templates/views/service-settings/link-service-to-organisation.html +++ b/app/templates/views/service-settings/link-service-to-organization.html @@ -25,8 +25,8 @@ autofocus=True ) }} {% call form_wrapper() %} - {% if has_organisations %} - {{ form.organisations }} + {% if has_organizations %} + {{ form.organizations }} {{ sticky_page_footer('Save') }} {% else %}

No organizations

diff --git a/app/templates/views/service-settings/name-local.html b/app/templates/views/service-settings/name-local.html index 5a2b3e940..aaff84b1a 100644 --- a/app/templates/views/service-settings/name-local.html +++ b/app/templates/views/service-settings/name-local.html @@ -18,9 +18,9 @@

Your service name should tell users what the message is about as well as who it’s from. For example:

    -
  • School admissions - {{ current_service.organisation.name or current_user.default_organisation.name }}
  • -
  • Electoral services - {{ current_service.organisation.name or current_user.default_organisation.name }}
  • -
  • Blue Badge - {{ current_service.organisation.name or current_user.default_organisation.name }}
  • +
  • School admissions - {{ current_service.organization.name or current_user.default_organization.name }}
  • +
  • Electoral services - {{ current_service.organization.name or current_user.default_organization.name }}
  • +
  • Blue Badge - {{ current_service.organization.name or current_user.default_organization.name }}

You should only use an acronym or initialism if your users are already familiar with it.

diff --git a/app/templates/views/signedout.html b/app/templates/views/signedout.html index 11d556988..a7ebe74f9 100644 --- a/app/templates/views/signedout.html +++ b/app/templates/views/signedout.html @@ -112,7 +112,7 @@ U.S. Notify
There are -
{{ counts.organisations|format_thousands }}
+
{{ counts.organizations|format_thousands }}

Organizations

@@ -246,7 +246,7 @@ U.S. Notify
There are -
{{ counts.organisations|format_thousands }}
+
{{ counts.organizations|format_thousands }}
organizations
diff --git a/app/utils/branding.py b/app/utils/branding.py index 3e4518f21..f1d12d77b 100644 --- a/app/utils/branding.py +++ b/app/utils/branding.py @@ -1,22 +1,22 @@ -from app.models.organisation import Organisation +from app.models.organization import Organization NHS_EMAIL_BRANDING_ID = 'a7dc4e56-660b-4db7-8cff-12c37b12b5ea' def get_email_choices(service): - organisation_branding_id = service.organisation.email_branding_id if service.organisation else None + organization_branding_id = service.organization.email_branding_id if service.organization else None if ( - service.organisation_type == Organisation.TYPE_FEDERAL + service.organization_type == Organization.TYPE_FEDERAL and service.email_branding_id is not None # GOV.UK is not current branding - and organisation_branding_id is None # no default to supersede it (GOV.UK) + and organization_branding_id is None # no default to supersede it (GOV.UK) ): yield ('govuk', 'GOV.UK') if ( - service.organisation_type == Organisation.TYPE_FEDERAL - and service.organisation - and organisation_branding_id is None # don't offer both if org has default - and service.email_branding_name.lower() != f'GOV.UK and {service.organisation.name}'.lower() + service.organization_type == Organization.TYPE_FEDERAL + and service.organization + and organization_branding_id is None # don't offer both if org has default + and service.email_branding_name.lower() != f'GOV.UK and {service.organization.name}'.lower() ): - yield ('govuk_and_org', f'GOV.UK and {service.organisation.name}') + yield ('govuk_and_org', f'GOV.UK and {service.organization.name}') diff --git a/app/utils/user.py b/app/utils/user.py index 27af90e83..ef42f6fc7 100644 --- a/app/utils/user.py +++ b/app/utils/user.py @@ -4,7 +4,7 @@ from flask import abort, current_app from flask_login import current_user, login_required from app import config -from app.notify_client.organisations_api_client import organisations_client +from app.notify_client.organizations_api_client import organizations_client user_is_logged_in = login_required @@ -48,7 +48,7 @@ def is_gov_user(email_address): return _email_address_ends_with( email_address, config.Config.GOVERNMENT_EMAIL_DOMAIN_NAMES ) or _email_address_ends_with( - email_address, organisations_client.get_domains() + email_address, organizations_client.get_domains() ) diff --git a/paas-failwhale/static_503/stylesheets/main.css b/paas-failwhale/static_503/stylesheets/main.css index 062f452c3..096763c7c 100644 --- a/paas-failwhale/static_503/stylesheets/main.css +++ b/paas-failwhale/static_503/stylesheets/main.css @@ -6019,7 +6019,7 @@ a.table-show-more-link { color: #2b8cc4 } -.navigation-organisation-link { +.navigation-organization-link { font-family: "nta", Arial, sans-serif; font-weight: 400; text-transform: none; @@ -6039,13 +6039,13 @@ a.table-show-more-link { } @media (min-width: 641px) { - .navigation-organisation-link { + .navigation-organization-link { font-size: 19px; line-height: 1.31579 } } -.navigation-organisation-link:before { +.navigation-organization-link:before { content: ""; display: block; position: absolute; @@ -6063,12 +6063,12 @@ a.table-show-more-link { border-color: #6f777b } -.navigation-organisation-link:hover { +.navigation-organization-link:hover { color: #2b8cc4; text-decoration: underline } -.navigation-organisation-link:focus { +.navigation-organization-link:focus { color: #0b0c0c; outline: none; box-shadow: 0 1px 0 0 #ffbf47, -3px 0 0 0 #ffbf47, -3px 1px 0 0 #ffbf47 diff --git a/tests/__init__.py b/tests/__init__.py index 03f232638..b3966b6b9 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -68,7 +68,7 @@ def user_json( state='active', platform_admin=False, current_session_id='1234', - organisations=None, + organizations=None, services=None ): @@ -99,7 +99,7 @@ def user_json( 'state': state, 'platform_admin': platform_admin, 'current_session_id': current_session_id, - 'organisations': organisations or [], + 'organizations': organizations or [], 'services': services } @@ -113,7 +113,7 @@ def invited_user( status='pending', created_at=None, auth_type='sms_auth', - organisation=None + organization=None ): data = { 'id': _id, @@ -127,8 +127,8 @@ def invited_user( data['service'] = service if permissions: data['permissions'] = permissions - if organisation: - data['organisation'] = organisation + if organization: + data['organization'] = organization return data @@ -150,10 +150,10 @@ def service_json( inbound_api=None, service_callback_api=None, permissions=None, - organisation_type='federal', + organization_type='federal', prefix_sms=True, contact_link=None, - organisation_id=None, + organization_id=None, rate_limit=3000, notes=None, billing_contact_email_addresses=None, @@ -181,7 +181,7 @@ def service_json( 'reply_to_email_address': reply_to_email_address, 'sms_sender': sms_sender, 'research_mode': research_mode, - 'organisation_type': organisation_type, + 'organization_type': organization_type, 'email_branding': email_branding, 'branding': branding, 'created_at': created_at or str(datetime.utcnow()), @@ -194,7 +194,7 @@ def service_json( 'volume_sms': 222222, 'consent_to_research': True, 'count_as_live': True, - 'organisation': organisation_id, + 'organization': organization_id, 'notes': notes, 'billing_contact_email_addresses': billing_contact_email_addresses, 'billing_contact_names': billing_contact_names, @@ -203,7 +203,7 @@ def service_json( } -def organisation_json( +def organization_json( id_='1234', name=False, users=None, @@ -217,7 +217,7 @@ def organisation_json( agreement_signed_by_id=None, agreement_signed_on_behalf_of_name=None, agreement_signed_on_behalf_of_email_address=None, - organisation_type='federal', + organization_type='federal', request_to_go_live_notes=None, notes=None, billing_contact_email_addresses=None, @@ -231,12 +231,12 @@ def organisation_json( services = [] return { 'id': id_, - 'name': 'Test Organisation' if name is False else name, + 'name': 'Test Organization' if name is False else name, 'active': active, 'users': users, 'created_at': created_at or str(datetime.utcnow()), 'email_branding_id': email_branding_id, - 'organisation_type': organisation_type, + 'organization_type': organization_type, 'agreement_signed': agreement_signed, 'agreement_signed_at': None, 'agreement_signed_by_id': agreement_signed_by_id, @@ -345,7 +345,7 @@ def org_invite_json(id_, invited_by, org_id, email_address, created_at, status): return { 'id': id_, 'invited_by': invited_by, - 'organisation': org_id, + 'organization': org_id, 'email_address': email_address, 'status': status, 'created_at': created_at, diff --git a/tests/app/main/forms/test_register_user_form.py b/tests/app/main/forms/test_register_user_form.py index b6d8c3b0d..c56120fd6 100644 --- a/tests/app/main/forms/test_register_user_form.py +++ b/tests/app/main/forms/test_register_user_form.py @@ -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", diff --git a/tests/app/main/test_permissions.py b/tests/app/main/test_permissions.py index 93fbebe0e..0cd12d0e7 100644 --- a/tests/app/main/test_permissions.py +++ b/tests/app/main/test_permissions.py @@ -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) diff --git a/tests/app/main/test_validators.py b/tests/app/main/test_validators.py index adfcd1121..d1b046d33 100644 --- a/tests/app/main/test_validators.py +++ b/tests/app/main/test_validators.py @@ -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): diff --git a/tests/app/main/views/accounts/test_choose_accounts.py b/tests/app/main/views/accounts/test_choose_accounts.py index 2e7afbb9b..21531c3b6 100644 --- a/tests/app/main/views/accounts/test_choose_accounts.py +++ b/tests/app/main/views/accounts/test_choose_accounts.py @@ -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 diff --git a/tests/app/main/views/accounts/test_show_accounts_or_dashboard.py b/tests/app/main/views/accounts/test_show_accounts_or_dashboard.py index 502bb2f1b..f47d863d7 100644 --- a/tests/app/main/views/accounts/test_show_accounts_or_dashboard.py +++ b/tests/app/main/views/accounts/test_show_accounts_or_dashboard.py @@ -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', ), ) diff --git a/tests/app/main/views/organisations/test_organisation_invites.py b/tests/app/main/views/organizations/test_organization_invites.py similarity index 88% rename from tests/app/main/views/organisations/test_organisation_invites.py rename to tests/app/main/views/organizations/test_organization_invites.py index 78f088f21..2003d39d6 100644 --- a/tests/app/main/views/organisations/test_organisation_invites.py +++ b/tests/app/main/views/organizations/test_organization_invites.py @@ -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'], ), ) diff --git a/tests/app/main/views/organisations/test_organisations.py b/tests/app/main/views/organizations/test_organizations.py similarity index 70% rename from tests/app/main/views/organisations/test_organisations.py rename to tests/app/main/views/organizations/test_organizations.py index bd2c86609..a8075101c 100644 --- a/tests/app/main/views/organisations/test_organisations.py +++ b/tests/app/main/views/organizations/test_organizations.py @@ -3,7 +3,7 @@ from flask import url_for from freezegun import freeze_time from notifications_python_client.errors import HTTPError -from tests import organisation_json, service_json +from tests import organization_json, service_json from tests.conftest import ( ORGANISATION_ID, SERVICE_ONE_ID, @@ -14,7 +14,7 @@ from tests.conftest import ( ) -def test_organisation_page_shows_all_organisations( +def test_organization_page_shows_all_organizations( client_request, platform_admin_user, mocker @@ -25,11 +25,11 @@ def test_organisation_page_shows_all_organisations( {'id': 'C2', 'name': 'Test 2', 'active': False, 'count_of_live_services': 2}, ] - get_organisations = mocker.patch( - 'app.models.organisation.AllOrganisations.client_method', return_value=orgs + get_organizations = mocker.patch( + 'app.models.organization.AllOrganizations.client_method', return_value=orgs ) client_request.login(platform_admin_user) - page = client_request.get('.organisations') + page = client_request.get('.organizations') assert normalize_spaces( page.select_one('h1').text @@ -46,13 +46,13 @@ def test_organisation_page_shows_all_organisations( ) ] == [ ('Test 1', '1 live service', url_for( - 'main.organisation_dashboard', org_id='B1' + 'main.organization_dashboard', org_id='B1' )), ('Test 2', '2 live services', url_for( - 'main.organisation_dashboard', org_id='C2' + 'main.organization_dashboard', org_id='C2' )), ('Test 3', '0 live services', url_for( - 'main.organisation_dashboard', org_id='A3' + 'main.organization_dashboard', org_id='A3' )), ] @@ -63,23 +63,23 @@ def test_organisation_page_shows_all_organisations( assert normalize_spaces( page.select_one('a.govuk-button--secondary').text ) == 'New organization' - get_organisations.assert_called_once_with() + get_organizations.assert_called_once_with() -def test_view_organisation_shows_the_correct_organisation( +def test_view_organization_shows_the_correct_organization( client_request, mocker ): org = {'id': ORGANISATION_ID, 'name': 'Test 1', 'active': True} mocker.patch( - 'app.organisations_client.get_organisation', return_value=org + 'app.organizations_client.get_organization', return_value=org ) mocker.patch( - 'app.organisations_client.get_services_and_usage', return_value={'services': {}} + 'app.organizations_client.get_services_and_usage', return_value={'services': {}} ) page = client_request.get( - '.organisation_dashboard', + '.organization_dashboard', org_id=ORGANISATION_ID, ) @@ -90,72 +90,72 @@ def test_view_organisation_shows_the_correct_organisation( assert not page.select('a[download]') -def test_page_to_create_new_organisation( +def test_page_to_create_new_organization( client_request, platform_admin_user, mocker, ): client_request.login(platform_admin_user) - page = client_request.get('.add_organisation') + page = client_request.get('.add_organization') assert [ (input['type'], input['name'], input.get('value')) for input in page.select('input') ] == [ ('text', 'name', None), - ('radio', 'organisation_type', 'federal'), - ('radio', 'organisation_type', 'state'), - # ('radio', 'organisation_type', 'nhs_central'), - # ('radio', 'organisation_type', 'nhs_local'), - # ('radio', 'organisation_type', 'nhs_gp'), - # ('radio', 'organisation_type', 'emergency_service'), - # ('radio', 'organisation_type', 'school_or_college'), - ('radio', 'organisation_type', 'other'), + ('radio', 'organization_type', 'federal'), + ('radio', 'organization_type', 'state'), + # ('radio', 'organization_type', 'nhs_central'), + # ('radio', 'organization_type', 'nhs_local'), + # ('radio', 'organization_type', 'nhs_gp'), + # ('radio', 'organization_type', 'emergency_service'), + # ('radio', 'organization_type', 'school_or_college'), + ('radio', 'organization_type', 'other'), ('hidden', 'csrf_token', mocker.ANY), ] -def test_create_new_organisation( +def test_create_new_organization( client_request, platform_admin_user, mocker, ): - mock_create_organisation = mocker.patch( - 'app.organisations_client.create_organisation', - return_value=organisation_json(ORGANISATION_ID), + mock_create_organization = mocker.patch( + 'app.organizations_client.create_organization', + return_value=organization_json(ORGANISATION_ID), ) client_request.login(platform_admin_user) client_request.post( - '.add_organisation', + '.add_organization', _data={ 'name': 'new name', - 'organisation_type': 'federal', + 'organization_type': 'federal', }, _expected_redirect=url_for( - 'main.organisation_settings', + 'main.organization_settings', org_id=ORGANISATION_ID, ), ) - mock_create_organisation.assert_called_once_with( + mock_create_organization.assert_called_once_with( name='new name', - organisation_type='federal', + organization_type='federal', ) -def test_create_new_organisation_validates( +def test_create_new_organization_validates( client_request, platform_admin_user, mocker, ): - mock_create_organisation = mocker.patch( - 'app.organisations_client.create_organisation' + mock_create_organization = mocker.patch( + 'app.organizations_client.create_organization' ) client_request.login(platform_admin_user) page = client_request.post( - '.add_organisation', + '.add_organization', _expected_status=200, ) assert [ @@ -163,9 +163,9 @@ def test_create_new_organisation_validates( for error in page.select('.usa-error-message') ] == [ ('name', 'Error: Cannot be empty'), - ('organisation_type', 'Error: Select the type of organization'), + ('organization_type', 'Error: Select the type of organization'), ] - assert mock_create_organisation.called is False + assert mock_create_organization.called is False @pytest.mark.parametrize('name, error_message', [ @@ -173,31 +173,31 @@ def test_create_new_organisation_validates( ('a', 'at least two alphanumeric characters'), ('a' * 256, 'Organization name must be 255 characters or fewer'), ]) -def test_create_new_organisation_fails_with_incorrect_input( +def test_create_new_organization_fails_with_incorrect_input( client_request, platform_admin_user, mocker, name, error_message, ): - mock_create_organisation = mocker.patch( - 'app.organisations_client.create_organisation' + mock_create_organization = mocker.patch( + 'app.organizations_client.create_organization' ) client_request.login(platform_admin_user) page = client_request.post( - '.add_organisation', + '.add_organization', _data={ 'name': name, - 'organisation_type': 'local', + 'organization_type': 'local', }, _expected_status=200, ) - assert mock_create_organisation.called is False + assert mock_create_organization.called is False assert error_message in page.select_one('.usa-error-message').text -def test_create_new_organisation_fails_with_duplicate_name( +def test_create_new_organization_fails_with_duplicate_name( client_request, platform_admin_user, mocker, @@ -209,16 +209,16 @@ def test_create_new_organisation_fails_with_duplicate_name( raise http_error mocker.patch( - 'app.organisations_client.create_organisation', + 'app.organizations_client.create_organization', side_effect=_create ) client_request.login(platform_admin_user) page = client_request.post( - '.add_organisation', + '.add_organization', _data={ 'name': 'Existing org', - 'organisation_type': 'federal', + 'organization_type': 'federal', }, _expected_status=200, ) @@ -227,26 +227,26 @@ def test_create_new_organisation_fails_with_duplicate_name( assert error_message in page.select_one('.usa-error-message').text -@pytest.mark.parametrize('organisation_type, organisation, expected_status', ( +@pytest.mark.parametrize('organization_type, organization, expected_status', ( ('nhs_gp', None, 200), ('central', None, 403), - ('nhs_gp', organisation_json(organisation_type='nhs_gp'), 403), + ('nhs_gp', organization_json(organization_type='nhs_gp'), 403), )) @pytest.mark.skip(reason='Update for TTS') -def test_gps_can_create_own_organisations( +def test_gps_can_create_own_organizations( client_request, mocker, - mock_get_service_organisation, + mock_get_service_organization, service_one, - organisation_type, - organisation, + organization_type, + organization, expected_status, ): - mocker.patch('app.organisations_client.get_organisation', return_value=organisation) - service_one['organisation_type'] = organisation_type + mocker.patch('app.organizations_client.get_organization', return_value=organization) + service_one['organization_type'] = organization_type page = client_request.get( - '.add_organisation_from_gp_service', + '.add_organization_from_gp_service', service_id=SERVICE_ONE_ID, _expected_status=expected_status, ) @@ -279,32 +279,32 @@ def test_gps_can_create_own_organisations( ), )) @pytest.mark.skip(reason='Update for TTS') -def test_gps_can_name_their_organisation( +def test_gps_can_name_their_organization( client_request, mocker, service_one, - mock_update_service_organisation, + mock_update_service_organization, data, expected_service_name, ): - service_one['organisation_type'] = 'nhs_gp' - mock_create_organisation = mocker.patch( - 'app.organisations_client.create_organisation', - return_value=organisation_json(ORGANISATION_ID), + service_one['organization_type'] = 'nhs_gp' + mock_create_organization = mocker.patch( + 'app.organizations_client.create_organization', + return_value=organization_json(ORGANISATION_ID), ) client_request.post( - '.add_organisation_from_gp_service', + '.add_organization_from_gp_service', service_id=SERVICE_ONE_ID, _data=data, _expected_status=302, ) - mock_create_organisation.assert_called_once_with( + mock_create_organization.assert_called_once_with( name=expected_service_name, - organisation_type='nhs_gp', + organization_type='nhs_gp', ) - mock_update_service_organisation.assert_called_once_with(SERVICE_ONE_ID, ORGANISATION_ID) + mock_update_service_organization.assert_called_once_with(SERVICE_ONE_ID, ORGANISATION_ID) @pytest.mark.parametrize('data, expected_error', ( @@ -323,16 +323,16 @@ def test_gps_can_name_their_organisation( ), )) @pytest.mark.skip(reason='Update for TTS') -def test_validation_of_gps_creating_organisations( +def test_validation_of_gps_creating_organizations( client_request, mocker, service_one, data, expected_error, ): - service_one['organisation_type'] = 'nhs_gp' + service_one['organization_type'] = 'nhs_gp' page = client_request.post( - '.add_organisation_from_gp_service', + '.add_organization_from_gp_service', service_id=SERVICE_ONE_ID, _data=data, _expected_status=200, @@ -341,15 +341,15 @@ def test_validation_of_gps_creating_organisations( @freeze_time("2020-02-20 20:20") -def test_organisation_services_shows_live_services_and_usage( +def test_organization_services_shows_live_services_and_usage( client_request, - mock_get_organisation, + mock_get_organization, mocker, active_user_with_permissions, fake_uuid, ): mock = mocker.patch( - 'app.organisations_client.get_services_and_usage', + 'app.organizations_client.get_services_and_usage', return_value={"services": [ {'service_id': SERVICE_ONE_ID, 'service_name': '1', 'chargeable_billable_sms': 250122, 'emails_sent': 13000, 'free_sms_limit': 250000, 'sms_billable_units': 122, 'sms_cost': 0, @@ -361,7 +361,7 @@ def test_organisation_services_shows_live_services_and_usage( ) client_request.login(active_user_with_permissions) - page = client_request.get('.organisation_dashboard', org_id=ORGANISATION_ID) + page = client_request.get('.organization_dashboard', org_id=ORGANISATION_ID) mock.assert_called_once_with(ORGANISATION_ID, 2019) services = page.select('main h3') @@ -387,15 +387,15 @@ def test_organisation_services_shows_live_services_and_usage( @freeze_time("2020-02-20 20:20") -def test_organisation_services_shows_live_services_and_usage_with_count_of_1( +def test_organization_services_shows_live_services_and_usage_with_count_of_1( client_request, - mock_get_organisation, + mock_get_organization, mocker, active_user_with_permissions, fake_uuid, ): mocker.patch( - 'app.organisations_client.get_services_and_usage', + 'app.organizations_client.get_services_and_usage', return_value={"services": [ {'service_id': SERVICE_ONE_ID, 'service_name': '1', 'chargeable_billable_sms': 1, 'emails_sent': 1, 'free_sms_limit': 250000, 'sms_billable_units': 1, 'sms_cost': 0, @@ -404,7 +404,7 @@ def test_organisation_services_shows_live_services_and_usage_with_count_of_1( ) client_request.login(active_user_with_permissions) - page = client_request.get('.organisation_dashboard', org_id=ORGANISATION_ID) + page = client_request.get('.organization_dashboard', org_id=ORGANISATION_ID) usage_rows = page.select('main .govuk-grid-column-one-half') @@ -422,9 +422,9 @@ def test_organisation_services_shows_live_services_and_usage_with_count_of_1( (2018, '2018 to 2019 fiscal year'), (2019, '2019 to 2020 fiscal year'), )) -def test_organisation_services_filters_by_financial_year( +def test_organization_services_filters_by_financial_year( client_request, - mock_get_organisation, + mock_get_organization, mocker, active_user_with_permissions, fake_uuid, @@ -432,11 +432,11 @@ def test_organisation_services_filters_by_financial_year( expected_selected, ): mock = mocker.patch( - 'app.organisations_client.get_services_and_usage', + 'app.organizations_client.get_services_and_usage', return_value={"services": []} ) page = client_request.get( - '.organisation_dashboard', + '.organization_dashboard', org_id=ORGANISATION_ID, year=financial_year, ) @@ -452,15 +452,15 @@ def test_organisation_services_filters_by_financial_year( @freeze_time("2020-02-20 20:20") -def test_organisation_services_shows_search_bar( +def test_organization_services_shows_search_bar( client_request, - mock_get_organisation, + mock_get_organization, mocker, active_user_with_permissions, fake_uuid, ): mocker.patch( - 'app.organisations_client.get_services_and_usage', + 'app.organizations_client.get_services_and_usage', return_value={"services": [ { 'service_id': SERVICE_ONE_ID, @@ -476,12 +476,12 @@ def test_organisation_services_shows_search_bar( ) client_request.login(active_user_with_permissions) - page = client_request.get('.organisation_dashboard', org_id=ORGANISATION_ID) + page = client_request.get('.organization_dashboard', org_id=ORGANISATION_ID) - services = page.select('.organisation-service') + services = page.select('.organization-service') assert len(services) == 8 - assert page.select_one('.live-search')['data-targets'] == '.organisation-service' + assert page.select_one('.live-search')['data-targets'] == '.organization-service' assert [ normalize_spaces(service_name.text) for service_name in page.select('.live-search-relevant') @@ -498,15 +498,15 @@ def test_organisation_services_shows_search_bar( @freeze_time("2020-02-20 20:20") -def test_organisation_services_hides_search_bar_for_7_or_fewer_services( +def test_organization_services_hides_search_bar_for_7_or_fewer_services( client_request, - mock_get_organisation, + mock_get_organization, mocker, active_user_with_permissions, fake_uuid, ): mocker.patch( - 'app.organisations_client.get_services_and_usage', + 'app.organizations_client.get_services_and_usage', return_value={"services": [ { 'service_id': SERVICE_ONE_ID, @@ -522,23 +522,23 @@ def test_organisation_services_hides_search_bar_for_7_or_fewer_services( ) client_request.login(active_user_with_permissions) - page = client_request.get('.organisation_dashboard', org_id=ORGANISATION_ID) + page = client_request.get('.organization_dashboard', org_id=ORGANISATION_ID) - services = page.select('.organisation-service') + services = page.select('.organization-service') assert len(services) == 7 assert not page.select_one('.live-search') @freeze_time("2021-11-12 11:09:00.061258") -def test_organisation_services_links_to_downloadable_report( +def test_organization_services_links_to_downloadable_report( client_request, - mock_get_organisation, + mock_get_organization, mocker, active_user_with_permissions, fake_uuid, ): mocker.patch( - 'app.organisations_client.get_services_and_usage', + 'app.organizations_client.get_services_and_usage', return_value={"services": [ { 'service_id': SERVICE_ONE_ID, @@ -553,27 +553,27 @@ def test_organisation_services_links_to_downloadable_report( ] * 2} ) client_request.login(active_user_with_permissions) - page = client_request.get('.organisation_dashboard', org_id=ORGANISATION_ID) + page = client_request.get('.organization_dashboard', org_id=ORGANISATION_ID) link_to_report = page.select_one('a[download]') assert normalize_spaces(link_to_report.text) == 'Download this report (CSV)' assert link_to_report.attrs["href"] == url_for( - '.download_organisation_usage_report', + '.download_organization_usage_report', org_id=ORGANISATION_ID, selected_year=2021 ) @freeze_time("2021-11-12 11:09:00.061258") -def test_download_organisation_usage_report( +def test_download_organization_usage_report( client_request, - mock_get_organisation, + mock_get_organization, mocker, active_user_with_permissions, fake_uuid, ): mocker.patch( - 'app.organisations_client.get_services_and_usage', + 'app.organizations_client.get_services_and_usage', return_value={"services": [ { 'service_id': SERVICE_ONE_ID, @@ -599,7 +599,7 @@ def test_download_organisation_usage_report( ) client_request.login(active_user_with_permissions) csv_report = client_request.get( - '.download_organisation_usage_report', + '.download_organization_usage_report', org_id=ORGANISATION_ID, selected_year=2021, _test_page_title=False @@ -613,15 +613,15 @@ def test_download_organisation_usage_report( ) -def test_organisation_trial_mode_services_shows_all_non_live_services( +def test_organization_trial_mode_services_shows_all_non_live_services( client_request, platform_admin_user, - mock_get_organisation, + mock_get_organization, mocker, fake_uuid, ): mocker.patch( - 'app.organisations_client.get_organisation_services', + 'app.organizations_client.get_organization_services', return_value=[ service_json(id_='1', name='1', restricted=False, active=True), # live service_json(id_='2', name='2', restricted=True, active=True), # trial @@ -631,7 +631,7 @@ def test_organisation_trial_mode_services_shows_all_non_live_services( client_request.login(platform_admin_user) page = client_request.get( - '.organisation_trial_mode_services', + '.organization_trial_mode_services', org_id=ORGANISATION_ID, _test_page_title=False ) @@ -645,12 +645,12 @@ def test_organisation_trial_mode_services_shows_all_non_live_services( assert services[1].find('a')['href'] == url_for('main.service_dashboard', service_id='3') -def test_organisation_trial_mode_services_doesnt_work_if_not_platform_admin( +def test_organization_trial_mode_services_doesnt_work_if_not_platform_admin( client_request, - mock_get_organisation, + mock_get_organization, ): client_request.get( - '.organisation_trial_mode_services', + '.organization_trial_mode_services', org_id=ORGANISATION_ID, _expected_status=403 ) @@ -658,9 +658,9 @@ def test_organisation_trial_mode_services_doesnt_work_if_not_platform_admin( def test_manage_org_users_shows_correct_link_next_to_each_user( client_request, - mock_get_organisation, - mock_get_users_for_organisation, - mock_get_invited_users_for_organisation, + mock_get_organization, + mock_get_users_for_organization, + mock_get_invited_users_for_organization, ): page = client_request.get( '.manage_org_users', @@ -685,19 +685,19 @@ def test_manage_org_users_shows_correct_link_next_to_each_user( org_id=ORGANISATION_ID, invited_user_id='73616d70-6c65-4f6f-b267-5f696e766974' ) - assert users[1].a['href'] == url_for('.edit_organisation_user', org_id=ORGANISATION_ID, user_id='1234') - assert users[2].a['href'] == url_for('.edit_organisation_user', org_id=ORGANISATION_ID, user_id='5678') + assert users[1].a['href'] == url_for('.edit_organization_user', org_id=ORGANISATION_ID, user_id='1234') + assert users[2].a['href'] == url_for('.edit_organization_user', org_id=ORGANISATION_ID, user_id='5678') def test_manage_org_users_shows_no_link_for_cancelled_users( client_request, - mock_get_organisation, - mock_get_users_for_organisation, + mock_get_organization, + mock_get_users_for_organization, sample_org_invite, mocker, ): sample_org_invite['status'] = 'cancelled' - mocker.patch('app.models.user.OrganisationInvitedUsers.client_method', return_value=[sample_org_invite]) + mocker.patch('app.models.user.OrganizationInvitedUsers.client_method', return_value=[sample_org_invite]) page = client_request.get( '.manage_org_users', @@ -716,16 +716,16 @@ def test_manage_org_users_shows_no_link_for_cancelled_users( def test_manage_org_users_should_show_live_search_if_more_than_7_users( client_request, mocker, - mock_get_organisation, + mock_get_organization, active_user_with_permissions, number_of_users, ): mocker.patch( - 'app.models.user.OrganisationInvitedUsers.client_method', + 'app.models.user.OrganizationInvitedUsers.client_method', return_value=[], ) mocker.patch( - 'app.models.user.OrganisationUsers.client_method', + 'app.models.user.OrganizationUsers.client_method', return_value=[active_user_with_permissions] * number_of_users, ) @@ -761,16 +761,16 @@ def test_manage_org_users_should_show_live_search_if_more_than_7_users( def test_manage_org_users_should_show_live_search_if_7_users_or_less( client_request, mocker, - mock_get_organisation, + mock_get_organization, active_user_with_permissions, number_of_users, ): mocker.patch( - 'app.models.user.OrganisationInvitedUsers.client_method', + 'app.models.user.OrganizationInvitedUsers.client_method', return_value=[], ) mocker.patch( - 'app.models.user.OrganisationUsers.client_method', + 'app.models.user.OrganizationUsers.client_method', return_value=[active_user_with_permissions] * number_of_users, ) @@ -785,15 +785,15 @@ def test_manage_org_users_should_show_live_search_if_7_users_or_less( ) -def test_edit_organisation_user_shows_the_delete_confirmation_banner( +def test_edit_organization_user_shows_the_delete_confirmation_banner( client_request, - mock_get_organisation, - mock_get_invites_for_organisation, - mock_get_users_for_organisation, + mock_get_organization, + mock_get_invites_for_organization, + mock_get_users_for_organization, active_user_with_permissions, ): page = client_request.get( - '.edit_organisation_user', + '.edit_organization_user', org_id=ORGANISATION_ID, user_id=active_user_with_permissions['id'] ) @@ -803,22 +803,22 @@ def test_edit_organisation_user_shows_the_delete_confirmation_banner( banner = page.select_one('.banner-dangerous') assert "Are you sure you want to remove Test User?" in normalize_spaces(banner.contents[0]) assert banner.form.attrs['action'] == url_for( - 'main.remove_user_from_organisation', + 'main.remove_user_from_organization', org_id=ORGANISATION_ID, user_id=active_user_with_permissions['id'] ) -def test_remove_user_from_organisation_makes_api_request_to_remove_user( +def test_remove_user_from_organization_makes_api_request_to_remove_user( client_request, mocker, - mock_get_organisation, + mock_get_organization, fake_uuid, ): - mock_remove_user = mocker.patch('app.organisations_client.remove_user_from_organisation') + mock_remove_user = mocker.patch('app.organizations_client.remove_user_from_organization') client_request.post( - '.remove_user_from_organisation', + '.remove_user_from_organization', org_id=ORGANISATION_ID, user_id=fake_uuid, _expected_redirect=url_for( @@ -829,27 +829,27 @@ def test_remove_user_from_organisation_makes_api_request_to_remove_user( mock_remove_user.assert_called_with(ORGANISATION_ID, fake_uuid) -def test_organisation_settings_platform_admin_only( +def test_organization_settings_platform_admin_only( client_request, - mock_get_organisation, - organisation_one + mock_get_organization, + organization_one ): client_request.get( - '.organisation_settings', - org_id=organisation_one['id'], + '.organization_settings', + org_id=organization_one['id'], _expected_status=403, ) -def test_organisation_settings_for_platform_admin( +def test_organization_settings_for_platform_admin( client_request, platform_admin_user, - mock_get_organisation, - organisation_one + mock_get_organization, + organization_one ): expected_rows = [ 'Label Value Action', - 'Name Test organisation Change organization name', + 'Name Test organization Change organization name', 'Sector Federal government Change sector for the organization', 'Request to go live notes None Change go live notes for the organization', 'Billing details None Change billing details for the organization', @@ -859,19 +859,19 @@ def test_organisation_settings_for_platform_admin( ] client_request.login(platform_admin_user) - page = client_request.get('.organisation_settings', org_id=organisation_one['id']) + page = client_request.get('.organization_settings', org_id=organization_one['id']) assert page.find('h1').text == 'Settings' rows = page.select('tr') assert len(rows) == len(expected_rows) for index, row in enumerate(expected_rows): assert row == " ".join(rows[index].text.split()) - mock_get_organisation.assert_called_with(organisation_one['id']) + mock_get_organization.assert_called_with(organization_one['id']) @pytest.mark.parametrize('endpoint, expected_options, expected_selected', ( ( - '.edit_organisation_type', + '.edit_organization_type', ( {'value': 'federal', 'label': 'Federal government'}, {'value': 'state', 'label': 'State government'}, @@ -889,11 +889,11 @@ def test_organisation_settings_for_platform_admin( marks=pytest.mark.xfail ), )) -def test_view_organisation_settings( +def test_view_organization_settings( client_request, fake_uuid, - organisation_one, - mock_get_organisation, + organization_one, + mock_get_organization, endpoint, expected_options, expected_selected, @@ -901,7 +901,7 @@ def test_view_organisation_settings( ): client_request.login(user) - page = client_request.get(endpoint, org_id=organisation_one['id']) + page = client_request.get(endpoint, org_id=organization_one['id']) radios = page.select('input[type=radio]') @@ -923,14 +923,14 @@ def test_view_organisation_settings( @pytest.mark.parametrize('endpoint, post_data, expected_persisted', ( ( - '.edit_organisation_type', - {'organisation_type': 'federal'}, - {'cached_service_ids': [], 'organisation_type': 'federal'}, + '.edit_organization_type', + {'organization_type': 'federal'}, + {'cached_service_ids': [], 'organization_type': 'federal'}, ), ( - '.edit_organisation_type', - {'organisation_type': 'state'}, - {'cached_service_ids': [], 'organisation_type': 'state'}, + '.edit_organization_type', + {'organization_type': 'state'}, + {'cached_service_ids': [], 'organization_type': 'state'}, ), )) @pytest.mark.parametrize('user', ( @@ -941,70 +941,70 @@ def test_view_organisation_settings( create_active_user_with_permissions(), ), )) -def test_update_organisation_settings( +def test_update_organization_settings( mocker, client_request, fake_uuid, - organisation_one, - mock_get_organisation, - mock_update_organisation, + organization_one, + mock_get_organization, + mock_update_organization, endpoint, post_data, expected_persisted, user, ): - mocker.patch('app.organisations_client.get_organisation_services', return_value=[]) + mocker.patch('app.organizations_client.get_organization_services', return_value=[]) client_request.login(user) if user['email_address'] == 'platform@admin.gsa.gov': expected_status = 302 expected_redirect = url_for( - 'main.organisation_settings', - org_id=organisation_one['id'], + 'main.organization_settings', + org_id=organization_one['id'], ) else: expected_status = 403 expected_redirect = None client_request.post( endpoint, - org_id=organisation_one['id'], + org_id=organization_one['id'], _data=post_data, _expected_status=expected_status, _expected_redirect=expected_redirect, ) if user['email_address'] == 'platform@admin.gsa.gov': - mock_update_organisation.assert_called_once_with( - organisation_one['id'], + mock_update_organization.assert_called_once_with( + organization_one['id'], **expected_persisted, ) -def test_update_organisation_sector_sends_service_id_data_to_api_client( +def test_update_organization_sector_sends_service_id_data_to_api_client( client_request, - mock_get_organisation, - organisation_one, - mock_get_organisation_services, - mock_update_organisation, + mock_get_organization, + organization_one, + mock_get_organization_services, + mock_update_organization, platform_admin_user, ): client_request.login(platform_admin_user) client_request.post( - 'main.edit_organisation_type', - org_id=organisation_one['id'], - _data={'organisation_type': 'federal'}, + 'main.edit_organization_type', + org_id=organization_one['id'], + _data={'organization_type': 'federal'}, _expected_status=302, _expected_redirect=url_for( - 'main.organisation_settings', - org_id=organisation_one['id'], + 'main.organization_settings', + org_id=organization_one['id'], ), ) - mock_update_organisation.assert_called_once_with( - organisation_one['id'], + mock_update_organization.assert_called_once_with( + organization_one['id'], cached_service_ids=['12345', '67890', SERVICE_ONE_ID], - organisation_type='federal' + organization_type='federal' ) @@ -1017,7 +1017,7 @@ def test_update_organisation_sector_sends_service_id_data_to_api_client( marks=pytest.mark.xfail ), )) -def test_view_organisation_domains( +def test_view_organization_domains( mocker, client_request, fake_uuid, @@ -1026,8 +1026,8 @@ def test_view_organisation_domains( client_request.login(user) 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', domains=['example.gsa.gov', 'test.example.gsa.gov'], @@ -1035,7 +1035,7 @@ def test_view_organisation_domains( ) page = client_request.get( - 'main.edit_organisation_domains', + 'main.edit_organization_domains', org_id=ORGANISATION_ID, ) @@ -1097,12 +1097,12 @@ def test_view_organisation_domains( create_active_user_with_permissions(), ), )) -def test_update_organisation_domains( +def test_update_organization_domains( client_request, fake_uuid, - organisation_one, - mock_get_organisation, - mock_update_organisation, + organization_one, + mock_get_organization, + mock_update_organization, post_data, expected_persisted, user, @@ -1111,15 +1111,15 @@ def test_update_organisation_domains( if user['email_address'] == 'platform@admin.gsa.gov': expected_status = 302 expected_redirect = url_for( - 'main.organisation_settings', - org_id=organisation_one['id'], + 'main.organization_settings', + org_id=organization_one['id'], ) else: expected_status = 403 expected_redirect = None client_request.post( - 'main.edit_organisation_domains', + 'main.edit_organization_domains', org_id=ORGANISATION_ID, _data=post_data, _expected_status=expected_status, @@ -1127,23 +1127,23 @@ def test_update_organisation_domains( ) if user['email_address'] == 'platform@admin.gsa.gov': - mock_update_organisation.assert_called_once_with( + mock_update_organization.assert_called_once_with( ORGANISATION_ID, **expected_persisted, ) -def test_update_organisation_domains_when_domain_already_exists( +def test_update_organization_domains_when_domain_already_exists( mocker, client_request, fake_uuid, - organisation_one, - mock_get_organisation, + organization_one, + mock_get_organization, ): user = create_platform_admin_user() client_request.login(user) - mocker.patch('app.organisations_client.update_organisation', side_effect=HTTPError( + mocker.patch('app.organizations_client.update_organization', side_effect=HTTPError( response=mocker.Mock( status_code=400, json={'result': 'error', 'message': 'Domain already exists'} @@ -1152,7 +1152,7 @@ def test_update_organisation_domains_when_domain_already_exists( ) response = client_request.post( - 'main.edit_organisation_domains', + 'main.edit_organization_domains', org_id=ORGANISATION_ID, _data={ 'domains': [ @@ -1165,24 +1165,24 @@ def test_update_organisation_domains_when_domain_already_exists( assert response.find("div", class_="banner-dangerous").text.strip() == "This domain is already in use" -def test_update_organisation_name( +def test_update_organization_name( client_request, platform_admin_user, fake_uuid, - mock_get_organisation, - mock_update_organisation, + mock_get_organization, + mock_update_organization, ): client_request.login(platform_admin_user) client_request.post( - '.edit_organisation_name', + '.edit_organization_name', org_id=fake_uuid, _data={'name': 'TestNewOrgName'}, _expected_redirect=url_for( - '.organisation_settings', + '.organization_settings', org_id=fake_uuid, ) ) - mock_update_organisation.assert_called_once_with( + mock_update_organization.assert_called_once_with( fake_uuid, name='TestNewOrgName', cached_service_ids=None, @@ -1194,44 +1194,44 @@ def test_update_organisation_name( ('a', 'at least two alphanumeric characters'), ('a' * 256, 'Organization name must be 255 characters or fewer'), ]) -def test_update_organisation_with_incorrect_input( +def test_update_organization_with_incorrect_input( client_request, platform_admin_user, - organisation_one, - mock_get_organisation, + organization_one, + mock_get_organization, name, error_message ): client_request.login(platform_admin_user) page = client_request.post( - '.edit_organisation_name', - org_id=organisation_one['id'], + '.edit_organization_name', + org_id=organization_one['id'], _data={'name': name}, _expected_status=200, ) assert error_message in page.select_one('.usa-error-message').text -def test_update_organisation_with_non_unique_name( +def test_update_organization_with_non_unique_name( client_request, platform_admin_user, fake_uuid, - mock_get_organisation, + mock_get_organization, mocker, ): mocker.patch( - 'app.organisations_client.update_organisation', + 'app.organizations_client.update_organization', side_effect=HTTPError( response=mocker.Mock( status_code=400, - json={'result': 'error', 'message': 'Organisation name already exists'} + json={'result': 'error', 'message': 'Organization name already exists'} ), message='Organization name already exists', ) ) client_request.login(platform_admin_user) page = client_request.post( - '.edit_organisation_name', + '.edit_organization_name', org_id=fake_uuid, _data={'name': 'TestNewOrgName'}, _expected_status=200, @@ -1240,16 +1240,16 @@ def test_update_organisation_with_non_unique_name( assert 'This organization name is already in use' in page.select_one('.usa-error-message').text -def test_get_edit_organisation_go_live_notes_page( +def test_get_edit_organization_go_live_notes_page( client_request, platform_admin_user, - mock_get_organisation, - organisation_one, + mock_get_organization, + organization_one, ): client_request.login(platform_admin_user) page = client_request.get( - '.edit_organisation_go_live_notes', - org_id=organisation_one['id'], + '.edit_organization_go_live_notes', + org_id=organization_one['id'], ) assert page.find('textarea', id='request_to_go_live_notes') @@ -1258,152 +1258,152 @@ def test_get_edit_organisation_go_live_notes_page( ('Needs permission', 'Needs permission'), (' ', None) ]) -def test_post_edit_organisation_go_live_notes_updates_go_live_notes( +def test_post_edit_organization_go_live_notes_updates_go_live_notes( client_request, platform_admin_user, - mock_get_organisation, - mock_update_organisation, - organisation_one, + mock_get_organization, + mock_update_organization, + organization_one, input_note, saved_note, ): client_request.login(platform_admin_user) client_request.post( - '.edit_organisation_go_live_notes', - org_id=organisation_one['id'], + '.edit_organization_go_live_notes', + org_id=organization_one['id'], _data={'request_to_go_live_notes': input_note}, _expected_redirect=url_for( - '.organisation_settings', - org_id=organisation_one['id'], + '.organization_settings', + org_id=organization_one['id'], ), ) - mock_update_organisation.assert_called_once_with( - organisation_one['id'], + mock_update_organization.assert_called_once_with( + organization_one['id'], request_to_go_live_notes=saved_note ) -def test_organisation_settings_links_to_edit_organisation_notes_page( +def test_organization_settings_links_to_edit_organization_notes_page( mocker, - mock_get_organisation, - organisation_one, + mock_get_organization, + organization_one, client_request, platform_admin_user, ): client_request.login(platform_admin_user) page = client_request.get( - '.organisation_settings', org_id=organisation_one['id'] + '.organization_settings', org_id=organization_one['id'] ) assert len(page.find_all( - 'a', attrs={'href': '/organisations/{}/settings/notes'.format(organisation_one['id'])} + 'a', attrs={'href': '/organizations/{}/settings/notes'.format(organization_one['id'])} )) == 1 -def test_view_edit_organisation_notes( +def test_view_edit_organization_notes( client_request, platform_admin_user, - organisation_one, - mock_get_organisation, + organization_one, + mock_get_organization, ): client_request.login(platform_admin_user) page = client_request.get( - 'main.edit_organisation_notes', - org_id=organisation_one['id'], + 'main.edit_organization_notes', + org_id=organization_one['id'], ) assert page.select_one('h1').text == "Edit organization notes" assert page.find('label', class_="usa-label").text.strip() == "Notes" assert page.find('textarea').attrs["name"] == "notes" -def test_update_organisation_notes( +def test_update_organization_notes( client_request, platform_admin_user, - organisation_one, - mock_get_organisation, - mock_update_organisation, + organization_one, + mock_get_organization, + mock_update_organization, ): client_request.login(platform_admin_user) client_request.post( - 'main.edit_organisation_notes', - org_id=organisation_one['id'], + 'main.edit_organization_notes', + org_id=organization_one['id'], _data={'notes': "Very fluffy"}, _expected_redirect=url_for( - 'main.organisation_settings', - org_id=organisation_one['id'], + 'main.organization_settings', + org_id=organization_one['id'], ), ) - mock_update_organisation.assert_called_with( - organisation_one['id'], + mock_update_organization.assert_called_with( + organization_one['id'], cached_service_ids=None, notes="Very fluffy" ) -def test_update_organisation_notes_errors_when_user_not_platform_admin( +def test_update_organization_notes_errors_when_user_not_platform_admin( client_request, - organisation_one, - mock_get_organisation, - mock_update_organisation, + organization_one, + mock_get_organization, + mock_update_organization, ): client_request.post( - 'main.edit_organisation_notes', - org_id=organisation_one['id'], + 'main.edit_organization_notes', + org_id=organization_one['id'], _data={'notes': "Very fluffy"}, _expected_status=403, ) -def test_update_organisation_notes_doesnt_call_api_when_notes_dont_change( +def test_update_organization_notes_doesnt_call_api_when_notes_dont_change( client_request, platform_admin_user, - organisation_one, - mock_update_organisation, + organization_one, + mock_update_organization, mocker ): - mocker.patch('app.organisations_client.get_organisation', return_value=organisation_json( - id_=organisation_one['id'], + mocker.patch('app.organizations_client.get_organization', return_value=organization_json( + id_=organization_one['id'], name="Test Org", notes="Very fluffy" )) client_request.login(platform_admin_user) client_request.post( - 'main.edit_organisation_notes', - org_id=organisation_one['id'], + 'main.edit_organization_notes', + org_id=organization_one['id'], _data={'notes': "Very fluffy"}, _expected_redirect=url_for( - 'main.organisation_settings', - org_id=organisation_one['id'], + 'main.organization_settings', + org_id=organization_one['id'], ), ) - assert not mock_update_organisation.called + assert not mock_update_organization.called -def test_organisation_settings_links_to_edit_organisation_billing_details_page( +def test_organization_settings_links_to_edit_organization_billing_details_page( mocker, - mock_get_organisation, - organisation_one, + mock_get_organization, + organization_one, client_request, platform_admin_user, ): client_request.login(platform_admin_user) page = client_request.get( - '.organisation_settings', org_id=organisation_one['id'] + '.organization_settings', org_id=organization_one['id'] ) assert len(page.find_all( - 'a', attrs={'href': '/organisations/{}/settings/edit-billing-details'.format(organisation_one['id'])} + 'a', attrs={'href': '/organizations/{}/settings/edit-billing-details'.format(organization_one['id'])} )) == 1 -def test_view_edit_organisation_billing_details( +def test_view_edit_organization_billing_details( client_request, platform_admin_user, - organisation_one, - mock_get_organisation, + organization_one, + mock_get_organization, ): client_request.login(platform_admin_user) page = client_request.get( - 'main.edit_organisation_billing_details', - org_id=organisation_one['id'], + 'main.edit_organization_billing_details', + org_id=organization_one['id'], ) assert page.select_one('h1').text == "Edit organization billing details" labels = page.find_all('label', class_="usa-label") @@ -1430,17 +1430,17 @@ def test_view_edit_organisation_billing_details( assert page.find('textarea').attrs["name"] == "notes" -def test_update_organisation_billing_details( +def test_update_organization_billing_details( client_request, platform_admin_user, - organisation_one, - mock_get_organisation, - mock_update_organisation, + organization_one, + mock_get_organization, + mock_update_organization, ): client_request.login(platform_admin_user) client_request.post( - 'main.edit_organisation_billing_details', - org_id=organisation_one['id'], + 'main.edit_organization_billing_details', + org_id=organization_one['id'], _data={ 'billing_contact_email_addresses': 'accounts@fluff.gsa.gov', 'billing_contact_names': 'Flannellette von Fluff', @@ -1449,12 +1449,12 @@ def test_update_organisation_billing_details( 'notes': 'very fluffy, give extra allowance' }, _expected_redirect=url_for( - 'main.organisation_settings', - org_id=organisation_one['id'], + 'main.organization_settings', + org_id=organization_one['id'], ) ) - mock_update_organisation.assert_called_with( - organisation_one['id'], + mock_update_organization.assert_called_with( + organization_one['id'], cached_service_ids=None, billing_contact_email_addresses='accounts@fluff.gsa.gov', billing_contact_names='Flannellette von Fluff', @@ -1464,26 +1464,26 @@ def test_update_organisation_billing_details( ) -def test_update_organisation_billing_details_errors_when_user_not_platform_admin( +def test_update_organization_billing_details_errors_when_user_not_platform_admin( client_request, - organisation_one, - mock_get_organisation, - mock_update_organisation, + organization_one, + mock_get_organization, + mock_update_organization, ): client_request.post( - 'main.edit_organisation_billing_details', - org_id=organisation_one['id'], + 'main.edit_organization_billing_details', + org_id=organization_one['id'], _data={'notes': "Very fluffy"}, _expected_status=403, ) -def test_organisation_billing_page_not_accessible_if_not_platform_admin( +def test_organization_billing_page_not_accessible_if_not_platform_admin( client_request, - mock_get_organisation, + mock_get_organization, ): client_request.get( - '.organisation_billing', + '.organization_billing', org_id=ORGANISATION_ID, _expected_status=403 ) diff --git a/tests/app/main/views/service_settings/test_email_branding_requests.py b/tests/app/main/views/service_settings/test_email_branding_requests.py index 5739f91dc..a94e38dbc 100644 --- a/tests/app/main/views/service_settings/test_email_branding_requests.py +++ b/tests/app/main/views/service_settings/test_email_branding_requests.py @@ -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' ]), diff --git a/tests/app/main/views/service_settings/test_service_setting_permissions.py b/tests/app/main/views/service_settings/test_service_setting_permissions.py index 276dd973b..b45a045cc 100644 --- a/tests/app/main/views/service_settings/test_service_setting_permissions.py +++ b/tests/app/main/views/service_settings/test_service_setting_permissions.py @@ -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, diff --git a/tests/app/main/views/service_settings/test_service_settings.py b/tests/app/main/views/service_settings/test_service_settings.py index 21c602717..1df4bba24 100644 --- a/tests/app/main/views/service_settings/test_service_settings.py +++ b/tests/app/main/views/service_settings/test_service_settings.py @@ -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 diff --git a/tests/app/main/views/test_add_service.py b/tests/app/main/views/test_add_service.py index 910c8e79b..06539a654 100644 --- a/tests/app/main/views/test_add_service.py +++ b/tests/app/main/views/test_add_service.py @@ -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) diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 31ac51b78..142db9a94 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -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, ) diff --git a/tests/app/main/views/test_email_branding.py b/tests/app/main/views/test_email_branding.py index 6a4b7d0e8..2af1985d5 100644 --- a/tests/app/main/views/test_email_branding.py +++ b/tests/app/main/views/test_email_branding.py @@ -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, diff --git a/tests/app/main/views/test_email_preview.py b/tests/app/main/views/test_email_preview.py index 3854cf683..ef0080471 100644 --- a/tests/app/main/views/test_email_preview.py +++ b/tests/app/main/views/test_email_preview.py @@ -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( diff --git a/tests/app/main/views/test_feedback.py b/tests/app/main/views/test_feedback.py index f7f22455c..6b087a5da 100644 --- a/tests/app/main/views/test_feedback.py +++ b/tests/app/main/views/test_feedback.py @@ -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, diff --git a/tests/app/main/views/test_find_users.py b/tests/app/main/views/test_find_users.py index df5fbeeed..c69544374 100644 --- a/tests/app/main/views/test_find_users.py +++ b/tests/app/main/views/test_find_users.py @@ -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', diff --git a/tests/app/main/views/test_headers.py b/tests/app/main/views/test_headers.py index 6d4c2e6d4..77fa3b495 100644 --- a/tests/app/main/views/test_headers.py +++ b/tests/app/main/views/test_headers.py @@ -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') diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py index a85544203..13af3338e 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -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, ): diff --git a/tests/app/main/views/test_manage_users.py b/tests/app/main/views/test_manage_users.py index 940bf77c4..e672c1a6b 100644 --- a/tests/app/main/views/test_manage_users.py +++ b/tests/app/main/views/test_manage_users.py @@ -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', diff --git a/tests/app/main/views/test_performance.py b/tests/app/main/views/test_performance.py index 24eaa0ca7..53631edd0 100644 --- a/tests/app/main/views/test_performance.py +++ b/tests/app/main/views/test_performance.py @@ -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', diff --git a/tests/app/main/views/test_platform_admin.py b/tests/app/main/views/test_platform_admin.py index 12172a6e6..519e81eaf 100644 --- a/tests/app/main/views/test_platform_admin.py +++ b/tests/app/main/views/test_platform_admin.py @@ -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,' + diff --git a/tests/app/main/views/test_register.py b/tests/app/main/views/test_register.py index 424fae580..641bb2ee2 100644 --- a/tests/app/main/views/test_register.py +++ b/tests/app/main/views/test_register.py @@ -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, diff --git a/tests/app/main/views/test_sign_in.py b/tests/app/main/views/test_sign_in.py index 03dc771f6..e8e0bc114 100644 --- a/tests/app/main/views/test_sign_in.py +++ b/tests/app/main/views/test_sign_in.py @@ -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)) diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py index ce3150a1b..61ff06f20 100644 --- a/tests/app/main/views/test_templates.py +++ b/tests/app/main/views/test_templates.py @@ -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', diff --git a/tests/app/main/views/test_user_profile.py b/tests/app/main/views/test_user_profile.py index 2caf56260..ead6cd4c6 100644 --- a/tests/app/main/views/test_user_profile.py +++ b/tests/app/main/views/test_user_profile.py @@ -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) diff --git a/tests/app/models/test_organisation.py b/tests/app/models/test_organisation.py deleted file mode 100644 index 7d66dca29..000000000 --- a/tests/app/models/test_organisation.py +++ /dev/null @@ -1,13 +0,0 @@ -import pytest - -from app.models.organisation import Organisation -from tests import organisation_json - - -@pytest.mark.parametrize("purchase_order_number,expected_result", [ - [None, None], - ["PO1234", [None, None, None, "PO1234"]] -]) -def test_organisation_billing_details(purchase_order_number, expected_result): - organisation = Organisation(organisation_json(purchase_order_number=purchase_order_number)) - assert organisation.billing_details == expected_result diff --git a/tests/app/models/test_organization.py b/tests/app/models/test_organization.py new file mode 100644 index 000000000..de9841497 --- /dev/null +++ b/tests/app/models/test_organization.py @@ -0,0 +1,13 @@ +import pytest + +from app.models.organization import Organization +from tests import organization_json + + +@pytest.mark.parametrize("purchase_order_number,expected_result", [ + [None, None], + ["PO1234", [None, None, None, "PO1234"]] +]) +def test_organization_billing_details(purchase_order_number, expected_result): + organization = Organization(organization_json(purchase_order_number=purchase_order_number)) + assert organization.billing_details == expected_result diff --git a/tests/app/models/test_service.py b/tests/app/models/test_service.py index 8cd3b6f4e..5cc257230 100644 --- a/tests/app/models/test_service.py +++ b/tests/app/models/test_service.py @@ -1,46 +1,46 @@ import pytest -from app.models.organisation import Organisation +from app.models.organization import Organization from app.models.service import Service -from tests import organisation_json, service_json +from tests import organization_json, service_json from tests.conftest import ORGANISATION_ID, create_folder, create_template -def test_organisation_type_when_services_organisation_has_no_org_type(mocker, service_one): +def test_organization_type_when_services_organization_has_no_org_type(mocker, service_one): service = Service(service_one) - service._dict['organisation_id'] = ORGANISATION_ID - org = organisation_json(organisation_type=None) - mocker.patch('app.organisations_client.get_organisation', return_value=org) + service._dict['organization_id'] = ORGANISATION_ID + org = organization_json(organization_type=None) + mocker.patch('app.organizations_client.get_organization', return_value=org) - assert not org['organisation_type'] - assert service.organisation_type == 'federal' + assert not org['organization_type'] + assert service.organization_type == 'federal' -def test_organisation_type_when_service_and_its_org_both_have_an_org_type(mocker, service_one): - # service_one has an organisation_type of 'central' +def test_organization_type_when_service_and_its_org_both_have_an_org_type(mocker, service_one): + # service_one has an organization_type of 'central' service = Service(service_one) - service._dict['organisation'] = ORGANISATION_ID - org = organisation_json(organisation_type='local') - mocker.patch('app.organisations_client.get_organisation', return_value=org) + service._dict['organization'] = ORGANISATION_ID + org = organization_json(organization_type='local') + mocker.patch('app.organizations_client.get_organization', return_value=org) - assert service.organisation_type == 'local' + assert service.organization_type == 'local' -def test_organisation_name_comes_from_cache(mocker, service_one): +def test_organization_name_comes_from_cache(mocker, service_one): mock_redis_get = mocker.patch( 'app.extensions.RedisClient.get', return_value=b'"Borchester Council"', ) - mock_get_organisation = mocker.patch('app.organisations_client.get_organisation') + mock_get_organization = mocker.patch('app.organizations_client.get_organization') service = Service(service_one) - service._dict['organisation'] = ORGANISATION_ID + service._dict['organization'] = ORGANISATION_ID - assert service.organisation_name == 'Borchester Council' - mock_redis_get.assert_called_once_with(f'organisation-{ORGANISATION_ID}-name') - assert mock_get_organisation.called is False + assert service.organization_name == 'Borchester Council' + mock_redis_get.assert_called_once_with(f'organization-{ORGANISATION_ID}-name') + assert mock_get_organization.called is False -def test_organisation_name_goes_into_cache(mocker, service_one): +def test_organization_name_goes_into_cache(mocker, service_one): mocker.patch( 'app.extensions.RedisClient.get', return_value=None, @@ -49,32 +49,32 @@ def test_organisation_name_goes_into_cache(mocker, service_one): 'app.extensions.RedisClient.set', ) mocker.patch( - 'app.organisations_client.get_organisation', - return_value=organisation_json(), + 'app.organizations_client.get_organization', + return_value=organization_json(), ) service = Service(service_one) - service._dict['organisation'] = ORGANISATION_ID + service._dict['organization'] = ORGANISATION_ID - assert service.organisation_name == 'Test Organisation' + assert service.organization_name == 'Test Organization' mock_redis_set.assert_called_once_with( - f'organisation-{ORGANISATION_ID}-name', - '"Test Organisation"', + f'organization-{ORGANISATION_ID}-name', + '"Test Organization"', ex=604800, ) -def test_service_without_organisation_doesnt_need_org_api(mocker, service_one): +def test_service_without_organization_doesnt_need_org_api(mocker, service_one): mock_redis_get = mocker.patch('app.extensions.RedisClient.get') - mock_get_organisation = mocker.patch('app.organisations_client.get_organisation') + mock_get_organization = mocker.patch('app.organizations_client.get_organization') service = Service(service_one) - service._dict['organisation'] = None + service._dict['organization'] = None - assert service.organisation_id is None - assert service.organisation_name is None - assert isinstance(service.organisation, Organisation) + assert service.organization_id is None + assert service.organization_name is None + assert isinstance(service.organization, Organization) assert mock_redis_get.called is False - assert mock_get_organisation.called is False + assert mock_get_organization.called is False def test_bad_permission_raises(service_one): diff --git a/tests/app/models/test_user.py b/tests/app/models/test_user.py index 47aab5aca..ae3e36cb2 100644 --- a/tests/app/models/test_user.py +++ b/tests/app/models/test_user.py @@ -7,10 +7,10 @@ from tests.conftest import SERVICE_ONE_ID, USER_ONE_ID def test_anonymous_user(notify_admin): assert AnonymousUser().is_authenticated is False assert AnonymousUser().logged_in_elsewhere() is False - assert AnonymousUser().default_organisation.name is None - assert AnonymousUser().default_organisation.domains == [] - assert AnonymousUser().default_organisation.organisation_type is None - assert AnonymousUser().default_organisation.request_to_go_live_notes is None + assert AnonymousUser().default_organization.name is None + assert AnonymousUser().default_organization.domains == [] + assert AnonymousUser().default_organization.organization_type is None + assert AnonymousUser().default_organization.request_to_go_live_notes is None def test_user(notify_admin): @@ -75,7 +75,7 @@ def test_platform_admin_flag_set_in_session( def test_has_live_services( client_request, - mock_get_non_empty_organisations_and_services_for_user, + mock_get_non_empty_organizations_and_services_for_user, fake_uuid, ): user = User({ @@ -89,7 +89,7 @@ def test_has_live_services( def test_has_live_services_when_there_are_no_services( client_request, - mock_get_organisations_and_services_for_user, + mock_get_organizations_and_services_for_user, fake_uuid, ): assert User({ @@ -100,7 +100,7 @@ def test_has_live_services_when_there_are_no_services( def test_has_live_services_when_service_is_not_live( client_request, - mock_get_empty_organisations_and_one_service_for_user, + mock_get_empty_organizations_and_one_service_for_user, fake_uuid, ): assert User({ diff --git a/tests/app/notify_client/test_organisation_client.py b/tests/app/notify_client/test_organization_client.py similarity index 67% rename from tests/app/notify_client/test_organisation_client.py rename to tests/app/notify_client/test_organization_client.py index 92b0e7167..f6e67311e 100644 --- a/tests/app/notify_client/test_organisation_client.py +++ b/tests/app/notify_client/test_organization_client.py @@ -2,7 +2,7 @@ from unittest.mock import ANY, call import pytest -from app import organisations_client +from app import organizations_client @pytest.mark.parametrize( @@ -34,15 +34,15 @@ from app import organisations_client 'get_domains', [ call('domains'), - call('organisations'), + call('organizations'), ], None, [ - call(url='/organisations') + call(url='/organizations') ], [ call( - 'organisations', + 'organizations', '[{"domains": ["x", "y", "z"]}]', ex=604800, ), @@ -55,9 +55,9 @@ from app import organisations_client 'from api', ), ( - 'get_organisations', + 'get_organizations', [ - call('organisations'), + call('organizations'), ], b""" [ @@ -73,17 +73,17 @@ from app import organisations_client ], ), ( - 'get_organisations', + 'get_organizations', [ - call('organisations'), + call('organizations'), ], None, [ - call(url='/organisations') + call(url='/organizations') ], [ call( - 'organisations', + 'organizations', '[{"domains": ["x", "y", "z"]}]', ex=604800, ), @@ -117,7 +117,7 @@ def test_returns_value_from_cache( 'app.extensions.RedisClient.set', ) - getattr(organisations_client, client_method)() + getattr(organizations_client, client_method)() assert mock_redis_get.call_args_list == expected_cache_get_calls assert mock_api_get.call_args_list == expected_api_calls @@ -134,7 +134,7 @@ def test_deletes_domain_cache( mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete') mock_request = mocker.patch('notifications_python_client.base.BaseAPIClient.request') - organisations_client.update_organisation(fake_uuid, foo='bar') + organizations_client.update_organization(fake_uuid, foo='bar') assert call('domains') in mock_redis_delete.call_args_list assert len(mock_request.call_args_list) == 1 @@ -142,16 +142,16 @@ def test_deletes_domain_cache( @pytest.mark.parametrize('post_data, expected_cache_delete_calls', ( ({'foo': 'bar'}, [ - call('organisations'), + call('organizations'), call('domains'), ]), ({'name': 'new name'}, [ - call('organisation-6ce466d0-fd6a-11e5-82f5-e0accb9d11a6-name'), - call('organisations'), + call('organization-6ce466d0-fd6a-11e5-82f5-e0accb9d11a6-name'), + call('organizations'), call('domains'), ]), )) -def test_update_organisation_when_not_updating_org_type( +def test_update_organization_when_not_updating_org_type( mocker, fake_uuid, post_data, @@ -159,89 +159,89 @@ def test_update_organisation_when_not_updating_org_type( ): mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete') - mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post') + mock_post = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.post') - organisations_client.update_organisation(fake_uuid, **post_data) + organizations_client.update_organization(fake_uuid, **post_data) mock_post.assert_called_with( - url='/organisations/{}'.format(fake_uuid), + url='/organizations/{}'.format(fake_uuid), data=post_data ) assert mock_redis_delete.call_args_list == expected_cache_delete_calls -def test_update_organisation_when_updating_org_type_and_org_has_services(mocker, fake_uuid): +def test_update_organization_when_updating_org_type_and_org_has_services(mocker, fake_uuid): mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete') - mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post') + mock_post = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.post') - organisations_client.update_organisation( + organizations_client.update_organization( fake_uuid, cached_service_ids=['a', 'b', 'c'], - organisation_type='central', + organization_type='central', ) mock_post.assert_called_with( - url='/organisations/{}'.format(fake_uuid), - data={'organisation_type': 'central'} + url='/organizations/{}'.format(fake_uuid), + data={'organization_type': 'central'} ) assert mock_redis_delete.call_args_list == [ call('service-a', 'service-b', 'service-c'), - call('organisations'), + call('organizations'), call('domains'), ] -def test_update_organisation_when_updating_org_type_but_org_has_no_services(mocker, fake_uuid): +def test_update_organization_when_updating_org_type_but_org_has_no_services(mocker, fake_uuid): mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete') - mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post') + mock_post = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.post') - organisations_client.update_organisation( + organizations_client.update_organization( fake_uuid, cached_service_ids=[], - organisation_type='central', + organization_type='central', ) mock_post.assert_called_with( - url='/organisations/{}'.format(fake_uuid), - data={'organisation_type': 'central'} + url='/organizations/{}'.format(fake_uuid), + data={'organization_type': 'central'} ) assert mock_redis_delete.call_args_list == [ - call('organisations'), + call('organizations'), call('domains'), ] -def test_update_service_organisation_deletes_cache(mocker, fake_uuid): +def test_update_service_organization_deletes_cache(mocker, fake_uuid): mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete') - mock_post = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.post') + mock_post = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.post') - organisations_client.update_service_organisation( + organizations_client.update_service_organization( service_id=fake_uuid, org_id=fake_uuid ) assert sorted(mock_redis_delete.call_args_list) == [ - call('live-service-and-organisation-counts'), - call('organisations'), + call('live-service-and-organization-counts'), + call('organizations'), call('service-{}'.format(fake_uuid)), ] mock_post.assert_called_with( - url='/organisations/{}/service'.format(fake_uuid), + url='/organizations/{}/service'.format(fake_uuid), data=ANY ) -def test_remove_user_from_organisation_deletes_user_cache(mocker): +def test_remove_user_from_organization_deletes_user_cache(mocker): mock_redis_delete = mocker.patch('app.extensions.RedisClient.delete') - mock_delete = mocker.patch('app.notify_client.organisations_api_client.OrganisationsClient.delete') + mock_delete = mocker.patch('app.notify_client.organizations_api_client.OrganizationsClient.delete') org_id = 'abcd-1234' user_id = 'efgh-5678' - organisations_client.remove_user_from_organisation( + organizations_client.remove_user_from_organization( org_id=org_id, user_id=user_id, ) assert mock_redis_delete.call_args_list == [call(f'user-{user_id}')] - mock_delete.assert_called_with(f'/organisations/{org_id}/users/{user_id}') + mock_delete.assert_called_with(f'/organizations/{org_id}/users/{user_id}') diff --git a/tests/app/notify_client/test_service_api_client.py b/tests/app/notify_client/test_service_api_client.py index 83699ff56..1f285e632 100644 --- a/tests/app/notify_client/test_service_api_client.py +++ b/tests/app/notify_client/test_service_api_client.py @@ -81,7 +81,7 @@ def test_client_creates_service_with_correct_data( # ‘service_name’ argument is coerced to ‘name’ name='My first service', # The rest pass through with the same names - organisation_type='central_government', + organization_type='central_government', message_limit=1, restricted=True, user_id=fake_uuid, @@ -514,7 +514,7 @@ def test_client_updates_service_with_allowed_attributes( 'message_limit', 'name', 'notes', - 'organisation_type', + 'organization_type', 'permissions', 'prefix_sms', 'rate_limit', diff --git a/tests/app/notify_client/test_status_api_client.py b/tests/app/notify_client/test_status_api_client.py index e434bc9d1..907fd6b29 100644 --- a/tests/app/notify_client/test_status_api_client.py +++ b/tests/app/notify_client/test_status_api_client.py @@ -1,14 +1,14 @@ from app.notify_client.status_api_client import StatusApiClient -def test_get_count_of_live_services_and_organisations(mocker): +def test_get_count_of_live_services_and_organizations(mocker): mocker.patch('app.extensions.RedisClient.get', return_value=None) client = StatusApiClient() mock = mocker.patch.object(client, 'get', return_value={}) - client.get_count_of_live_services_and_organisations() + client.get_count_of_live_services_and_organizations() - mock.assert_called_once_with(url='/_status/live-service-and-organisation-counts') + mock.assert_called_once_with(url='/_status/live-service-and-organization-counts') def test_sets_value_in_cache(mocker): @@ -26,12 +26,12 @@ def test_sets_value_in_cache(mocker): 'app.extensions.RedisClient.set', ) - assert client.get_count_of_live_services_and_organisations() == {'data_from': 'api'} + assert client.get_count_of_live_services_and_organizations() == {'data_from': 'api'} - mock_redis_get.assert_called_once_with('live-service-and-organisation-counts') - mock_api_get.assert_called_once_with(url='/_status/live-service-and-organisation-counts') + mock_redis_get.assert_called_once_with('live-service-and-organization-counts') + mock_api_get.assert_called_once_with(url='/_status/live-service-and-organization-counts') mock_redis_set.assert_called_once_with( - 'live-service-and-organisation-counts', + 'live-service-and-organization-counts', '{"data_from": "api"}', ex=3600 ) @@ -51,9 +51,9 @@ def test_returns_value_from_cache(mocker): 'app.extensions.RedisClient.set', ) - assert client.get_count_of_live_services_and_organisations() == {'data_from': 'cache'} + assert client.get_count_of_live_services_and_organizations() == {'data_from': 'cache'} - mock_redis_get.assert_called_once_with('live-service-and-organisation-counts') + mock_redis_get.assert_called_once_with('live-service-and-organization-counts') assert mock_api_get.called is False assert mock_redis_set.called is False diff --git a/tests/app/notify_client/test_user_client.py b/tests/app/notify_client/test_user_client.py index 82b3f4bc6..e7aff5610 100644 --- a/tests/app/notify_client/test_user_client.py +++ b/tests/app/notify_client/test_user_client.py @@ -192,7 +192,7 @@ def test_returns_value_from_cache( (user_api_client, 'check_verify_code', [user_id, '', ''], {}), (user_api_client, 'complete_webauthn_login_attempt', [user_id], {'is_successful': True}), (user_api_client, 'add_user_to_service', [SERVICE_ONE_ID, user_id, [], []], {}), - (user_api_client, 'add_user_to_organisation', [sample_uuid(), user_id], {}), + (user_api_client, 'add_user_to_organization', [sample_uuid(), user_id], {}), (user_api_client, 'set_user_permissions', [user_id, SERVICE_ONE_ID, []], {}), (user_api_client, 'activate_user', [user_id], {}), (user_api_client, 'archive_user', [user_id], {}), diff --git a/tests/app/test_navigation.py b/tests/app/test_navigation.py index 8f36a3131..fefa3722f 100644 --- a/tests/app/test_navigation.py +++ b/tests/app/test_navigation.py @@ -18,7 +18,7 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'accessibility_statement', 'action_blocked', 'add_data_retention', - 'add_organisation', + 'add_organization', 'add_service', 'add_service_template', 'api_callbacks', @@ -66,17 +66,17 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'design_content', 'documentation', 'download_notifications_csv', - 'download_organisation_usage_report', + 'download_organization_usage_report', 'edit_and_format_messages', 'edit_data_retention', - 'edit_organisation_billing_details', - 'edit_organisation_domains', - 'edit_organisation_email_branding', - 'edit_organisation_go_live_notes', - 'edit_organisation_name', - 'edit_organisation_notes', - 'edit_organisation_type', - 'edit_organisation_user', + 'edit_organization_billing_details', + 'edit_organization_domains', + 'edit_organization_email_branding', + 'edit_organization_go_live_notes', + 'edit_organization_name', + 'edit_organization_notes', + 'edit_organization_type', + 'edit_organization_user', 'edit_service_billing_details', 'edit_service_notes', 'edit_service_template', @@ -88,7 +88,7 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'email_branding_govuk', 'email_branding_govuk_and_org', 'email_branding_nhs', - 'email_branding_organisation', + 'email_branding_organization', 'email_branding_request', 'email_branding_something_else', 'email_not_received', @@ -125,7 +125,7 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'integration_testing', 'invite_org_user', 'invite_user', - 'link_service_to_organisation', + 'link_service_to_organization', 'live_services', 'live_services_csv', 'manage_org_users', @@ -141,12 +141,12 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'old_service_dashboard', 'old_terms', 'old_using_notify', - 'organisation_billing', - 'organisation_dashboard', - 'organisation_preview_email_branding', - 'organisation_settings', - 'organisation_trial_mode_services', - 'organisations', + 'organization_billing', + 'organization_dashboard', + 'organization_preview_email_branding', + 'organization_settings', + 'organization_trial_mode_services', + 'organizations', 'performance', 'platform_admin', 'platform_admin_list_complaints', @@ -160,7 +160,7 @@ EXCLUDED_ENDPOINTS = tuple(map(Navigation.get_endpoint_with_blueprint, { 'register_from_invite', 'register_from_org_invite', 'registration_continue', - 'remove_user_from_organisation', + 'remove_user_from_organization', 'remove_user_from_service', 'request_to_go_live', 'resend_email_link', @@ -397,20 +397,20 @@ def test_a_page_should_nave_selected_navigation_item( @pytest.mark.parametrize('endpoint, selected_nav_item', [ - ('main.organisation_dashboard', 'Usage'), + ('main.organization_dashboard', 'Usage'), ('main.manage_org_users', 'Team members'), ]) def test_a_page_should_nave_selected_org_navigation_item( client_request, - mock_get_organisation, - mock_get_users_for_organisation, - mock_get_invited_users_for_organisation, + mock_get_organization, + mock_get_users_for_organization, + mock_get_invited_users_for_organization, endpoint, selected_nav_item, mocker ): mocker.patch( - 'app.organisations_client.get_services_and_usage', return_value={'services': {}} + 'app.organizations_client.get_services_and_usage', return_value={'services': {}} ) # page = client_request.get(endpoint, org_id=ORGANISATION_ID) # selected_nav_item_element = page.select_one('.usa-sidenav a.usa-current') diff --git a/tests/app/utils/test_branding.py b/tests/app/utils/test_branding.py index 0ded8c7a1..62b85a5b2 100644 --- a/tests/app/utils/test_branding.py +++ b/tests/app/utils/test_branding.py @@ -4,7 +4,7 @@ import pytest from app.models.service import Service from app.utils.branding import get_email_choices -from tests import organisation_json +from tests import organization_json from tests.conftest import create_email_branding @@ -19,7 +19,7 @@ def test_get_choices_service_not_assigned_to_org( org_type, expected_options, ): - service_one['organisation_type'] = org_type + service_one['organization_type'] = org_type service = Service(service_one) options = function(service) @@ -28,19 +28,19 @@ def test_get_choices_service_not_assigned_to_org( @pytest.mark.parametrize('org_type, branding_id, expected_options', [ ('federal', None, [ - ('govuk_and_org', 'GOV.UK and Test Organisation'), - ('organisation', 'Test Organisation'), + ('govuk_and_org', 'GOV.UK and Test Organization'), + ('organization', 'Test Organization'), ]), ('federal', 'some-branding-id', [ ('govuk', 'GOV.UK'), # central orgs can switch back to gsa.gov - ('govuk_and_org', 'GOV.UK and Test Organisation'), - ('organisation', 'Test Organisation'), + ('govuk_and_org', 'GOV.UK and Test Organization'), + ('organization', 'Test Organization'), ]), ('state', None, [ - ('organisation', 'Test Organisation') + ('organization', 'Test Organization') ]), ('state', 'some-branding-id', [ - ('organisation', 'Test Organisation') + ('organization', 'Test Organization') ]), # ('nhs_central', None, [ # ('nhs', 'NHS') @@ -56,14 +56,14 @@ def test_get_email_choices_service_assigned_to_org( org_type, branding_id, expected_options, - mock_get_service_organisation, + mock_get_service_organization, mock_get_email_branding ): service = Service(service_one) mocker.patch( - 'app.organisations_client.get_organisation', - return_value=organisation_json(organisation_type=org_type) + 'app.organizations_client.get_organization', + return_value=organization_json(organization_type=org_type) ) mocker.patch( 'app.models.service.Service.email_branding_id', @@ -78,7 +78,7 @@ def test_get_email_choices_service_assigned_to_org( @pytest.mark.parametrize('org_type, branding_id, expected_options', [ ('federal', 'some-branding-id', [ # don't show gsa.gov options as org default supersedes it - ('organisation', 'Test Organisation'), + ('organization', 'Test Organization'), ]), ('federal', 'org-branding-id', [ # also don't show org option if it's the current branding @@ -94,15 +94,15 @@ def test_get_email_choices_org_has_default_branding( org_type, branding_id, expected_options, - mock_get_service_organisation, + mock_get_service_organization, mock_get_email_branding ): service = Service(service_one) mocker.patch( - 'app.organisations_client.get_organisation', - return_value=organisation_json( - organisation_type=org_type, + 'app.organizations_client.get_organization', + return_value=organization_json( + organization_type=org_type, email_branding_id='org-branding-id' ) ) @@ -119,12 +119,12 @@ def test_get_email_choices_org_has_default_branding( @pytest.mark.parametrize('branding_name, expected_options', [ ('gsa.gov and something else', [ ('govuk', 'GOV.UK'), - ('govuk_and_org', 'GOV.UK and Test Organisation'), - ('organisation', 'Test Organisation'), + ('govuk_and_org', 'GOV.UK and Test Organization'), + ('organization', 'Test Organization'), ]), ('gsa.gov and test OrganisatioN', [ ('govuk', 'GOV.UK'), - ('organisation', 'Test Organisation'), + ('organization', 'Test Organization'), ]) ]) @pytest.mark.skip(reason='Update for TTS') @@ -133,13 +133,13 @@ def test_get_email_choices_branding_name_in_use( service_one, branding_name, expected_options, - mock_get_service_organisation, + mock_get_service_organization, ): service = Service(service_one) mocker.patch( - 'app.organisations_client.get_organisation', - return_value=organisation_json(organisation_type='central') + 'app.organizations_client.get_organization', + return_value=organization_json(organization_type='central') ) mocker.patch( 'app.models.service.Service.email_branding_id', diff --git a/tests/app/utils/test_user.py b/tests/app/utils/test_user.py index ed4d9c1ae..b79e89e9d 100644 --- a/tests/app/utils/test_user.py +++ b/tests/app/utils/test_user.py @@ -96,11 +96,11 @@ def test_no_user_returns_redirect_to_sign_in( assert response.location.startswith('/sign-in?next=') -def test_user_has_permissions_for_organisation( +def test_user_has_permissions_for_organization( client_request, api_user_active, ): - api_user_active['organisations'] = ['org_1', 'org_2'] + api_user_active['organizations'] = ['org_1', 'org_2'] client_request.login(api_user_active) request.view_args = {'org_id': 'org_2'} @@ -116,7 +116,7 @@ def test_platform_admin_can_see_orgs_they_dont_have( client_request, platform_admin_user, ): - platform_admin_user['organisations'] = [] + platform_admin_user['organizations'] = [] client_request.login(platform_admin_user) request.view_args = {'org_id': 'org_2'} @@ -144,11 +144,11 @@ def test_cant_use_decorator_without_view_args( index() -def test_user_doesnt_have_permissions_for_organisation( +def test_user_doesnt_have_permissions_for_organization( client_request, api_user_active, ): - api_user_active['organisations'] = ['org_1', 'org_2'] + api_user_active['organizations'] = ['org_1', 'org_2'] client_request.login(api_user_active) request.view_args = {'org_id': 'org_3'} diff --git a/tests/conftest.py b/tests/conftest.py index e3ac46ca2..79aa06b8c 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -24,7 +24,7 @@ from . import ( job_json, notification_json, org_invite_json, - organisation_json, + organization_json, sample_uuid, service_json, template_json, @@ -448,7 +448,7 @@ def mock_get_live_service(mocker, api_user_active): def mock_create_service(mocker): def _create( service_name, - organisation_type, + organization_type, message_limit, restricted, user_id, @@ -961,7 +961,7 @@ def active_user_with_permission_to_two_services(fake_uuid): SERVICE_ONE_ID: permissions, SERVICE_TWO_ID: permissions, }, - organisations=[ORGANISATION_ID], + organizations=[ORGANISATION_ID], services=[SERVICE_ONE_ID, SERVICE_TWO_ID], ) @@ -2048,8 +2048,8 @@ def mock_no_email_branding(mocker): def create_email_branding(id, non_standard_values=None): branding = { 'logo': 'example.png', - 'name': 'Organisation name', - 'text': 'Organisation text', + 'name': 'Organization name', + 'text': 'Organization text', 'id': id, 'colour': '#f00', 'brand_type': 'org', @@ -2585,35 +2585,35 @@ def mock_update_service_callback_api(mocker): @pytest.fixture(scope='function') -def organisation_one(api_user_active): - return organisation_json(ORGANISATION_ID, 'organisation one', [api_user_active['id']]) +def organization_one(api_user_active): + return organization_json(ORGANISATION_ID, 'organization one', [api_user_active['id']]) @pytest.fixture(scope='function') -def mock_get_organisations(mocker): - def _get_organisations(): +def mock_get_organizations(mocker): + def _get_organizations(): return [ - organisation_json('7aa5d4e9-4385-4488-a489-07812ba13383', 'Org 1'), - organisation_json('7aa5d4e9-4385-4488-a489-07812ba13384', 'Org 2'), - organisation_json('7aa5d4e9-4385-4488-a489-07812ba13385', 'Org 3'), + organization_json('7aa5d4e9-4385-4488-a489-07812ba13383', 'Org 1'), + organization_json('7aa5d4e9-4385-4488-a489-07812ba13384', 'Org 2'), + organization_json('7aa5d4e9-4385-4488-a489-07812ba13385', 'Org 3'), ] mocker.patch( - 'app.models.organisation.AllOrganisations.client_method', - side_effect=_get_organisations, + 'app.models.organization.AllOrganizations.client_method', + side_effect=_get_organizations, ) return mocker.patch( - 'app.notify_client.organisations_api_client.organisations_client.get_organisations', - side_effect=_get_organisations, + 'app.notify_client.organizations_api_client.organizations_client.get_organizations', + side_effect=_get_organizations, ) @pytest.fixture(scope='function') -def mock_get_organisations_with_unusual_domains(mocker): - def _get_organisations(): +def mock_get_organizations_with_unusual_domains(mocker): + def _get_organizations(): return [ - organisation_json('7aa5d4e9-4385-4488-a489-07812ba13383', 'Org 1', domains=[ + organization_json('7aa5d4e9-4385-4488-a489-07812ba13383', 'Org 1', domains=[ 'ldquo.net', 'rdquo.net', 'lsquo.net', @@ -2621,74 +2621,74 @@ def mock_get_organisations_with_unusual_domains(mocker): ]), ] - return mocker.patch('app.organisations_client.get_organisations', side_effect=_get_organisations) + return mocker.patch('app.organizations_client.get_organizations', side_effect=_get_organizations) @pytest.fixture(scope='function') -def mock_get_organisation(mocker): - def _get_organisation(org_id): - return organisation_json( +def mock_get_organization(mocker): + def _get_organization(org_id): + return organization_json( org_id, { 'o1': 'Org 1', 'o2': 'Org 2', 'o3': 'Org 3', - }.get(org_id, 'Test organisation'), + }.get(org_id, 'Test organization'), ) - return mocker.patch('app.organisations_client.get_organisation', side_effect=_get_organisation) + return mocker.patch('app.organizations_client.get_organization', side_effect=_get_organization) @pytest.fixture(scope='function') -def mock_get_organisation_by_domain(mocker): - def _get_organisation_by_domain(domain): - return organisation_json(ORGANISATION_ID) +def mock_get_organization_by_domain(mocker): + def _get_organization_by_domain(domain): + return organization_json(ORGANISATION_ID) return mocker.patch( - 'app.organisations_client.get_organisation_by_domain', - side_effect=_get_organisation_by_domain, + 'app.organizations_client.get_organization_by_domain', + side_effect=_get_organization_by_domain, ) @pytest.fixture(scope='function') -def mock_get_no_organisation_by_domain(mocker): +def mock_get_no_organization_by_domain(mocker): return mocker.patch( - 'app.organisations_client.get_organisation_by_domain', + 'app.organizations_client.get_organization_by_domain', return_value=None, ) @pytest.fixture(scope='function') -def mock_get_service_organisation( +def mock_get_service_organization( mocker, - mock_get_organisation, + mock_get_organization, ): return mocker.patch( - 'app.models.service.Service.organisation_id', + 'app.models.service.Service.organization_id', new_callable=PropertyMock, return_value=ORGANISATION_ID, ) @pytest.fixture(scope='function') -def mock_update_service_organisation(mocker): - def _update_service_organisation(service_id, org_id): +def mock_update_service_organization(mocker): + def _update_service_organization(service_id, org_id): return return mocker.patch( - 'app.organisations_client.update_service_organisation', - side_effect=_update_service_organisation + 'app.organizations_client.update_service_organization', + side_effect=_update_service_organization ) -def _get_organisation_services(organisation_id): - if organisation_id == 'o1': +def _get_organization_services(organization_id): + if organization_id == 'o1': return [ service_json('12345', 'service one', restricted=False), service_json('67890', 'service two'), service_json('abcde', 'service three'), ] - if organisation_id == 'o2': + if organization_id == 'o2': return [ service_json('12345', 'service one (org 2)', restricted=False), service_json('67890', 'service two (org 2)', restricted=False), @@ -2702,54 +2702,54 @@ def _get_organisation_services(organisation_id): @pytest.fixture(scope='function') -def mock_get_organisation_services(mocker, api_user_active): +def mock_get_organization_services(mocker, api_user_active): return mocker.patch( - 'app.organisations_client.get_organisation_services', - side_effect=_get_organisation_services + 'app.organizations_client.get_organization_services', + side_effect=_get_organization_services ) @pytest.fixture(scope='function') -def mock_get_users_for_organisation(mocker): - def _get_users_for_organisation(org_id): +def mock_get_users_for_organization(mocker): + def _get_users_for_organization(org_id): return [ user_json(id_='1234', name='Test User 1'), user_json(id_='5678', name='Test User 2', email_address='testt@gsa.gov'), ] return mocker.patch( - 'app.models.user.OrganisationUsers.client_method', - side_effect=_get_users_for_organisation + 'app.models.user.OrganizationUsers.client_method', + side_effect=_get_users_for_organization ) @pytest.fixture(scope='function') -def mock_get_invited_users_for_organisation(mocker, sample_org_invite): - def _get_invited_invited_users_for_organisation(org_id): +def mock_get_invited_users_for_organization(mocker, sample_org_invite): + def _get_invited_invited_users_for_organization(org_id): return [ sample_org_invite ] return mocker.patch( - 'app.models.user.OrganisationInvitedUsers.client_method', - side_effect=_get_invited_invited_users_for_organisation + 'app.models.user.OrganizationInvitedUsers.client_method', + side_effect=_get_invited_invited_users_for_organization ) @pytest.fixture(scope='function') -def sample_org_invite(mocker, organisation_one): +def sample_org_invite(mocker, organization_one): id_ = str(UUID(bytes=b'sample_org_invit', version=4)) - invited_by = organisation_one['users'][0] + invited_by = organization_one['users'][0] email_address = 'invited_user@test.gsa.gov' - organisation = organisation_one['id'] + organization = organization_one['id'] created_at = str(datetime.utcnow()) status = 'pending' - return org_invite_json(id_, invited_by, organisation, email_address, created_at, status) + return org_invite_json(id_, invited_by, organization, email_address, created_at, status) @pytest.fixture(scope='function') -def mock_get_invites_for_organisation(mocker, sample_org_invite): +def mock_get_invites_for_organization(mocker, sample_org_invite): def _get_org_invites(org_id): data = [] for i in range(0, 5): @@ -2758,7 +2758,7 @@ def mock_get_invites_for_organisation(mocker, sample_org_invite): data.append(invite) return data - return mocker.patch('app.models.user.OrganisationInvitedUsers.client_method', side_effect=_get_org_invites) + return mocker.patch('app.models.user.OrganizationInvitedUsers.client_method', side_effect=_get_org_invites) @pytest.fixture(scope='function') @@ -2790,56 +2790,56 @@ def mock_check_org_accepted_invite_token(mocker, sample_org_invite): @pytest.fixture(scope='function') def mock_accept_org_invite(mocker, sample_org_invite): - def _accept(organisation_id, invite_id): + def _accept(organization_id, invite_id): return sample_org_invite return mocker.patch('app.org_invite_api_client.accept_invite', side_effect=_accept) @pytest.fixture(scope='function') -def mock_add_user_to_organisation(mocker, organisation_one, api_user_active): - def _add_user(organisation_id, user_id): +def mock_add_user_to_organization(mocker, organization_one, api_user_active): + def _add_user(organization_id, user_id): return api_user_active - return mocker.patch('app.user_api_client.add_user_to_organisation', side_effect=_add_user) + return mocker.patch('app.user_api_client.add_user_to_organization', side_effect=_add_user) @pytest.fixture(scope='function') -def mock_update_organisation(mocker): +def mock_update_organization(mocker): def _update_org(org, **kwargs): return - return mocker.patch('app.organisations_client.update_organisation', side_effect=_update_org) + return mocker.patch('app.organizations_client.update_organization', side_effect=_update_org) @pytest.fixture -def mock_get_organisations_and_services_for_user(mocker, organisation_one, api_user_active): +def mock_get_organizations_and_services_for_user(mocker, organization_one, api_user_active): def _get_orgs_and_services(user_id): return { - 'organisations': [], + 'organizations': [], 'services': [] } return mocker.patch( - 'app.user_api_client.get_organisations_and_services_for_user', + 'app.user_api_client.get_organizations_and_services_for_user', side_effect=_get_orgs_and_services ) @pytest.fixture -def mock_get_non_empty_organisations_and_services_for_user(mocker, organisation_one, api_user_active): +def mock_get_non_empty_organizations_and_services_for_user(mocker, organization_one, api_user_active): def _make_services(name, trial_mode=False): return [{ 'name': '{} {}'.format(name, i), 'id': SERVICE_TWO_ID, 'restricted': trial_mode, - 'organisation': None, + 'organization': None, } for i in range(1, 3)] def _get_orgs_and_services(user_id): return { - 'organisations': [ + 'organizations': [ { 'name': 'Org 1', 'id': 'o1', @@ -2857,47 +2857,47 @@ def mock_get_non_empty_organisations_and_services_for_user(mocker, organisation_ }, ], 'services': ( - _get_organisation_services('o1') - + _get_organisation_services('o2') + _get_organization_services('o1') + + _get_organization_services('o2') + _make_services('Service') ) } return mocker.patch( - 'app.user_api_client.get_organisations_and_services_for_user', + 'app.user_api_client.get_organizations_and_services_for_user', side_effect=_get_orgs_and_services ) @pytest.fixture -def mock_get_just_services_for_user(mocker, organisation_one, api_user_active): +def mock_get_just_services_for_user(mocker, organization_one, api_user_active): def _make_services(name, trial_mode=False): return [{ 'name': '{} {}'.format(name, i + 1), 'id': id, 'restricted': trial_mode, - 'organisation': None, + 'organization': None, } for i, id in enumerate([SERVICE_TWO_ID, SERVICE_ONE_ID])] def _get_orgs_and_services(user_id): return { - 'organisations': [], + 'organizations': [], 'services': _make_services('Service'), } return mocker.patch( - 'app.user_api_client.get_organisations_and_services_for_user', + 'app.user_api_client.get_organizations_and_services_for_user', side_effect=_get_orgs_and_services ) @pytest.fixture -def mock_get_empty_organisations_and_one_service_for_user(mocker, organisation_one, api_user_active): +def mock_get_empty_organizations_and_one_service_for_user(mocker, organization_one, api_user_active): def _get_orgs_and_services(user_id): return { - 'organisations': [], + 'organizations': [], 'services': [{ 'name': 'Only service', 'id': SERVICE_TWO_ID, @@ -2906,7 +2906,7 @@ def mock_get_empty_organisations_and_one_service_for_user(mocker, organisation_o } return mocker.patch( - 'app.user_api_client.get_organisations_and_services_for_user', + 'app.user_api_client.get_organizations_and_services_for_user', side_effect=_get_orgs_and_services ) @@ -2943,9 +2943,9 @@ def mock_create_template_folder(mocker): @pytest.fixture(scope='function') -def mock_get_service_and_organisation_counts(mocker): - return mocker.patch('app.status_api_client.get_count_of_live_services_and_organisations', return_value={ - 'organisations': 111, +def mock_get_service_and_organization_counts(mocker): + return mocker.patch('app.status_api_client.get_count_of_live_services_and_organizations', return_value={ + 'organizations': 111, 'services': 9999, }) @@ -3108,7 +3108,7 @@ def create_service_one_admin(**overrides): def create_service_one_user(**overrides): user_data = { - 'organisations': [ORGANISATION_ID], + 'organizations': [ORGANISATION_ID], 'services': [SERVICE_ONE_ID], } user_data.update(overrides) @@ -3128,7 +3128,7 @@ def create_user(**overrides): 'auth_type': 'sms_auth', 'password_changed_at': str(datetime.utcnow()), 'services': [], - 'organisations': [], + 'organizations': [], 'current_session_id': None, 'logged_in_at': None, 'email_access_validated_at': None,