mirror of
https://github.com/GSA/notifications-api.git
synced 2026-04-17 15:49:44 -04:00
Only count_as_live services
Add comments to live services dao test for context
This commit is contained in:
@@ -87,6 +87,7 @@ def dao_fetch_live_services_data():
|
||||
Service.name.label("service_name"),
|
||||
Service.consent_to_research,
|
||||
Service.go_live_user_id,
|
||||
Service.count_as_live,
|
||||
User.name.label('user_name'),
|
||||
User.email_address,
|
||||
User.mobile_number,
|
||||
@@ -109,11 +110,14 @@ def dao_fetch_live_services_data():
|
||||
this_year_ft_billing, Service.id == this_year_ft_billing.c.service_id
|
||||
).outerjoin(
|
||||
User, Service.go_live_user_id == User.id
|
||||
).filter(
|
||||
Service.count_as_live == True # noqa
|
||||
).group_by(
|
||||
Service.id,
|
||||
Organisation.name,
|
||||
Service.name,
|
||||
Service.consent_to_research,
|
||||
Service.count_as_live,
|
||||
Service.go_live_user_id,
|
||||
User.name,
|
||||
User.email_address,
|
||||
|
||||
@@ -391,15 +391,21 @@ def test_dao_fetch_live_services_data(sample_user, mock):
|
||||
template = create_template(service=service)
|
||||
service_2 = create_service(service_name='second', go_live_user=sample_user)
|
||||
create_service(service_name='third')
|
||||
create_service(service_name='not_live', count_as_live=False)
|
||||
template2 = create_template(service=service, template_type='email')
|
||||
template_letter_1 = create_template(service=service, template_type='letter')
|
||||
template_letter_2 = create_template(service=service_2, template_type='letter')
|
||||
dao_add_service_to_organisation(service=service, organisation_id=org.id)
|
||||
# two sms billing records for 1st service within current financial year:
|
||||
create_ft_billing(bst_date='2019-04-20', notification_type='sms', template=template, service=service)
|
||||
create_ft_billing(bst_date='2019-04-21', notification_type='sms', template=template, service=service)
|
||||
# one sms billing record for 1st service from previous financial year, should not appear in the result:
|
||||
create_ft_billing(bst_date='2018-04-20', notification_type='sms', template=template, service=service)
|
||||
# one email billing record for 1st service within current financial year:
|
||||
create_ft_billing(bst_date='2019-04-20', notification_type='email', template=template2, service=service)
|
||||
# one letter billing record for 1st service within current financial year:
|
||||
create_ft_billing(bst_date='2019-04-15', notification_type='letter', template=template_letter_1, service=service)
|
||||
# one letter billing record for 2nd service within current financial year:
|
||||
create_ft_billing(bst_date='2019-04-16', notification_type='letter', template=template_letter_2, service=service_2)
|
||||
|
||||
results = dao_fetch_live_services_data()
|
||||
|
||||
Reference in New Issue
Block a user