mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-03 01:41:05 -05:00
When a service is associated with a organisation set the free allowance to
the default free allowance for the organisation type. The update/insert for the default free allowance is done in a separate transaction. Updates to services need to happen in a transaction to trigger the insert into the ServicesHistory table. For that reason the call to set_default_free_allowance_for_service is done after the service is updated. I've added a try/except around the set_default_free_allowance_for_service call to ensure we still get the update to the service but get an exception log if the update to annual_billing fails. I believe it's important to preserve the update to the service in the unlikely event that the annual_billing upsert fails.
This commit is contained in:
@@ -91,3 +91,21 @@ def test_set_default_free_allowance_for_service_using_correct_year(sample_servic
|
||||
25000,
|
||||
2020
|
||||
)
|
||||
|
||||
|
||||
@freeze_time('2021-04-01 14:02:00')
|
||||
def test_set_default_free_allowance_for_service_updates_existing_year(sample_service):
|
||||
set_default_free_allowance_for_service(service=sample_service, year_start=None)
|
||||
annual_billing = AnnualBilling.query.all()
|
||||
assert not sample_service.organisation_type
|
||||
assert len(annual_billing) == 1
|
||||
assert annual_billing[0].service_id == sample_service.id
|
||||
assert annual_billing[0].free_sms_fragment_limit == 10000
|
||||
|
||||
sample_service.organisation_type = 'central'
|
||||
|
||||
set_default_free_allowance_for_service(service=sample_service, year_start=None)
|
||||
annual_billing = AnnualBilling.query.all()
|
||||
assert len(annual_billing) == 1
|
||||
assert annual_billing[0].service_id == sample_service.id
|
||||
assert annual_billing[0].free_sms_fragment_limit == 150000
|
||||
|
||||
Reference in New Issue
Block a user