Remove dependence on domains.yml from static pages

This will allow us to remove the `domains.yml` file, by using
information about organisations that is now stored in the database
instead.
This commit is contained in:
Chris Hill-Scott
2019-04-04 11:12:53 +01:00
parent 718f440720
commit 72f49a9a1e
6 changed files with 50 additions and 20 deletions

View File

@@ -6,7 +6,7 @@ from flask import url_for
from app.main.forms import FieldWithNoneOption
from tests.conftest import (
active_user_with_permissions,
mock_get_organisation_by_domain,
normalize_spaces,
sample_uuid,
)
@@ -69,6 +69,7 @@ def test_robots(client):
])
def test_static_pages(
client_request,
mock_get_organisation_by_domain,
view,
):
page = client_request.get('main.{}'.format(view))
@@ -166,13 +167,15 @@ def test_pricing_is_generic_if_user_is_not_logged_in(
@pytest.mark.parametrize((
'email_address,'
'name,'
'agreement_signed,'
'expected_terms_paragraph,'
'expected_terms_link,'
'expected_pricing_paragraph'
), [
(
'test@cabinet-office.gov.uk',
'Cabinet Office',
True,
(
'Your organisation (Cabinet Office) has already accepted '
'the GOV.UK Notify data sharing and financial agreement.'
@@ -184,7 +187,8 @@ def test_pricing_is_generic_if_user_is_not_logged_in(
),
),
(
'test@aylesburytowncouncil.gov.uk',
'Aylesbury Town Council',
False,
(
'Your organisation (Aylesbury Town Council) must also '
'accept our data sharing and financial agreement. Download '
@@ -200,7 +204,8 @@ def test_pricing_is_generic_if_user_is_not_logged_in(
),
),
(
'larry@downing-street.gov.uk',
None,
None,
(
'Your organisation must also accept our data sharing and '
'financial agreement. Download the agreement or contact us '
@@ -217,7 +222,8 @@ def test_pricing_is_generic_if_user_is_not_logged_in(
),
),
(
'michael.fish@metoffice.gov.uk',
'Met Office',
False,
(
'Your organisation (Met Office) must also accept our data '
'sharing and financial agreement. Download a copy.'
@@ -236,14 +242,17 @@ def test_terms_tells_logged_in_users_what_we_know_about_their_agreement(
mocker,
fake_uuid,
client_request,
email_address,
name,
agreement_signed,
expected_terms_paragraph,
expected_terms_link,
expected_pricing_paragraph,
):
user = active_user_with_permissions(fake_uuid)
user.email_address = email_address
mocker.patch('app.user_api_client.get_user', return_value=user)
mock_get_organisation_by_domain(
mocker,
name=name,
agreement_signed=agreement_signed,
)
terms_page = client_request.get('main.terms')
pricing_page = client_request.get('main.pricing')
assert normalize_spaces(terms_page.select('main p')[1].text) == expected_terms_paragraph
@@ -256,7 +265,7 @@ def test_terms_tells_logged_in_users_what_we_know_about_their_agreement(
def test_css_is_served_from_correct_path(client_request):
page = client_request.get('main.pricing') # easy static page
page = client_request.get('main.documentation') # easy static page
for index, link in enumerate(
page.select('link[rel=stylesheet]')