mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 05:29:38 -04:00
Merge pull request #2074 from alphagov/sign-in-for-agreement
Let people choose which agreement to download if signed in
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from functools import partial
|
||||
from io import BytesIO
|
||||
|
||||
import pytest
|
||||
@@ -15,25 +16,45 @@ class _MockS3Object():
|
||||
return {'Body': BytesIO(self.data)}
|
||||
|
||||
|
||||
@pytest.mark.parametrize('email_address, expected_status', [
|
||||
('test@cabinet-office.gov.uk', 200),
|
||||
('test@aylesburytowncouncil.gov.uk', 200),
|
||||
('test@unknown.gov.uk', 404),
|
||||
@pytest.mark.parametrize('email_address, expected_links', [
|
||||
(
|
||||
'test@cabinet-office.gov.uk',
|
||||
[
|
||||
partial(url_for, 'main.download_agreement'),
|
||||
]
|
||||
),
|
||||
(
|
||||
'test@aylesburytowncouncil.gov.uk',
|
||||
[
|
||||
partial(url_for, 'main.download_agreement'),
|
||||
lambda: 'mailto:notify-support@digital.cabinet-office.gov.uk',
|
||||
]
|
||||
),
|
||||
(
|
||||
'test@unknown.gov.uk',
|
||||
[
|
||||
partial(url_for, 'main.public_download_agreement', variant='crown'),
|
||||
partial(url_for, 'main.public_download_agreement', variant='non-crown'),
|
||||
partial(url_for, 'main.support'),
|
||||
lambda: 'mailto:notify-support@digital.cabinet-office.gov.uk',
|
||||
]
|
||||
),
|
||||
])
|
||||
def test_show_agreement_page(
|
||||
client_request,
|
||||
mocker,
|
||||
fake_uuid,
|
||||
email_address,
|
||||
expected_status,
|
||||
expected_links,
|
||||
):
|
||||
user = active_user_with_permissions(fake_uuid)
|
||||
user.email_address = email_address
|
||||
mocker.patch('app.user_api_client.get_user', return_value=user)
|
||||
client_request.get(
|
||||
'main.agreement',
|
||||
_expected_status=expected_status,
|
||||
)
|
||||
page = client_request.get('main.agreement')
|
||||
links = page.select('main .column-two-thirds a')
|
||||
assert len(links) == len(expected_links)
|
||||
for index, link in enumerate(links):
|
||||
assert link['href'] == expected_links[index]()
|
||||
|
||||
|
||||
@pytest.mark.parametrize('email_address, expected_file_fetched, expected_file_served', [
|
||||
|
||||
@@ -88,16 +88,8 @@ def test_get_feedback_page(client, ticket_type, expected_status_code):
|
||||
(
|
||||
'agreement',
|
||||
(
|
||||
'Please send me a copy of the GOV.UK Notify data sharing '
|
||||
'and financial agreement.'
|
||||
)
|
||||
),
|
||||
(
|
||||
'agreement-with-owner',
|
||||
(
|
||||
'Please send me a copy of the GOV.UK Notify data sharing '
|
||||
'and financial agreement for Marine Management '
|
||||
'Organisation to sign.'
|
||||
'Please can you tell me if there’s an agreement in place '
|
||||
'between GOV.UK Notify and my organisation?'
|
||||
)
|
||||
),
|
||||
(
|
||||
|
||||
@@ -101,7 +101,25 @@ def test_terms_is_generic_if_user_is_not_logged_in(
|
||||
|
||||
assert normalize_spaces(page.select('main p')[1].text) == (
|
||||
'Your organisation must also accept our data sharing and '
|
||||
'financial agreement. Contact us to get a copy.'
|
||||
'financial agreement. Sign in to download a copy or find out '
|
||||
'if one is already in place.'
|
||||
)
|
||||
|
||||
|
||||
def test_pricing_is_generic_if_user_is_not_logged_in(
|
||||
client
|
||||
):
|
||||
response = client.get(url_for('main.pricing'))
|
||||
assert response.status_code == 200
|
||||
page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser')
|
||||
last_paragraph = page.select('main p')[-1]
|
||||
assert normalize_spaces(last_paragraph.text) == (
|
||||
'Sign in to download a copy or find out if one is already '
|
||||
'in place with your organisation.'
|
||||
)
|
||||
assert last_paragraph.select_one('a')['href'] == url_for(
|
||||
'main.sign_in',
|
||||
next=url_for('main.pricing', _anchor='paying'),
|
||||
)
|
||||
|
||||
|
||||
@@ -119,7 +137,7 @@ def test_terms_is_generic_if_user_is_not_logged_in(
|
||||
),
|
||||
None,
|
||||
(
|
||||
'Contact us to get a copy of the agreement '
|
||||
'Download the agreement '
|
||||
'(Cabinet Office has already accepted it).'
|
||||
),
|
||||
),
|
||||
@@ -135,7 +153,7 @@ def test_terms_is_generic_if_user_is_not_logged_in(
|
||||
'main.agreement',
|
||||
),
|
||||
(
|
||||
'Contact us to get a copy of the agreement '
|
||||
'Download the agreement '
|
||||
'(Aylesbury Town Council hasn’t accepted it yet).'
|
||||
),
|
||||
),
|
||||
@@ -143,16 +161,16 @@ def test_terms_is_generic_if_user_is_not_logged_in(
|
||||
'larry@downing-street.gov.uk',
|
||||
(
|
||||
'Your organisation must also accept our data sharing and '
|
||||
'financial agreement. Contact us to get a copy.'
|
||||
'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.feedback',
|
||||
ticket_type='ask-question-give-feedback',
|
||||
body='agreement-with-owner',
|
||||
'main.agreement',
|
||||
),
|
||||
(
|
||||
'Contact us to get a copy of the agreement or find out if '
|
||||
'Download the agreement or contact us to find out if '
|
||||
'we already have one in place with your organisation.'
|
||||
),
|
||||
),
|
||||
@@ -167,8 +185,8 @@ def test_terms_is_generic_if_user_is_not_logged_in(
|
||||
'main.agreement',
|
||||
),
|
||||
(
|
||||
'Contact us to get a copy of the agreement (Met Office '
|
||||
'hasn’t accepted it yet).'
|
||||
'Download the agreement (Met Office hasn’t accepted it '
|
||||
'yet).'
|
||||
),
|
||||
),
|
||||
])
|
||||
|
||||
Reference in New Issue
Block a user