Merge pull request #1941 from alphagov/rtgl-org-info

Add what we know of agreements to go live request
This commit is contained in:
Leo Hemsted
2018-03-09 12:20:57 +00:00
committed by GitHub
5 changed files with 66 additions and 0 deletions

View File

@@ -53,6 +53,8 @@ innovateuk.gov.uk:
ncsc.gov.uk:
owner: National Cyber Security Center
agreement_signed: true
nhs.net:
owner: NHS
nhsdigital.nhs.uk: digital.nhs.uk
digital.nhs.uk:
owner: NHS Digital

View File

@@ -44,6 +44,7 @@ from app.main.forms import (
SMSPrefixForm,
)
from app.utils import (
GovernmentDomain,
email_safe,
get_cdn_domain,
user_has_permissions,
@@ -196,6 +197,7 @@ def submit_request_to_go_live(service_id):
'On behalf of {} ({})\n'
'\n---'
'\nOrganisation type: {}'
'\nAgreement signed: {}'
'\nMOU in place: {}'
'\nChannel: {}\nStart date: {}\nStart volume: {}'
'\nPeak volume: {}'
@@ -204,6 +206,7 @@ def submit_request_to_go_live(service_id):
current_service['name'],
url_for('main.service_dashboard', service_id=current_service['id'], _external=True),
current_service['organisation_type'],
GovernmentDomain.from_current_user().as_human_readable,
form.mou.data,
formatted_list(filter(None, (
'email' if form.channel_email.data else None,

View File

@@ -462,6 +462,34 @@ class GovernmentDomain:
self.agreement_signed
) = self._get_details_of_domain()
@classmethod
def from_user(cls, user):
return cls(user.email_address if user.is_authenticated else '')
@classmethod
def from_current_user(cls):
return cls.from_user(current_user)
@property
def as_human_readable(self):
if self.agreement_signed:
return 'Yes, on behalf of {}'.format(self.owner)
elif self.owner:
return '{} (organisation is {}, {})'.format(
{
False: 'No',
None: 'Cant tell',
}.get(self.agreement_signed),
self.owner,
{
True: 'a crown body',
False: 'a non-crown body',
None: 'crown status unknown',
}.get(self.crown_status),
)
else:
return 'Cant tell'
@staticmethod
def get_matching_function(email_address_or_domain):

View File

@@ -588,6 +588,7 @@ def test_should_redirect_after_request_to_go_live(
returned_message = mock_post.call_args[1]['message']
assert 'On behalf of service one' in returned_message
assert 'Organisation type: central' in returned_message
assert 'Agreement signed: Cant tell' in returned_message
assert 'Channel: email and text messages' in returned_message
assert 'Start date: 01/01/2017' in returned_message
assert 'Start volume: 100,000' in returned_message

View File

@@ -387,6 +387,9 @@ def test_get_valid_government_domain_known_details(domain_or_email_address):
assert government_domain.crown_status is None
assert government_domain.owner == "Ministry of Housing, Communities & Local Government"
assert government_domain.agreement_signed is True
assert government_domain.as_human_readable == (
'Yes, on behalf of Ministry of Housing, Communities & Local Government'
)
@pytest.mark.parametrize("domain_or_email_address", (
@@ -397,6 +400,16 @@ def test_get_valid_government_domain_unknown_details(domain_or_email_address):
assert government_domain.crown_status is None
assert government_domain.owner is None
assert government_domain.agreement_signed is None
assert government_domain.as_human_readable == 'Cant tell'
def test_get_valid_government_domain_only_org_known():
government_domain = GovernmentDomain('nhs.net')
# Some parts of the NHS are Crown, some arent
assert government_domain.crown_status is None
assert government_domain.owner == 'NHS'
assert government_domain.agreement_signed is None
assert government_domain.as_human_readable == 'Cant tell (organisation is NHS, crown status unknown)'
def test_get_valid_government_domain_some_known_details():
@@ -404,6 +417,19 @@ def test_get_valid_government_domain_some_known_details():
assert government_domain.crown_status is None
assert government_domain.owner == "Marine Management Organisation"
assert government_domain.agreement_signed is True
assert government_domain.as_human_readable == (
'Yes, on behalf of Marine Management Organisation'
)
def test_get_valid_local_government_domain_some_known_details():
government_domain = GovernmentDomain("aberdeenshire.gov.uk")
assert government_domain.crown_status is False
assert government_domain.owner == "Aberdeenshire Council"
assert government_domain.agreement_signed is False
assert government_domain.as_human_readable == (
'No (organisation is Aberdeenshire Council, a non-crown body)'
)
def test_get_valid_government_domain_gets_most_specific_first():
@@ -412,11 +438,17 @@ def test_get_valid_government_domain_gets_most_specific_first():
assert generic.crown_status is None
assert generic.owner is None
assert generic.agreement_signed is None
assert generic.as_human_readable == (
'Cant tell'
)
specific = GovernmentDomain("dacorum.gov.uk")
assert specific.crown_status is False
assert specific.owner == 'Dacorum Borough Council'
assert specific.agreement_signed is True
assert specific.as_human_readable == (
'Yes, on behalf of Dacorum Borough Council'
)
def test_validate_government_domain_data():