mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-02 17:48:36 -04:00
Add endpoint to return structured data
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import random
|
||||
import uuid
|
||||
from datetime import datetime, date
|
||||
from datetime import datetime, date, timedelta
|
||||
|
||||
from app import db
|
||||
from app.dao.email_branding_dao import dao_create_email_branding
|
||||
@@ -12,7 +12,7 @@ from app.dao.notifications_dao import (
|
||||
dao_create_notification,
|
||||
dao_created_scheduled_notification
|
||||
)
|
||||
from app.dao.organisation_dao import dao_create_organisation
|
||||
from app.dao.organisation_dao import dao_create_organisation, dao_add_service_to_organisation
|
||||
from app.dao.permissions_dao import permission_dao
|
||||
from app.dao.service_callback_api_dao import save_service_callback_api
|
||||
from app.dao.service_data_retention_dao import insert_service_data_retention
|
||||
@@ -873,3 +873,66 @@ def create_letter_branding(name='HM Government', filename='hm-government'):
|
||||
db.session.add(test_domain_branding)
|
||||
db.session.commit()
|
||||
return test_domain_branding
|
||||
|
||||
|
||||
def set_up_usage_data(start_date):
|
||||
year = int(start_date.strftime('%Y'))
|
||||
one_week_earlier = start_date - timedelta(days=7)
|
||||
two_days_later = start_date + timedelta(days=2)
|
||||
one_week_later = start_date + timedelta(days=7)
|
||||
one_month_later = start_date + timedelta(days=31)
|
||||
|
||||
service = create_service(service_name='a - with sms and letter')
|
||||
letter_template = create_template(service=service, template_type='letter')
|
||||
sms_template_1 = create_template(service=service, template_type='sms')
|
||||
create_annual_billing(service_id=service.id, free_sms_fragment_limit=10, financial_year_start=year)
|
||||
org = create_organisation(name="Org for {}".format(service.name))
|
||||
dao_add_service_to_organisation(service=service, organisation_id=org.id)
|
||||
|
||||
service_3 = create_service(service_name='c - letters only')
|
||||
template_3 = create_template(service=service_3)
|
||||
org_3 = create_organisation(name="Org for {}".format(service_3.name))
|
||||
dao_add_service_to_organisation(service=service_3, organisation_id=org_3.id)
|
||||
|
||||
service_4 = create_service(service_name='d - service without org')
|
||||
template_4 = create_template(service=service_4, template_type='letter')
|
||||
|
||||
service_sms_only = create_service(service_name='b - chargeable sms')
|
||||
sms_template = create_template(service=service_sms_only, template_type='sms')
|
||||
create_annual_billing(service_id=service_sms_only.id, free_sms_fragment_limit=10, financial_year_start=year)
|
||||
|
||||
create_ft_billing(bst_date=one_week_earlier, service=service, notification_type='sms',
|
||||
template=sms_template_1, billable_unit=2, rate=0.11)
|
||||
create_ft_billing(bst_date=start_date, service=service, notification_type='sms',
|
||||
template=sms_template_1, billable_unit=2, rate=0.11)
|
||||
create_ft_billing(bst_date=two_days_later, service=service, notification_type='sms',
|
||||
template=sms_template_1, billable_unit=1, rate=0.11)
|
||||
create_ft_billing(bst_date=one_week_later, service=service, notification_type='letter',
|
||||
template=letter_template,
|
||||
notifications_sent=2, billable_unit=1, rate=.35, postage='first')
|
||||
create_ft_billing(bst_date=one_month_later, service=service, notification_type='letter',
|
||||
template=letter_template,
|
||||
notifications_sent=6, billable_unit=2, rate=.45, postage='second')
|
||||
|
||||
create_ft_billing(bst_date=one_week_earlier, service=service_sms_only, notification_type='sms',
|
||||
template=sms_template, rate=0.11, billable_unit=12)
|
||||
create_ft_billing(bst_date=two_days_later, service=service_sms_only, notification_type='sms',
|
||||
template=sms_template, rate=0.11)
|
||||
create_ft_billing(bst_date=one_week_later, service=service_sms_only, notification_type='sms',
|
||||
template=sms_template, billable_unit=2, rate=0.11)
|
||||
|
||||
create_ft_billing(bst_date=start_date, service=service_3, notification_type='letter',
|
||||
template=template_3,
|
||||
notifications_sent=2, billable_unit=3, rate=.50, postage='first')
|
||||
create_ft_billing(bst_date=one_week_later, service=service_3, notification_type='letter',
|
||||
template=template_3,
|
||||
notifications_sent=8, billable_unit=5, rate=.65, postage='second')
|
||||
create_ft_billing(bst_date=one_month_later, service=service_3, notification_type='letter',
|
||||
template=template_3,
|
||||
notifications_sent=12, billable_unit=5, rate=.65, postage='second')
|
||||
|
||||
create_ft_billing(bst_date=two_days_later, service=service_4, notification_type='letter',
|
||||
template=template_4,
|
||||
notifications_sent=15, billable_unit=4, rate=.55, postage='second')
|
||||
|
||||
return org, org_3, service, service_3, service_4, service_sms_only
|
||||
|
||||
Reference in New Issue
Block a user