mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-13 09:50:08 -04:00
Fix column names
Add unit test
This commit is contained in:
@@ -322,9 +322,9 @@ def get_volumes_by_service():
|
||||
start_date = form.start_date.data
|
||||
end_date = form.end_date.data
|
||||
headers = [
|
||||
"organisation_id", "organisation_name", "service_id", "service_name",
|
||||
"free_allowance", "sms_notifications", "sms chargeable units", "email_totals",
|
||||
"letter_totals", "letter_cost", "letter_sheet_totals"
|
||||
"organisation id", "organisation name", "service id", "service name",
|
||||
"free allowance", "sms notifications", "sms chargeable units", "email totals",
|
||||
"letter totals", "letter cost", "letter sheet totals"
|
||||
]
|
||||
result = billing_api_client.get_data_for_volumes_by_service_report(start_date, end_date)
|
||||
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
{% for message_length, charge in [
|
||||
('day', 'The whole business day in BST.'),
|
||||
('sms totals', 'The number of text messages sent'),
|
||||
('sms fragments', 'The number of text message fragments sent times the rate multiplier'),
|
||||
('sms chargeable units', 'The number of text message fragments sent'),
|
||||
('sms_fragments_times_multiplier', 'The number of text message fragments sent times the rate multiplier'),
|
||||
('email totals', 'The number of emails sent'),
|
||||
('letter totals', 'The number of letters sent'),
|
||||
('letter sheet totals', The number of sheets sent)
|
||||
('letter sheet totals', 'The number of sheets sent')
|
||||
] %}
|
||||
{% call row() %}
|
||||
{{ text_field(message_length) }}
|
||||
|
||||
@@ -31,9 +31,11 @@
|
||||
{% for message_length, charge in [
|
||||
('free allowance', 'Free allowance set for the service. This is the latest free allowance for the date range given'),
|
||||
('sms notifications', 'The number of text messages sent by the service.'),
|
||||
('sms volume', 'The number of text message fragments times the rate multiplier sent by the service.'),
|
||||
('sms chargeable units', 'The number of text message fragments times the rate multiplier sent by the service.'),
|
||||
('email totals', 'The number of emails sent by a service'),
|
||||
('letter totals', 'The number of letters sent by a service'),
|
||||
('letter costs', 'The cost of the letters, rate * letter totals'),
|
||||
('letter sheet totals', 'The number of sheet sent by a service')
|
||||
] %}
|
||||
{% call row() %}
|
||||
{{ text_field(message_length) }}
|
||||
|
||||
@@ -1014,3 +1014,102 @@ def test_get_notifications_sent_by_service_calls_api_and_downloads_data(
|
||||
'2019-01-01,596364a0-858e-42c8-9062-a8fe822260eb,service one,sms,42,0,0,8,0,0\r\n'
|
||||
'2019-01-01,147ad62a-2951-4fa1-9ca0-093cd1a52c52,service two,email,3,1,0,2,0,0\r\n'
|
||||
)
|
||||
|
||||
|
||||
def test_get_volumes_by_service_report_when_calls_api_and_download_data(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
mocker
|
||||
):
|
||||
mocker.patch(
|
||||
"app.main.views.platform_admin.billing_api_client.get_data_for_volumes_by_service_report",
|
||||
return_value=[{
|
||||
"organisation_id": "7832a1be-a1f0-4f2a-982f-05adfd3d6354",
|
||||
"organisation_name": "Org name",
|
||||
"service_id": "48e82ac0-c8c4-4e46-8712-c83c35a94006",
|
||||
"service_name": "service name",
|
||||
"free_allowance": 10000,
|
||||
"sms_notifications": 10,
|
||||
"sms_chargeable_units": 20,
|
||||
"email_totals": 8,
|
||||
"letter_totals": 10,
|
||||
"letter_cost": 4.5,
|
||||
"letter_sheet_totals": 10
|
||||
}]
|
||||
)
|
||||
|
||||
client_request.login(platform_admin_user)
|
||||
response = client_request.post_response(
|
||||
'main.get_volumes_by_service',
|
||||
_data={'start_date': '2019-01-01', 'end_date': '2019-03-31'},
|
||||
_expected_status=200,
|
||||
)
|
||||
|
||||
assert response.content_type == 'text/csv; charset=utf-8'
|
||||
assert response.headers['Content-Disposition'] == (
|
||||
'attachment; filename="Volumes by service report from {} to {}.csv"'.format('2019-01-01', '2019-03-31')
|
||||
)
|
||||
|
||||
assert response.get_data(as_text=True) == (
|
||||
"organisation id,organisation name,service id,service name,free allowance,sms notifications," +
|
||||
"sms chargeable units,email totals,letter totals,letter cost,letter sheet totals\r\n" +
|
||||
|
||||
'7832a1be-a1f0-4f2a-982f-05adfd3d6354,' +
|
||||
'Org name,' +
|
||||
'48e82ac0-c8c4-4e46-8712-c83c35a94006,' +
|
||||
'service name,' +
|
||||
'10000,' +
|
||||
'10,' +
|
||||
'20,' +
|
||||
'8,' +
|
||||
'10,' +
|
||||
'4.5,' +
|
||||
'10'
|
||||
|
||||
'\r\n'
|
||||
)
|
||||
|
||||
|
||||
def test_get_daily_volumes_report_when_calls_api_and_download_data(
|
||||
client_request,
|
||||
platform_admin_user,
|
||||
mocker
|
||||
):
|
||||
mocker.patch(
|
||||
"app.main.views.platform_admin.billing_api_client.get_data_for_daily_volumes_report",
|
||||
return_value=[{
|
||||
"day": '2019-01-01',
|
||||
"sms_totals": 20,
|
||||
"sms_fragment_totals": 40,
|
||||
"sms_chargeable_units": 60,
|
||||
"email_totals": 100,
|
||||
"letter_totals": 10,
|
||||
"letter_sheet_totals": 20
|
||||
}]
|
||||
)
|
||||
|
||||
client_request.login(platform_admin_user)
|
||||
response = client_request.post_response(
|
||||
'main.get_daily_volumes',
|
||||
_data={'start_date': '2019-01-01', 'end_date': '2019-03-31'},
|
||||
_expected_status=200,
|
||||
)
|
||||
|
||||
assert response.content_type == 'text/csv; charset=utf-8'
|
||||
assert response.headers['Content-Disposition'] == (
|
||||
'attachment; filename="Daily volumes report from {} to {}.csv"'.format('2019-01-01', '2019-03-31')
|
||||
)
|
||||
|
||||
assert response.get_data(as_text=True) == (
|
||||
"day,sms totals,sms fragment totals,sms chargeable units,email totals,letter totals,letter sheet totals\r\n" +
|
||||
|
||||
'2019-01-01,' +
|
||||
'20,' +
|
||||
'40,' +
|
||||
'60,' +
|
||||
'100,' +
|
||||
'10,' +
|
||||
'20'
|
||||
|
||||
'\r\n'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user