diff --git a/app/main/__init__.py b/app/main/__init__.py
index 4ec54c1e2..a255c4600 100644
--- a/app/main/__init__.py
+++ b/app/main/__init__.py
@@ -20,7 +20,7 @@ from app.main.views import ( # noqa
new_password,
styleguide,
user_profile,
- choose_service,
+ choose_account,
api_keys,
manage_users,
invites,
diff --git a/app/main/views/choose_service.py b/app/main/views/choose_account.py
similarity index 86%
rename from app/main/views/choose_service.py
rename to app/main/views/choose_account.py
index 187d6aac0..80fb4d143 100644
--- a/app/main/views/choose_service.py
+++ b/app/main/views/choose_account.py
@@ -6,21 +6,21 @@ from app.main import main
from app.utils import is_gov_user
-@main.route("/services")
+@main.route("/accounts")
@login_required
-def choose_service():
+def choose_account():
orgs_and_services = user_api_client.get_organisations_and_services_for_user(current_user)
return render_template(
- 'views/choose-service.html',
+ 'views/choose-account.html',
organisations=orgs_and_services['organisations'],
services_without_organisations=orgs_and_services['services_without_organisations'],
can_add_service=is_gov_user(current_user.email_address)
)
-@main.route("/services-or-dashboard")
-def show_all_services_or_dashboard():
+@main.route("/accounts-or-dashboard")
+def show_accounts_or_dashboard():
if not current_user.is_authenticated:
return redirect(url_for('.index'))
@@ -39,4 +39,4 @@ def show_all_services_or_dashboard():
if len(current_user.organisations) == 1 and not current_user.services:
return redirect(url_for('.organisation_dashboard', org_id=current_user.organisations[0]))
- return redirect(url_for('.choose_service'))
+ return redirect(url_for('.choose_account'))
diff --git a/app/main/views/index.py b/app/main/views/index.py
index 56bdfe03f..1ac631a8d 100644
--- a/app/main/views/index.py
+++ b/app/main/views/index.py
@@ -14,7 +14,7 @@ from app.main.views.sub_navigation_dictionaries import features_nav
@main.route('/')
def index():
if current_user and current_user.is_authenticated:
- return redirect(url_for('main.choose_service'))
+ return redirect(url_for('main.choose_account'))
return render_template('views/signedout.html')
diff --git a/app/main/views/register.py b/app/main/views/register.py
index f7e19ad06..247f916ec 100644
--- a/app/main/views/register.py
+++ b/app/main/views/register.py
@@ -16,7 +16,7 @@ from app.main.views.verify import activate_user
@main.route('/register', methods=['GET', 'POST'])
def register():
if current_user and current_user.is_authenticated:
- return redirect(url_for('main.choose_service'))
+ return redirect(url_for('main.choose_account'))
form = RegisterUserForm()
if form.validate_on_submit():
@@ -101,5 +101,5 @@ def _do_registration(form, send_sms=True, send_email=True, organisation_id=None)
@main.route('/registration-continue')
def registration_continue():
if not session.get('user_details'):
- return redirect(url_for('.show_all_services_or_dashboard'))
+ return redirect(url_for('.show_accounts_or_dashboard'))
return render_template('views/registration-continue.html')
diff --git a/app/main/views/sign_in.py b/app/main/views/sign_in.py
index e714cbcc7..8805b8512 100644
--- a/app/main/views/sign_in.py
+++ b/app/main/views/sign_in.py
@@ -18,7 +18,7 @@ from app.main.forms import LoginForm
@main.route('/sign-in', methods=(['GET', 'POST']))
def sign_in():
if current_user and current_user.is_authenticated:
- return redirect(url_for('main.choose_service'))
+ return redirect(url_for('main.choose_account'))
form = LoginForm()
diff --git a/app/main/views/two_factor.py b/app/main/views/two_factor.py
index c3346eea9..cf2dab0c2 100644
--- a/app/main/views/two_factor.py
+++ b/app/main/views/two_factor.py
@@ -117,4 +117,4 @@ def redirect_when_logged_in(user_id):
if len(services) == 1:
return redirect(url_for('main.service_dashboard', service_id=services[0]['id']))
else:
- return redirect(url_for('main.choose_service'))
+ return redirect(url_for('main.choose_account'))
diff --git a/app/templates/admin_template.html b/app/templates/admin_template.html
index 29323efe6..6595057e7 100644
--- a/app/templates/admin_template.html
+++ b/app/templates/admin_template.html
@@ -63,7 +63,7 @@
{% set global_header_text = "GOV.UK Notify"|safe %}
-{% set homepage_url = url_for('main.show_all_services_or_dashboard') %}
+{% set homepage_url = url_for('main.show_accounts_or_dashboard') %}
{% block content %}
{% block fullwidth_content %}{% endblock %}
diff --git a/app/templates/org_template.html b/app/templates/org_template.html
index 62f68cd71..ba4811367 100644
--- a/app/templates/org_template.html
+++ b/app/templates/org_template.html
@@ -10,7 +10,7 @@
{{ current_org.name }}
- Switch service
+ Switch service
diff --git a/app/templates/views/choose-service.html b/app/templates/views/choose-account.html
similarity index 97%
rename from app/templates/views/choose-service.html
rename to app/templates/views/choose-account.html
index d1864c590..6fd63733e 100644
--- a/app/templates/views/choose-service.html
+++ b/app/templates/views/choose-account.html
@@ -1,13 +1,13 @@
{% extends "withoutnav_template.html" %}
{% block per_page_title %}
- Choose service
+ Choose account
{% endblock %}
{% block maincolumn_content %}
- Choose service
+ Choose account
{% for org in organisations %}
diff --git a/app/templates/withnav_template.html b/app/templates/withnav_template.html
index f19a96e19..4f3221103 100644
--- a/app/templates/withnav_template.html
+++ b/app/templates/withnav_template.html
@@ -10,7 +10,7 @@
{{ current_service.name }}
-
Switch service
+
Switch service
{% if help %}
diff --git a/app/templates/withoutnav_template.html b/app/templates/withoutnav_template.html
index eb04dd4ea..bc55e55fc 100644
--- a/app/templates/withoutnav_template.html
+++ b/app/templates/withoutnav_template.html
@@ -4,7 +4,7 @@
{% if current_service %}
{% endif %}
diff --git a/tests/app/main/views/test_add_service.py b/tests/app/main/views/test_add_service.py
index 3ed7ac7ff..0ed602f9c 100644
--- a/tests/app/main/views/test_add_service.py
+++ b/tests/app/main/views/test_add_service.py
@@ -9,9 +9,10 @@ def test_non_gov_user_cannot_see_add_service_button(
mock_login,
mock_get_non_govuser,
api_nongov_user_active,
+ mock_get_organisations_and_services_for_user
):
client.login(api_nongov_user_active)
- response = client.get(url_for('main.choose_service'))
+ response = client.get(url_for('main.choose_account'))
assert 'Add a new service' not in response.get_data(as_text=True)
assert response.status_code == 200
diff --git a/tests/app/main/views/test_choose_services.py b/tests/app/main/views/test_choose_accounts.py
similarity index 76%
rename from tests/app/main/views/test_choose_services.py
rename to tests/app/main/views/test_choose_accounts.py
index 44795d5c3..004c161eb 100644
--- a/tests/app/main/views/test_choose_services.py
+++ b/tests/app/main/views/test_choose_accounts.py
@@ -2,14 +2,14 @@ from bs4 import BeautifulSoup
from flask import url_for
-def test_should_show_choose_services_page(
+def test_should_show_choose_accounts_page(
logged_in_client,
mock_login,
mock_get_user,
api_user_active,
mock_get_services,
):
- response = logged_in_client.get(url_for('main.choose_service'))
+ response = logged_in_client.get(url_for('main.choose_account'))
assert response.status_code == 200
resp_data = response.get_data(as_text=True)
@@ -20,14 +20,14 @@ def test_should_show_choose_services_page(
assert services['data'][1]['name'] in resp_data
-def test_should_show_choose_services_page_if_no_services(
+def test_should_show_choose_accounts_page_if_no_services(
logged_in_client,
mock_login,
api_user_active,
):
# if users last service has been archived there'll be no services
# mock_login already patches get_services to return no data
- response = logged_in_client.get(url_for('main.choose_service'))
+ response = logged_in_client.get(url_for('main.choose_account'))
assert response.status_code == 200
resp_data = response.get_data(as_text=True)
assert 'Choose service' in resp_data
@@ -40,7 +40,7 @@ def test_redirect_if_only_one_service(
api_user_active,
mock_get_services_with_one_service,
):
- response = logged_in_client.get(url_for('main.show_all_services_or_dashboard'))
+ response = logged_in_client.get(url_for('main.show_accounts_or_dashboard'))
service = mock_get_services_with_one_service.side_effect()['data'][0]
assert response.status_code == 302
@@ -52,10 +52,10 @@ def test_redirect_if_multiple_services(
mock_login,
api_user_active,
):
- response = logged_in_client.get(url_for('main.show_all_services_or_dashboard'))
+ response = logged_in_client.get(url_for('main.show_accounts_or_dashboard'))
assert response.status_code == 302
- assert response.location == url_for('main.choose_service', _external=True)
+ assert response.location == url_for('main.choose_account', _external=True)
def test_redirect_if_service_in_session(
@@ -67,7 +67,7 @@ def test_redirect_if_service_in_session(
):
with logged_in_client.session_transaction() as session:
session['service_id'] = '147ad62a-2951-4fa1-9ca0-093cd1a52c52'
- response = logged_in_client.get(url_for('main.show_all_services_or_dashboard'))
+ response = logged_in_client.get(url_for('main.show_accounts_or_dashboard'))
assert response.status_code == 302
assert response.location == url_for(
@@ -81,7 +81,7 @@ def test_should_redirect_if_not_logged_in(
logged_in_client,
app_
):
- response = logged_in_client.get(url_for('main.show_all_services_or_dashboard'))
+ response = logged_in_client.get(url_for('main.show_accounts_or_dashboard'))
assert response.status_code == 302
assert url_for('main.index', _external=True) in response.location
@@ -89,12 +89,12 @@ def test_should_redirect_if_not_logged_in(
def test_should_show_back_to_service_link(
logged_in_client
):
- response = logged_in_client.get(url_for('main.choose_service'))
+ response = logged_in_client.get(url_for('main.choose_account'))
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
assert page.select('.navigation-service a')[0]['href'] == (
- url_for('main.show_all_services_or_dashboard')
+ url_for('main.show_accounts_or_dashboard')
)
@@ -105,7 +105,7 @@ def test_should_not_show_back_to_service_link_if_no_service_in_session(
mock_get_services_with_no_services,
):
client.login(api_user_active)
- response = client.get(url_for('main.choose_service'))
+ response = client.get(url_for('main.choose_account'))
assert response.status_code == 200
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py
index 0c5b05ff6..eb08b0314 100644
--- a/tests/app/main/views/test_index.py
+++ b/tests/app/main/views/test_index.py
@@ -22,7 +22,7 @@ def test_non_logged_in_user_can_see_homepage(
)
-def test_logged_in_user_redirects_to_choose_service(
+def test_logged_in_user_redirects_to_choose_account(
logged_in_client,
api_user_active,
mock_get_user,
@@ -33,7 +33,7 @@ def test_logged_in_user_redirects_to_choose_service(
assert response.status_code == 302
response = logged_in_client.get(url_for('main.sign_in', follow_redirects=True))
- assert response.location == url_for('main.choose_service', _external=True)
+ assert response.location == url_for('main.choose_account', _external=True)
@pytest.mark.parametrize('view', [
diff --git a/tests/app/main/views/test_new_password.py b/tests/app/main/views/test_new_password.py
index 732ae86b6..93b5a425f 100644
--- a/tests/app/main/views/test_new_password.py
+++ b/tests/app/main/views/test_new_password.py
@@ -100,7 +100,7 @@ def test_should_sign_in_when_password_reset_is_successful_for_email_auth(
response = client.post(url_for('.new_password', token=token), data={'new_password': 'a-new_password'})
assert response.status_code == 302
- assert response.location == url_for('.choose_service', _external=True)
+ assert response.location == url_for('.choose_account', _external=True)
assert mock_get_user_by_email_request_password_reset.called
assert mock_reset_failed_login_count.called
diff --git a/tests/app/main/views/test_register.py b/tests/app/main/views/test_register.py
index 5757b8175..3a861c4ed 100644
--- a/tests/app/main/views/test_register.py
+++ b/tests/app/main/views/test_register.py
@@ -18,7 +18,7 @@ def test_render_register_returns_template_with_form(client):
assert 'Create an account' in response.get_data(as_text=True)
-def test_logged_in_user_redirects_to_choose_service(
+def test_logged_in_user_redirects_to_choose_account(
logged_in_client,
api_user_active,
mock_get_user_by_email,
@@ -29,7 +29,7 @@ def test_logged_in_user_redirects_to_choose_service(
assert response.status_code == 302
response = logged_in_client.get(url_for('main.sign_in', follow_redirects=True))
- assert response.location == url_for('main.choose_service', _external=True)
+ assert response.location == url_for('main.choose_account', _external=True)
@pytest.mark.parametrize('phone_number_to_register_with', [
@@ -78,7 +78,7 @@ def test_register_continue_handles_missing_session_sensibly(
# session is not set
response = client.get(url_for('main.registration_continue'))
assert response.status_code == 302
- assert response.location == url_for('main.show_all_services_or_dashboard', _external=True)
+ assert response.location == url_for('main.show_accounts_or_dashboard', _external=True)
def test_process_register_returns_200_when_mobile_number_is_invalid(
diff --git a/tests/app/main/views/test_sign_in.py b/tests/app/main/views/test_sign_in.py
index c35a1807a..bcfaf98a4 100644
--- a/tests/app/main/views/test_sign_in.py
+++ b/tests/app/main/views/test_sign_in.py
@@ -38,12 +38,15 @@ def test_sign_in_explains_other_browser(logged_in_client, api_user_active, mocke
assert 'We signed you out because you logged in to Notify on another device' in response.get_data(as_text=True)
-def test_doesnt_redirect_to_sign_in_if_no_session_info(logged_in_client, api_user_active):
+def test_doesnt_redirect_to_sign_in_if_no_session_info(
+ logged_in_client, api_user_active
+):
assert api_user_active.current_session_id is None
+
with logged_in_client.session_transaction() as session:
session['current_session_id'] = None
- response = logged_in_client.get(url_for('main.choose_service'))
+ response = logged_in_client.get(url_for('main.add_service'))
assert response.status_code == 200
@@ -65,16 +68,16 @@ def test_redirect_to_sign_in_if_logged_in_from_other_browser(
with logged_in_client.session_transaction() as session:
session['current_session_id'] = str(cookie_sess_id)
- response = logged_in_client.get(url_for('main.choose_service'))
+ response = logged_in_client.get(url_for('main.choose_account'))
assert response.status_code == 302
- assert response.location == url_for('main.sign_in', next='/services', _external=True)
+ assert response.location == url_for('main.sign_in', next='/accounts', _external=True)
-def test_logged_in_user_redirects_to_choose_service(
+def test_logged_in_user_redirects_to_choose_account(
logged_in_client
):
response = logged_in_client.get(url_for('main.sign_in'))
- assert response.location == url_for('main.choose_service', _external=True)
+ assert response.location == url_for('main.choose_account', _external=True)
@pytest.mark.parametrize('email_address, password', [
diff --git a/tests/app/main/views/test_two_factor.py b/tests/app/main/views/test_two_factor.py
index 3b28e5849..747dff750 100644
--- a/tests/app/main/views/test_two_factor.py
+++ b/tests/app/main/views/test_two_factor.py
@@ -90,7 +90,7 @@ def test_should_login_user_and_not_redirect_to_external_url(
)
-def test_should_login_user_and_redirect_to_choose_services(
+def test_should_login_user_and_redirect_to_choose_accounts(
client,
api_user_active,
mock_get_user,
@@ -106,7 +106,7 @@ def test_should_login_user_and_redirect_to_choose_services(
data={'sms_code': '12345'})
assert response.status_code == 302
- assert response.location == url_for('main.choose_service', _external=True)
+ assert response.location == url_for('main.choose_account', _external=True)
def test_should_return_200_with_sms_code_error_when_sms_code_is_wrong(
@@ -321,4 +321,4 @@ def test_two_factor_email_link_used_when_user_already_logged_in(
url_for('main.two_factor_email', token=valid_token)
)
assert response.status_code == 302
- assert response.location == url_for('main.choose_service', _external=True)
+ assert response.location == url_for('main.choose_account', _external=True)
diff --git a/tests/conftest.py b/tests/conftest.py
index ca7627b96..a70a7ce19 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -2867,3 +2867,17 @@ def mock_update_organisation_name(mocker):
return
return mocker.patch('app.organisations_client.update_organisation_name', side_effect=_update_org_name)
+
+
+@pytest.fixture
+def mock_get_organisations_and_services_for_user(mocker, organisation_one, api_user_active):
+ def _get_orgs_and_services(user_id):
+ return {
+ 'organisations': [],
+ 'services_without_organisations': []
+ }
+
+ return mocker.patch(
+ 'app.user_api_client.get_organisations_and_services_for_user',
+ side_effect=_get_orgs_and_services
+ )