mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-05 10:53:28 -05:00
Merge pull request #350 from alphagov/click-logo-redirect
Only show ‘Choose service’ if multiple services
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user