mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 21:18:26 -04:00
Minor tweaks in response to PR comments
In response to [^1] and [^2]. [^1]: https://github.com/alphagov/notifications-admin/pull/4229#discussion_r869181152 [^2]: https://github.com/alphagov/notifications-admin/pull/4229#discussion_r869186063
This commit is contained in:
@@ -423,6 +423,10 @@ def get_monthly_usage_breakdown_for_letters(monthly_letters):
|
||||
postage_order[get_monthly_usage_postage_description(row)], row['rate']
|
||||
)
|
||||
|
||||
# First sort letter rows by postage and then by rate, clumping "europe" and
|
||||
# "rest-of-world" postage together as "international". Group the sorted rows
|
||||
# together using the same fields - "group_key" is used for both operations.
|
||||
# Note that "groupby" preserves the sort order in the groups it returns.
|
||||
rate_groups = groupby(sorted(monthly_letters, key=group_key), key=group_key)
|
||||
|
||||
for _key, rate_group in rate_groups:
|
||||
|
||||
@@ -1079,9 +1079,10 @@ def test_usage_page_monthly_breakdown(
|
||||
assert '140 free text messages' in monthly_breakdown
|
||||
assert '960 text messages at 1.65p' in monthly_breakdown
|
||||
assert '33 text messages at 1.70p' in monthly_breakdown
|
||||
assert '10 second class letters at 31p' in monthly_breakdown
|
||||
assert '5 first class letters at 33p' in monthly_breakdown
|
||||
assert '10 international letters at 84p' in monthly_breakdown
|
||||
assert '10 second class letters at 31p' in monthly_breakdown
|
||||
assert '3 international letters at 55p' in monthly_breakdown
|
||||
assert '7 international letters at 84p' in monthly_breakdown
|
||||
|
||||
assert 'March' in monthly_breakdown
|
||||
assert '£20.91' in monthly_breakdown
|
||||
@@ -1110,7 +1111,7 @@ def test_usage_page_monthly_breakdown_shows_months_so_far(
|
||||
|
||||
|
||||
@freeze_time("2012-03-31 12:12:12")
|
||||
def test_usage_page_letter_breakdown_ordering(
|
||||
def test_usage_page_letter_breakdown_ordered_by_postage_and_rate(
|
||||
client_request,
|
||||
service_one,
|
||||
mock_get_monthly_usage_for_service,
|
||||
@@ -1123,7 +1124,8 @@ def test_usage_page_letter_breakdown_ordering(
|
||||
|
||||
assert normalize_spaces(postage_details[3].text) == '5 first class letters at 33p'
|
||||
assert normalize_spaces(postage_details[4].text) == '10 second class letters at 31p'
|
||||
assert normalize_spaces(postage_details[5].text) == '10 international letters at 84p'
|
||||
assert normalize_spaces(postage_details[5].text) == '3 international letters at 55p'
|
||||
assert normalize_spaces(postage_details[6].text) == '7 international letters at 84p'
|
||||
|
||||
|
||||
def test_usage_page_with_0_free_allowance(
|
||||
|
||||
@@ -2421,7 +2421,7 @@ def mock_get_monthly_usage_for_service(mocker):
|
||||
{
|
||||
'month': 'February',
|
||||
'notification_type': 'letter',
|
||||
'rate': 0.84,
|
||||
'rate': 0.55,
|
||||
'chargeable_units': 3,
|
||||
'notifications_sent': 3,
|
||||
'postage': 'europe',
|
||||
|
||||
Reference in New Issue
Block a user