Merge pull request #350 from alphagov/click-logo-redirect

Only show ‘Choose service’ if multiple services
This commit is contained in:
Chris Hill-Scott
2016-03-29 11:29:03 +01:00
3 changed files with 61 additions and 9 deletions

View File

@@ -23,6 +23,47 @@ def test_should_show_choose_services_page(app_,
assert 'List all services' not in resp_data
def test_redirect_if_only_one_service(
app_,
mock_login,
mock_get_user,
api_user_active,
mock_get_services_with_one_service
):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.get(url_for('main.show_all_services_or_dashboard'))
service = mock_get_services_with_one_service.side_effect()['data'][0]
assert response.status_code == 302
assert response.location == url_for('main.service_dashboard', service_id=service['id'], _external=True)
def test_redirect_if_multiple_services(
app_,
mock_login,
mock_get_user,
api_user_active,
mock_get_services
):
with app_.test_request_context():
with app_.test_client() as client:
client.login(api_user_active)
response = client.get(url_for('main.show_all_services_or_dashboard'))
assert response.status_code == 302
assert response.location == url_for('main.choose_service', _external=True)
def test_should_redirect_if_not_logged_in(app_):
with app_.test_request_context():
with app_.test_client() as client:
response = client.get(url_for('main.show_all_services_or_dashboard'))
assert response.status_code == 302
assert response.location == url_for('main.index', _external=True)
def test_should_show_all_services_for_platform_admin_user(app_,
platform_admin_user,
mock_get_services,