mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Merge pull request #3193 from alphagov/populate-annual-billing-2021
Populate annual billing for 2021
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import pytest
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app.dao.annual_billing_dao import (
|
||||
dao_create_or_update_annual_billing_for_year,
|
||||
dao_get_free_sms_fragment_limit_for_year,
|
||||
dao_update_annual_billing_for_future_years,
|
||||
set_default_free_allowance_for_service,
|
||||
)
|
||||
from app.dao.date_util import get_current_financial_year_start_year
|
||||
from tests.app.db import create_annual_billing
|
||||
from app.models import AnnualBilling
|
||||
from tests.app.db import create_annual_billing, create_service
|
||||
|
||||
|
||||
def test_dao_update_free_sms_fragment_limit(notify_db_session, sample_service):
|
||||
@@ -40,3 +44,50 @@ def test_dao_update_annual_billing_for_future_years(notify_db_session, sample_se
|
||||
assert dao_get_free_sms_fragment_limit_for_year(sample_service.id, current_year) is None
|
||||
assert dao_get_free_sms_fragment_limit_for_year(sample_service.id, current_year + 1).free_sms_fragment_limit == 9999
|
||||
assert dao_get_free_sms_fragment_limit_for_year(sample_service.id, current_year + 2).free_sms_fragment_limit == 9999
|
||||
|
||||
|
||||
@pytest.mark.parametrize('org_type, year, expected_default',
|
||||
[('central', 2021, 150000),
|
||||
('local', 2021, 25000),
|
||||
('nhs_central', 2021, 150000),
|
||||
('nhs_local', 2021, 25000),
|
||||
('nhs_gp', 2021, 10000),
|
||||
('emergency_service', 2021, 25000),
|
||||
('school_or_college', 2021, 10000),
|
||||
('other', 2021, 10000),
|
||||
(None, 2021, 10000),
|
||||
('central', 2020, 250000),
|
||||
('local', 2020, 25000),
|
||||
('nhs_central', 2020, 250000),
|
||||
('nhs_local', 2020, 25000),
|
||||
('nhs_gp', 2020, 25000),
|
||||
('emergency_service', 2020, 25000),
|
||||
('school_or_college', 2020, 25000),
|
||||
('other', 2020, 25000),
|
||||
(None, 2020, 25000),
|
||||
('central', 2019, 250000),
|
||||
('school_or_college', 2022, 10000)
|
||||
])
|
||||
def test_set_default_free_allowance_for_service(notify_db_session, org_type, year, expected_default):
|
||||
|
||||
service = create_service(organisation_type=org_type)
|
||||
|
||||
set_default_free_allowance_for_service(service=service, year_start=year)
|
||||
|
||||
annual_billing = AnnualBilling.query.all()
|
||||
|
||||
assert len(annual_billing) == 1
|
||||
assert annual_billing[0].service_id == service.id
|
||||
assert annual_billing[0].free_sms_fragment_limit == expected_default
|
||||
|
||||
|
||||
@freeze_time('2021-03-29 14:02:00')
|
||||
def test_set_default_free_allowance_for_service_using_correct_year(sample_service, mocker):
|
||||
mock_dao = mocker.patch('app.dao.annual_billing_dao.dao_create_or_update_annual_billing_for_year')
|
||||
set_default_free_allowance_for_service(service=sample_service, year_start=None)
|
||||
|
||||
mock_dao.assert_called_once_with(
|
||||
sample_service.id,
|
||||
25000,
|
||||
2020
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user