Merge pull request #2490 from alphagov/live_services_organisation_type

Add organisation type to live services report
This commit is contained in:
Pea (Malgorzata Tyczynska)
2019-05-03 15:19:44 +01:00
committed by GitHub
4 changed files with 12 additions and 8 deletions

View File

@@ -84,6 +84,7 @@ def dao_fetch_live_services_data():
data = db.session.query(
Service.id,
Organisation.name.label("organisation_name"),
Organisation.organisation_type,
Service.name.label("service_name"),
Service.consent_to_research,
Service.go_live_user_id,
@@ -117,6 +118,7 @@ def dao_fetch_live_services_data():
).group_by(
Service.id,
Organisation.name,
Organisation.organisation_type,
Service.name,
Service.consent_to_research,
Service.count_as_live,
@@ -151,6 +153,7 @@ def dao_fetch_live_services_data():
"service_id": row.id,
"service_name": row.service_name,
"organisation_name": row.organisation_name,
"organisation_type": row.organisation_type,
"consent_to_research": row.consent_to_research,
"contact_name": row.user_name,
"contact_email": row.email_address,

View File

@@ -386,7 +386,7 @@ def test_get_all_user_services_should_return_empty_list_if_no_services_for_user(
@freeze_time('2019-04-23T10:00:00')
def test_dao_fetch_live_services_data(sample_user, mock):
org = create_organisation()
org = create_organisation(organisation_type='crown')
service = create_service(go_live_user=sample_user, go_live_at='2014-04-20T10:00:00')
template = create_template(service=service)
service_2 = create_service(service_name='second', go_live_user=sample_user, go_live_at='2017-04-20T10:00:00')
@@ -416,19 +416,19 @@ def test_dao_fetch_live_services_data(sample_user, mock):
# checks the results and that they are ordered by date:
assert results == [
{'service_id': mock.ANY, 'service_name': 'Sample service', 'organisation_name': 'test_org_1',
'consent_to_research': None, 'contact_name': 'Test User',
'organisation_type': 'crown', 'consent_to_research': None, 'contact_name': 'Test User',
'contact_email': 'notify@digital.cabinet-office.gov.uk', 'contact_mobile': '+447700900986',
'live_date': datetime(2014, 4, 20, 10, 0), 'sms_volume_intent': None, 'email_volume_intent': None,
'letter_volume_intent': None, 'sms_totals': 2, 'email_totals': 1, 'letter_totals': 1},
{'service_id': mock.ANY, 'service_name': 'third', 'organisation_name': None, 'consent_to_research': None,
'contact_name': None, 'contact_email': None,
'organisation_type': None, 'contact_name': None, 'contact_email': None,
'contact_mobile': None, 'live_date': datetime(2016, 4, 20, 10, 0), 'sms_volume_intent': None,
'email_volume_intent': None, 'letter_volume_intent': None,
'sms_totals': 0, 'email_totals': 0, 'letter_totals': 0},
{'service_id': mock.ANY, 'service_name': 'second', 'organisation_name': None, 'consent_to_research': None,
'contact_name': 'Test User', 'contact_email': 'notify@digital.cabinet-office.gov.uk',
'contact_mobile': '+447700900986', 'live_date': datetime(2017, 4, 20, 10, 0), 'sms_volume_intent': None,
'email_volume_intent': None, 'letter_volume_intent': None,
'organisation_type': None, 'email_volume_intent': None, 'letter_volume_intent': None,
'sms_totals': 0, 'email_totals': 0, 'letter_totals': 1}
]

View File

@@ -541,10 +541,11 @@ def create_domain(domain, organisation_id):
return domain
def create_organisation(name='test_org_1', active=True):
def create_organisation(name='test_org_1', active=True, organisation_type=None):
data = {
'name': name,
'active': active
'active': active,
'organisation_type': organisation_type
}
organisation = Organisation(**data)
dao_create_organisation(organisation)

View File

@@ -153,12 +153,12 @@ def test_get_live_services_data(sample_user, admin_request, mock):
'contact_mobile': '+447700900986', 'contact_name': 'Test User', 'email_totals': 0,
'email_volume_intent': None, 'letter_totals': 0, 'letter_volume_intent': None, 'live_date': None,
'organisation_name': None, 'service_id': mock.ANY, 'service_name': 'second', 'sms_totals': 0,
'sms_volume_intent': None} in response
'sms_volume_intent': None, 'organisation_type': None} in response
assert {'consent_to_research': None, 'contact_email': 'notify@digital.cabinet-office.gov.uk',
'contact_mobile': '+447700900986', 'contact_name': 'Test User', 'email_totals': 1,
'email_volume_intent': None, 'letter_totals': 0, 'letter_volume_intent': None, 'live_date': None,
'organisation_name': 'test_org_1', 'service_id': mock.ANY, 'service_name': 'Sample service',
'sms_totals': 1, 'sms_volume_intent': None} in response
'sms_totals': 1, 'sms_volume_intent': None, 'organisation_type': None} in response
def test_get_service_by_id(admin_request, sample_service):