mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-07 06:28:24 -04:00
Merge pull request #3054 from alphagov/remove-old-agreement-pages
Remove the user-specific agreement pages
This commit is contained in:
@@ -9,7 +9,6 @@ from freezegun import freeze_time
|
||||
from tests import organisation_json
|
||||
from tests.conftest import (
|
||||
SERVICE_ONE_ID,
|
||||
mock_get_organisation_by_domain,
|
||||
mock_get_service_organisation,
|
||||
normalize_spaces,
|
||||
)
|
||||
@@ -24,49 +23,65 @@ class _MockS3Object():
|
||||
return {'Body': BytesIO(self.data)}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('endpoint, extra_args, organisation_mock, link_selector, expected_back_links', [
|
||||
(
|
||||
'main.agreement',
|
||||
{},
|
||||
mock_get_organisation_by_domain,
|
||||
'main .column-two-thirds a',
|
||||
[]
|
||||
),
|
||||
(
|
||||
'main.service_agreement',
|
||||
{'service_id': SERVICE_ONE_ID},
|
||||
mock_get_service_organisation,
|
||||
'main .column-five-sixths a',
|
||||
[
|
||||
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID)
|
||||
]
|
||||
),
|
||||
])
|
||||
@pytest.mark.parametrize('agreement_signed, crown, expected_links', [
|
||||
(
|
||||
True, True,
|
||||
[
|
||||
partial(url_for, 'main.service_download_agreement', service_id=SERVICE_ONE_ID),
|
||||
(
|
||||
['govuk-back-link'],
|
||||
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
|
||||
),
|
||||
(
|
||||
[],
|
||||
partial(url_for, 'main.service_download_agreement', service_id=SERVICE_ONE_ID),
|
||||
),
|
||||
]
|
||||
),
|
||||
(
|
||||
False, False,
|
||||
[
|
||||
partial(url_for, 'main.service_download_agreement', service_id=SERVICE_ONE_ID),
|
||||
partial(url_for, 'main.service_accept_agreement', service_id=SERVICE_ONE_ID),
|
||||
(
|
||||
['govuk-back-link'],
|
||||
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
|
||||
),
|
||||
(
|
||||
[],
|
||||
partial(url_for, 'main.service_download_agreement', service_id=SERVICE_ONE_ID),
|
||||
),
|
||||
(
|
||||
['button'],
|
||||
partial(url_for, 'main.service_accept_agreement', service_id=SERVICE_ONE_ID),
|
||||
),
|
||||
]
|
||||
),
|
||||
(
|
||||
False, True,
|
||||
[
|
||||
partial(url_for, 'main.service_download_agreement', service_id=SERVICE_ONE_ID),
|
||||
partial(url_for, 'main.service_accept_agreement', service_id=SERVICE_ONE_ID),
|
||||
(
|
||||
['govuk-back-link'],
|
||||
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
|
||||
),
|
||||
(
|
||||
[],
|
||||
partial(url_for, 'main.service_download_agreement', service_id=SERVICE_ONE_ID),
|
||||
),
|
||||
(
|
||||
['button'],
|
||||
partial(url_for, 'main.service_accept_agreement', service_id=SERVICE_ONE_ID),
|
||||
),
|
||||
]
|
||||
),
|
||||
(
|
||||
None, None,
|
||||
[
|
||||
partial(url_for, 'main.support'),
|
||||
(
|
||||
['govuk-back-link'],
|
||||
partial(url_for, 'main.request_to_go_live', service_id=SERVICE_ONE_ID),
|
||||
),
|
||||
(
|
||||
[],
|
||||
partial(url_for, 'main.support'),
|
||||
),
|
||||
]
|
||||
),
|
||||
])
|
||||
@@ -75,27 +90,22 @@ def test_show_agreement_page(
|
||||
mocker,
|
||||
fake_uuid,
|
||||
mock_has_jobs,
|
||||
mock_get_service_organisation,
|
||||
agreement_signed,
|
||||
crown,
|
||||
expected_links,
|
||||
endpoint,
|
||||
extra_args,
|
||||
organisation_mock,
|
||||
link_selector,
|
||||
expected_back_links,
|
||||
):
|
||||
organisation_mock(
|
||||
mock_get_service_organisation(
|
||||
mocker,
|
||||
crown=crown,
|
||||
agreement_signed=agreement_signed,
|
||||
)
|
||||
expected_links = expected_back_links + expected_links
|
||||
page = client_request.get(endpoint, **extra_args)
|
||||
links = page.select(link_selector)
|
||||
page = client_request.get('main.service_agreement', service_id=SERVICE_ONE_ID)
|
||||
links = page.select('main .column-five-sixths a')
|
||||
assert len(links) == len(expected_links)
|
||||
for index, link in enumerate(links):
|
||||
assert link['href'] == expected_links[index]()
|
||||
classes, url = expected_links[index]
|
||||
assert link.get('class', []) == classes
|
||||
assert link['href'] == url()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('crown, expected_status, expected_file_fetched, expected_file_served', (
|
||||
@@ -448,76 +458,6 @@ def test_confirm_agreement_page_persists(
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('crown, expected_file_fetched, expected_file_served', [
|
||||
(
|
||||
True,
|
||||
'crown.pdf',
|
||||
'GOV.UK Notify data sharing and financial agreement.pdf',
|
||||
),
|
||||
(
|
||||
False,
|
||||
'non-crown.pdf',
|
||||
'GOV.UK Notify data sharing and financial agreement (non-crown).pdf',
|
||||
),
|
||||
])
|
||||
def test_downloading_agreement(
|
||||
logged_in_client,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
crown,
|
||||
expected_file_fetched,
|
||||
expected_file_served,
|
||||
):
|
||||
mock_get_s3_object = mocker.patch(
|
||||
'app.s3_client.s3_mou_client.get_s3_object',
|
||||
return_value=_MockS3Object(b'foo')
|
||||
)
|
||||
mock_get_organisation_by_domain(
|
||||
mocker,
|
||||
crown=crown,
|
||||
)
|
||||
response = logged_in_client.get(url_for('main.download_agreement'))
|
||||
assert response.status_code == 200
|
||||
assert response.get_data() == b'foo'
|
||||
assert response.headers['Content-Type'] == 'application/pdf'
|
||||
assert response.headers['Content-Disposition'] == (
|
||||
'attachment; filename="{}"'.format(expected_file_served)
|
||||
)
|
||||
mock_get_s3_object.assert_called_once_with('test-mou', expected_file_fetched)
|
||||
|
||||
|
||||
def test_agreement_cant_be_downloaded_unknown_crown_status(
|
||||
logged_in_client,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
):
|
||||
mock_get_s3_object = mocker.patch(
|
||||
'app.s3_client.s3_mou_client.get_s3_object',
|
||||
return_value=_MockS3Object()
|
||||
)
|
||||
mock_get_organisation_by_domain(
|
||||
mocker,
|
||||
crown=None,
|
||||
)
|
||||
response = logged_in_client.get(url_for('main.download_agreement'))
|
||||
assert response.status_code == 404
|
||||
assert mock_get_s3_object.call_args_list == []
|
||||
|
||||
|
||||
def test_agreement_requires_login(
|
||||
client,
|
||||
mocker,
|
||||
):
|
||||
mock_get_s3_object = mocker.patch(
|
||||
'app.s3_client.s3_mou_client.get_s3_object',
|
||||
return_value=_MockS3Object()
|
||||
)
|
||||
response = client.get(url_for('main.download_agreement'))
|
||||
assert response.status_code == 302
|
||||
assert response.location == 'http://localhost/sign-in?next=%2Fagreement.pdf'
|
||||
assert mock_get_s3_object.call_args_list == []
|
||||
|
||||
|
||||
@pytest.mark.parametrize('endpoint', (
|
||||
'main.public_agreement',
|
||||
'main.public_download_agreement',
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
from functools import partial
|
||||
|
||||
import pytest
|
||||
from bs4 import BeautifulSoup
|
||||
from flask import url_for
|
||||
|
||||
from app.main.forms import FieldWithNoneOption
|
||||
from tests.conftest import (
|
||||
mock_get_organisation_by_domain,
|
||||
normalize_spaces,
|
||||
sample_uuid,
|
||||
)
|
||||
from tests.conftest import normalize_spaces, sample_uuid
|
||||
|
||||
|
||||
def test_non_logged_in_user_can_see_homepage(
|
||||
@@ -144,96 +138,12 @@ def test_old_integration_testing_page(
|
||||
)
|
||||
|
||||
|
||||
def test_terms_is_generic_if_user_is_not_logged_in(
|
||||
client
|
||||
):
|
||||
response = client.get(url_for('main.terms'))
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
|
||||
assert normalize_spaces(page.select('main p')[1].text) == (
|
||||
'Your organisation must also accept our data sharing and '
|
||||
'financial agreement. Sign in to download a copy or find out '
|
||||
'if one is already in place.'
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize((
|
||||
'name,'
|
||||
'agreement_signed,'
|
||||
'expected_terms_paragraph,'
|
||||
'expected_terms_link,'
|
||||
), [
|
||||
(
|
||||
'Cabinet Office',
|
||||
True,
|
||||
(
|
||||
'Your organisation (Cabinet Office) has already accepted '
|
||||
'the GOV.UK Notify data sharing and financial agreement.'
|
||||
),
|
||||
None,
|
||||
),
|
||||
(
|
||||
'Aylesbury Town Council',
|
||||
False,
|
||||
(
|
||||
'Your organisation (Aylesbury Town Council) must also '
|
||||
'accept our data sharing and financial agreement. Download '
|
||||
'a copy.'
|
||||
),
|
||||
partial(
|
||||
url_for,
|
||||
'main.agreement',
|
||||
),
|
||||
),
|
||||
(
|
||||
None,
|
||||
None,
|
||||
(
|
||||
'Your organisation must also accept our data sharing and '
|
||||
'financial agreement. Download the agreement or contact us '
|
||||
'to find out if we already have one in place with your '
|
||||
'organisation.'
|
||||
),
|
||||
partial(
|
||||
url_for,
|
||||
'main.agreement',
|
||||
),
|
||||
),
|
||||
(
|
||||
'Met Office',
|
||||
False,
|
||||
(
|
||||
'Your organisation (Met Office) must also accept our data '
|
||||
'sharing and financial agreement. Download a copy.'
|
||||
),
|
||||
partial(
|
||||
url_for,
|
||||
'main.agreement',
|
||||
),
|
||||
),
|
||||
])
|
||||
def test_terms_tells_logged_in_users_what_we_know_about_their_agreement(
|
||||
mocker,
|
||||
fake_uuid,
|
||||
client_request,
|
||||
name,
|
||||
agreement_signed,
|
||||
expected_terms_paragraph,
|
||||
expected_terms_link,
|
||||
):
|
||||
mock_get_organisation_by_domain(
|
||||
mocker,
|
||||
name=name,
|
||||
agreement_signed=agreement_signed,
|
||||
)
|
||||
def test_terms_page_has_correct_content(client_request):
|
||||
terms_page = client_request.get('main.terms')
|
||||
|
||||
assert normalize_spaces(terms_page.select('main p')[1].text) == expected_terms_paragraph
|
||||
if expected_terms_link:
|
||||
assert terms_page.select_one('main p a')['href'] == expected_terms_link()
|
||||
else:
|
||||
assert not terms_page.select_one('main p').select('a')
|
||||
assert normalize_spaces(terms_page.select('main p')[0].text) == (
|
||||
'These terms apply to your service’s use of GOV.UK Notify. '
|
||||
'You must be the service manager to accept them.'
|
||||
)
|
||||
|
||||
|
||||
def test_css_is_served_from_correct_path(client_request):
|
||||
|
||||
Reference in New Issue
Block a user