mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-11 10:28:55 -04:00
fixed object persistence problem
This commit is contained in:
@@ -5,26 +5,28 @@
|
||||
|
||||
from app.models import AnnualBilling
|
||||
from app.dao.annual_billing_dao import (
|
||||
dao_create_new_annual_billing_for_year,
|
||||
dao_get_free_sms_fragment_limit_for_year,
|
||||
dao_update_new_free_sms_fragment_limit_for_year
|
||||
dao_create_or_update_annual_billing_for_year,
|
||||
dao_get_free_sms_fragment_limit_for_year
|
||||
)
|
||||
|
||||
|
||||
def test_dao_create_get_free_sms_fragment_limit(notify_db_session, sample_service):
|
||||
year = 2016
|
||||
data = AnnualBilling(
|
||||
free_sms_fragment_limit=250000,
|
||||
financial_year_start=year,
|
||||
service_id=sample_service.id,
|
||||
)
|
||||
dao_create_new_annual_billing_for_year(data)
|
||||
years = [2015, 2016, 2017]
|
||||
free_limit_data = [1000, 2000, 3000]
|
||||
for i in range(0, len(years)):
|
||||
data = AnnualBilling(
|
||||
free_sms_fragment_limit=free_limit_data[i],
|
||||
financial_year_start=years[i],
|
||||
service_id=sample_service.id,
|
||||
)
|
||||
dao_create_or_update_annual_billing_for_year(data)
|
||||
|
||||
free_limit = dao_get_free_sms_fragment_limit_for_year(sample_service.id, year)
|
||||
for i in range(0, len(years)):
|
||||
free_limit = dao_get_free_sms_fragment_limit_for_year(sample_service.id, years[i])
|
||||
|
||||
assert free_limit.free_sms_fragment_limit == 250000
|
||||
assert free_limit.financial_year_start == year
|
||||
assert free_limit.service_id == sample_service.id
|
||||
assert free_limit.free_sms_fragment_limit == free_limit_data[i]
|
||||
assert free_limit.financial_year_start == years[i]
|
||||
assert free_limit.service_id == sample_service.id
|
||||
|
||||
|
||||
def test_dao_update_free_sms_fragment_limit(notify_db_session, sample_service):
|
||||
@@ -38,9 +40,9 @@ def test_dao_update_free_sms_fragment_limit(notify_db_session, sample_service):
|
||||
service_id=sample_service.id,
|
||||
)
|
||||
|
||||
dao_create_new_annual_billing_for_year(data)
|
||||
dao_create_or_update_annual_billing_for_year(data)
|
||||
data.free_sms_fragment_limit = new_limit
|
||||
dao_update_new_free_sms_fragment_limit_for_year(data)
|
||||
dao_create_or_update_annual_billing_for_year(data)
|
||||
new_free_limit = dao_get_free_sms_fragment_limit_for_year(sample_service.id, year)
|
||||
|
||||
assert new_free_limit.free_sms_fragment_limit == new_limit
|
||||
|
||||
Reference in New Issue
Block a user