mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Merge pull request #1957 from alphagov/rename-gov-domain
Rename GovernmentDomain to AgreementInfo
This commit is contained in:
@@ -9,7 +9,7 @@ from app import convert_to_boolean
|
|||||||
from app.main import main
|
from app.main import main
|
||||||
from app.main.forms import SearchTemplatesForm
|
from app.main.forms import SearchTemplatesForm
|
||||||
from app.main.views.sub_navigation_dictionaries import features_nav
|
from app.main.views.sub_navigation_dictionaries import features_nav
|
||||||
from app.utils import GovernmentDomain
|
from app.utils import AgreementInfo
|
||||||
|
|
||||||
|
|
||||||
@main.route('/')
|
@main.route('/')
|
||||||
@@ -154,7 +154,7 @@ def terms():
|
|||||||
return render_template(
|
return render_template(
|
||||||
'views/terms-of-use.html',
|
'views/terms-of-use.html',
|
||||||
navigation_links=features_nav(),
|
navigation_links=features_nav(),
|
||||||
agreement_info=GovernmentDomain.from_current_user(),
|
agreement_info=AgreementInfo.from_current_user(),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ from app.main.forms import (
|
|||||||
SMSPrefixForm,
|
SMSPrefixForm,
|
||||||
)
|
)
|
||||||
from app.utils import (
|
from app.utils import (
|
||||||
GovernmentDomain,
|
AgreementInfo,
|
||||||
email_safe,
|
email_safe,
|
||||||
get_cdn_domain,
|
get_cdn_domain,
|
||||||
user_has_permissions,
|
user_has_permissions,
|
||||||
@@ -205,7 +205,7 @@ def submit_request_to_go_live(service_id):
|
|||||||
current_service['name'],
|
current_service['name'],
|
||||||
url_for('main.service_dashboard', service_id=current_service['id'], _external=True),
|
url_for('main.service_dashboard', service_id=current_service['id'], _external=True),
|
||||||
current_service['organisation_type'],
|
current_service['organisation_type'],
|
||||||
GovernmentDomain.from_current_user().as_human_readable,
|
AgreementInfo.from_current_user().as_human_readable,
|
||||||
formatted_list(filter(None, (
|
formatted_list(filter(None, (
|
||||||
'email' if form.channel_email.data else None,
|
'email' if form.channel_email.data else None,
|
||||||
'text messages' if form.channel_sms.data else None,
|
'text messages' if form.channel_sms.data else None,
|
||||||
|
|||||||
10
app/utils.py
10
app/utils.py
@@ -443,7 +443,7 @@ def set_status_filters(filter_args):
|
|||||||
_dir_path = os.path.dirname(os.path.realpath(__file__))
|
_dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
|
||||||
|
|
||||||
class GovernmentDomain:
|
class AgreementInfo:
|
||||||
|
|
||||||
with open('{}/domains.yml'.format(_dir_path)) as domains:
|
with open('{}/domains.yml'.format(_dir_path)) as domains:
|
||||||
domains = yaml.safe_load(domains)
|
domains = yaml.safe_load(domains)
|
||||||
@@ -460,7 +460,7 @@ class GovernmentDomain:
|
|||||||
self.owner,
|
self.owner,
|
||||||
self.crown_status,
|
self.crown_status,
|
||||||
self.agreement_signed
|
self.agreement_signed
|
||||||
) = self._get_details_of_domain()
|
) = self._get_info()
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_user(cls, user):
|
def from_user(cls, user):
|
||||||
@@ -507,12 +507,12 @@ class GovernmentDomain:
|
|||||||
|
|
||||||
return fn
|
return fn
|
||||||
|
|
||||||
def _get_details_of_domain(self):
|
def _get_info(self):
|
||||||
|
|
||||||
details = self.domains.get(self._match) or {}
|
details = self.domains.get(self._match) or {}
|
||||||
|
|
||||||
if isinstance(details, str):
|
if isinstance(details, str):
|
||||||
return GovernmentDomain(details)._get_details_of_domain()
|
return AgreementInfo(details)._get_info()
|
||||||
|
|
||||||
elif isinstance(details, dict):
|
elif isinstance(details, dict):
|
||||||
return(
|
return(
|
||||||
@@ -526,7 +526,7 @@ class NotGovernmentEmailDomain(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class GovernmentEmailDomain(GovernmentDomain):
|
class GovernmentEmailDomain(AgreementInfo):
|
||||||
|
|
||||||
with open('{}/email_domains.yml'.format(_dir_path)) as email_domains:
|
with open('{}/email_domains.yml'.format(_dir_path)) as email_domains:
|
||||||
domain_names = yaml.safe_load(email_domains)
|
domain_names = yaml.safe_load(email_domains)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ from freezegun import freeze_time
|
|||||||
from tests.conftest import fake_uuid
|
from tests.conftest import fake_uuid
|
||||||
|
|
||||||
from app.utils import (
|
from app.utils import (
|
||||||
GovernmentDomain,
|
AgreementInfo,
|
||||||
Spreadsheet,
|
Spreadsheet,
|
||||||
email_safe,
|
email_safe,
|
||||||
generate_next_dict,
|
generate_next_dict,
|
||||||
@@ -382,12 +382,12 @@ def test_get_cdn_domain_on_non_localhost(client, mocker):
|
|||||||
@pytest.mark.parametrize("domain_or_email_address", (
|
@pytest.mark.parametrize("domain_or_email_address", (
|
||||||
"test@dclgdatamart.co.uk", "test@communities.gsi.gov.uk", "test@communities.gov.uk",
|
"test@dclgdatamart.co.uk", "test@communities.gsi.gov.uk", "test@communities.gov.uk",
|
||||||
))
|
))
|
||||||
def test_get_valid_government_domain_known_details(domain_or_email_address):
|
def test_get_valid_agreement_info_known_details(domain_or_email_address):
|
||||||
government_domain = GovernmentDomain(domain_or_email_address)
|
agreement_info = AgreementInfo(domain_or_email_address)
|
||||||
assert government_domain.crown_status is None
|
assert agreement_info.crown_status is None
|
||||||
assert government_domain.owner == "Ministry of Housing, Communities & Local Government"
|
assert agreement_info.owner == "Ministry of Housing, Communities & Local Government"
|
||||||
assert government_domain.agreement_signed is True
|
assert agreement_info.agreement_signed is True
|
||||||
assert government_domain.as_human_readable == (
|
assert agreement_info.as_human_readable == (
|
||||||
'Yes, on behalf of Ministry of Housing, Communities & Local Government'
|
'Yes, on behalf of Ministry of Housing, Communities & Local Government'
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -395,46 +395,46 @@ def test_get_valid_government_domain_known_details(domain_or_email_address):
|
|||||||
@pytest.mark.parametrize("domain_or_email_address", (
|
@pytest.mark.parametrize("domain_or_email_address", (
|
||||||
"test@police.gov.uk", "police.gov.uk",
|
"test@police.gov.uk", "police.gov.uk",
|
||||||
))
|
))
|
||||||
def test_get_valid_government_domain_unknown_details(domain_or_email_address):
|
def test_get_valid_agreement_info_unknown_details(domain_or_email_address):
|
||||||
government_domain = GovernmentDomain(domain_or_email_address)
|
government_domain = AgreementInfo(domain_or_email_address)
|
||||||
assert government_domain.crown_status is None
|
assert government_domain.crown_status is None
|
||||||
assert government_domain.owner is None
|
assert government_domain.owner is None
|
||||||
assert government_domain.agreement_signed is None
|
assert government_domain.agreement_signed is None
|
||||||
assert government_domain.as_human_readable == 'Can’t tell'
|
assert government_domain.as_human_readable == 'Can’t tell'
|
||||||
|
|
||||||
|
|
||||||
def test_get_valid_government_domain_only_org_known():
|
def test_get_valid_agreement_info_only_org_known():
|
||||||
government_domain = GovernmentDomain('nhs.net')
|
agreement_info = AgreementInfo('nhs.net')
|
||||||
# Some parts of the NHS are Crown, some aren’t
|
# Some parts of the NHS are Crown, some aren’t
|
||||||
assert government_domain.crown_status is None
|
assert agreement_info.crown_status is None
|
||||||
assert government_domain.owner == 'NHS'
|
assert agreement_info.owner == 'NHS'
|
||||||
assert government_domain.agreement_signed is None
|
assert agreement_info.agreement_signed is None
|
||||||
assert government_domain.as_human_readable == 'Can’t tell (organisation is NHS, crown status unknown)'
|
assert agreement_info.as_human_readable == 'Can’t tell (organisation is NHS, crown status unknown)'
|
||||||
|
|
||||||
|
|
||||||
def test_get_valid_government_domain_some_known_details():
|
def test_get_valid_agreement_info_some_known_details():
|
||||||
government_domain = GovernmentDomain("marinemanagement.org.uk")
|
agreement_info = AgreementInfo("marinemanagement.org.uk")
|
||||||
assert government_domain.crown_status is None
|
assert agreement_info.crown_status is None
|
||||||
assert government_domain.owner == "Marine Management Organisation"
|
assert agreement_info.owner == "Marine Management Organisation"
|
||||||
assert government_domain.agreement_signed is True
|
assert agreement_info.agreement_signed is True
|
||||||
assert government_domain.as_human_readable == (
|
assert agreement_info.as_human_readable == (
|
||||||
'Yes, on behalf of Marine Management Organisation'
|
'Yes, on behalf of Marine Management Organisation'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_get_valid_local_government_domain_some_known_details():
|
def test_get_valid_local_agreement_info_some_known_details():
|
||||||
government_domain = GovernmentDomain("aberdeenshire.gov.uk")
|
agreement_info = AgreementInfo("aberdeenshire.gov.uk")
|
||||||
assert government_domain.crown_status is False
|
assert agreement_info.crown_status is False
|
||||||
assert government_domain.owner == "Aberdeenshire Council"
|
assert agreement_info.owner == "Aberdeenshire Council"
|
||||||
assert government_domain.agreement_signed is False
|
assert agreement_info.agreement_signed is False
|
||||||
assert government_domain.as_human_readable == (
|
assert agreement_info.as_human_readable == (
|
||||||
'No (organisation is Aberdeenshire Council, a non-crown body)'
|
'No (organisation is Aberdeenshire Council, a non-crown body)'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_get_valid_government_domain_gets_most_specific_first():
|
def test_get_valid_government_domain_gets_most_specific_first():
|
||||||
|
|
||||||
generic = GovernmentDomain("gov.uk")
|
generic = AgreementInfo("gov.uk")
|
||||||
assert generic.crown_status is None
|
assert generic.crown_status is None
|
||||||
assert generic.owner is None
|
assert generic.owner is None
|
||||||
assert generic.agreement_signed is None
|
assert generic.agreement_signed is None
|
||||||
@@ -442,7 +442,7 @@ def test_get_valid_government_domain_gets_most_specific_first():
|
|||||||
'Can’t tell'
|
'Can’t tell'
|
||||||
)
|
)
|
||||||
|
|
||||||
specific = GovernmentDomain("dacorum.gov.uk")
|
specific = AgreementInfo("dacorum.gov.uk")
|
||||||
assert specific.crown_status is False
|
assert specific.crown_status is False
|
||||||
assert specific.owner == 'Dacorum Borough Council'
|
assert specific.owner == 'Dacorum Borough Council'
|
||||||
assert specific.agreement_signed is True
|
assert specific.agreement_signed is True
|
||||||
@@ -453,20 +453,20 @@ def test_get_valid_government_domain_gets_most_specific_first():
|
|||||||
|
|
||||||
def test_validate_government_domain_data():
|
def test_validate_government_domain_data():
|
||||||
|
|
||||||
for domain in GovernmentDomain.domains.keys():
|
for domain in AgreementInfo.domains.keys():
|
||||||
|
|
||||||
government_domain = GovernmentDomain(domain)
|
agreement_info = AgreementInfo(domain)
|
||||||
|
|
||||||
assert government_domain.crown_status in {
|
assert agreement_info.crown_status in {
|
||||||
True, False, None
|
True, False, None
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (
|
assert (
|
||||||
government_domain.owner is None
|
agreement_info.owner is None
|
||||||
) or (
|
) or (
|
||||||
isinstance(government_domain.owner, str)
|
isinstance(agreement_info.owner, str)
|
||||||
)
|
)
|
||||||
|
|
||||||
assert government_domain.agreement_signed in {
|
assert agreement_info.agreement_signed in {
|
||||||
True, False, None
|
True, False, None
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user