diff --git a/app/billing/billing_schemas.py b/app/billing/billing_schemas.py index f9f592e7d..631c782f7 100644 --- a/app/billing/billing_schemas.py +++ b/app/billing/billing_schemas.py @@ -10,5 +10,5 @@ create_or_update_free_sms_fragment_limit_schema = { "free_sms_fragment_limit": {"type": "integer", "minimum": 1}, "financial_year_start": {"type": "integer", "minimum": 2016} }, - "required": ["free_sms_fragment_limit", "financial_year_start"] + "required": ["free_sms_fragment_limit"] } diff --git a/app/billing/rest.py b/app/billing/rest.py index a29e31be7..614842d3f 100644 --- a/app/billing/rest.py +++ b/app/billing/rest.py @@ -13,12 +13,12 @@ from app.models import SMS_TYPE, EMAIL_TYPE from app.utils import convert_utc_to_bst from app.dao.annual_billing_dao import (dao_get_free_sms_fragment_limit_for_year, dao_get_all_free_sms_fragment_limit, - dao_create_or_update_annual_billing_for_year) + dao_create_or_update_annual_billing_for_year, + dao_update_annual_billing_for_current_and_future_years) from app.billing.billing_schemas import create_or_update_free_sms_fragment_limit_schema from app.errors import InvalidRequest from app.schema_validation import validate -from app.models import AnnualBilling -from app.service.utils import get_current_financial_year_start_year +from app.dao.date_util import get_current_financial_year_start_year billing_blueprint = Blueprint( 'billing', @@ -97,49 +97,52 @@ def _transform_billing_for_month(billing_for_month): @billing_blueprint.route('/free-sms-fragment-limit', methods=["GET"]) -@billing_blueprint.route('/free-sms-fragment-limit/current-year', methods=["GET"]) def get_free_sms_fragment_limit(service_id): - if request.path.split('/')[-1] == 'current-year': - financial_year_start = get_current_financial_year_start_year() - else: - financial_year_start = request.args.get('financial_year_start') + financial_year_start = request.args.get('financial_year_start') - if financial_year_start is None: - results = dao_get_all_free_sms_fragment_limit(service_id) + annual_billing = dao_get_free_sms_fragment_limit_for_year(service_id, financial_year_start) - if len(results) == 0: - raise InvalidRequest('no annual billing information for this service', status_code=404) - return jsonify(data=[row.serialize_free_sms_items() for row in results]), 200 - else: - result = dao_get_free_sms_fragment_limit_for_year(service_id, financial_year_start) - if result is None: - raise InvalidRequest('no free-sms-fragment-limit-info for this service and year', status_code=404) + if annual_billing is None: + # An entry does not exist in annual_billing table for that service and year. If it is a past year, + # we return the oldest entry. + # If it is the current or future years, we create an entry in the db table using the newest record, + # and return that number. If all fails, we return InvalidRequest. + sms_list = dao_get_all_free_sms_fragment_limit(service_id) - return jsonify(data=result.serialize_free_sms_items()), 200 + if not sms_list: + raise InvalidRequest('no free-sms-fragment-limit entry for service {} in DB'.format(service_id), 404) + else: + if financial_year_start is None: + financial_year_start = get_current_financial_year_start_year() + + if int(financial_year_start) < get_current_financial_year_start_year(): + annual_billing = sms_list[0] # The oldest entry + else: + annual_billing = sms_list[-1] # The newest entry + + annual_billing = dao_create_or_update_annual_billing_for_year(service_id, + annual_billing.free_sms_fragment_limit, + financial_year_start) + + return jsonify(annual_billing.serialize_free_sms_items()), 200 @billing_blueprint.route('/free-sms-fragment-limit', methods=["POST"]) def create_or_update_free_sms_fragment_limit(service_id): - dict_arg = request.get_json() + req_args = request.get_json() - if 'financial_year_start' not in dict_arg: - dict_arg['financial_year_start'] = get_current_financial_year_start_year() - - form = validate(dict_arg, create_or_update_free_sms_fragment_limit_schema) + form = validate(req_args, create_or_update_free_sms_fragment_limit_schema) financial_year_start = form.get('financial_year_start') free_sms_fragment_limit = form.get('free_sms_fragment_limit') - result = dao_get_free_sms_fragment_limit_for_year(service_id, financial_year_start) - - if result: - result.free_sms_fragment_limit = free_sms_fragment_limit + current_year = get_current_financial_year_start_year() + if financial_year_start is None or financial_year_start >= current_year: + dao_update_annual_billing_for_current_and_future_years(service_id, free_sms_fragment_limit) else: - result = AnnualBilling(service_id=service_id, financial_year_start=financial_year_start, - free_sms_fragment_limit=free_sms_fragment_limit) + dao_create_or_update_annual_billing_for_year(service_id, + free_sms_fragment_limit, financial_year_start) - dao_create_or_update_annual_billing_for_year(result) - - return jsonify(data=form), 201 + return jsonify(form), 201 diff --git a/app/dao/annual_billing_dao.py b/app/dao/annual_billing_dao.py index 2df3e1497..37361d7b1 100644 --- a/app/dao/annual_billing_dao.py +++ b/app/dao/annual_billing_dao.py @@ -1,11 +1,26 @@ -from app import db, create_uuid +from app import db from app.dao.dao_utils import ( transactional, - version_class ) from app.models import AnnualBilling -from datetime import datetime -from app.service.utils import get_current_financial_year_start_year +from app.dao.date_util import get_current_financial_year_start_year + + +@transactional +def dao_create_or_update_annual_billing_for_year(service_id, free_sms_fragment_limit, financial_year_start=None): + + if not financial_year_start: + financial_year_start = get_current_financial_year_start_year() + + result = dao_get_free_sms_fragment_limit_for_year(service_id, financial_year_start) + + if result: + result.free_sms_fragment_limit = free_sms_fragment_limit + else: + result = AnnualBilling(service_id=service_id, financial_year_start=financial_year_start, + free_sms_fragment_limit=free_sms_fragment_limit) + db.session.add(result) + return result def dao_get_annual_billing(service_id): @@ -14,16 +29,28 @@ def dao_get_annual_billing(service_id): ).order_by(AnnualBilling.financial_year_start).all() -def dao_create_or_update_annual_billing_for_year(annual_billing): - db.session.add(annual_billing) - db.session.commit() +@transactional +def dao_update_annual_billing_for_current_and_future_years(service_id, free_sms_fragment_limit, + financial_year_start=None): + if not financial_year_start: + financial_year_start = get_current_financial_year_start_year() + + updated = AnnualBilling.query.filter( + AnnualBilling.service_id == service_id, + AnnualBilling.financial_year_start >= financial_year_start + ).update( + {'free_sms_fragment_limit': free_sms_fragment_limit} + ) -def dao_get_free_sms_fragment_limit_for_year(service_id, year): +def dao_get_free_sms_fragment_limit_for_year(service_id, financial_year_start=None): + + if not financial_year_start: + financial_year_start = get_current_financial_year_start_year() return AnnualBilling.query.filter_by( service_id=service_id, - financial_year_start=year + financial_year_start=financial_year_start ).first() diff --git a/app/dao/date_util.py b/app/dao/date_util.py index a0044517d..b2c4d32bc 100644 --- a/app/dao/date_util.py +++ b/app/dao/date_util.py @@ -45,3 +45,12 @@ def get_month_start_and_end_date_in_utc(month_year): first_day = datetime(month_year.year, month_year.month, 1, 0, 0, 0) last_day = datetime(month_year.year, month_year.month, num_days, 23, 59, 59, 99999) return convert_bst_to_utc(first_day), convert_bst_to_utc(last_day) + + +def get_current_financial_year_start_year(): + now = datetime.now() + financial_year_start = now.year + start_date, end_date = get_financial_year(now.year) + if now < start_date: + financial_year_start = financial_year_start - 1 + return financial_year_start diff --git a/app/service/utils.py b/app/service/utils.py index 687f8939e..1d89d4fb6 100644 --- a/app/service/utils.py +++ b/app/service/utils.py @@ -54,12 +54,3 @@ def service_allowed_to_send_to(recipient, service, key_type): whitelist_members ) ) - - -def get_current_financial_year_start_year(): - now = datetime.now() - financial_year_start = now.year - start_date, end_date = get_financial_year(now.year) - if now < start_date: - financial_year_start = financial_year_start - 1 - return financial_year_start diff --git a/tests/app/billing/test_billing.py b/tests/app/billing/test_billing.py index 68175d704..7895bd8a9 100644 --- a/tests/app/billing/test_billing.py +++ b/tests/app/billing/test_billing.py @@ -15,9 +15,10 @@ from tests.app.db import ( from tests import create_authorization_header -from app.service.utils import get_current_financial_year_start_year +from app.dao.date_util import get_current_financial_year_start_year +from app.dao.annual_billing_dao import dao_get_free_sms_fragment_limit_for_year +from tests.app.db import create_annual_billing -import uuid APR_2016_MONTH_START = datetime(2016, 3, 31, 23, 00, 00) APR_2016_MONTH_END = datetime(2016, 4, 30, 22, 59, 59, 99999) @@ -268,34 +269,29 @@ def test_create_update_free_sms_fragment_limit_invalid_schema(client, sample_ser assert 'JSON' in json_resp['message'] -def test_create_free_sms_fragment_limit(client, sample_service): - - data = {'financial_year_start': 2017, 'free_sms_fragment_limit': 250} +def test_create_free_sms_fragment_limit_current_year(client, sample_service): + current_year = get_current_financial_year_start_year() + data = {'free_sms_fragment_limit': 9999} response = client.post('service/{}/billing/free-sms-fragment-limit'.format(sample_service.id), data=json.dumps(data), headers=[('Content-Type', 'application/json'), create_authorization_header()]) response_get = client.get( - 'service/{}/billing/free-sms-fragment-limit?financial_year_start=2017'.format(sample_service.id), + 'service/{}/billing/free-sms-fragment-limit?financial_year_start={}'.format(sample_service.id, current_year), headers=[('Content-Type', 'application/json'), create_authorization_header()]) json_resp = json.loads(response_get.get_data(as_text=True)) assert response.status_code == 201 assert response_get.status_code == 200 - assert json_resp['data']['financial_year_start'] == 2017 - assert json_resp['data']['free_sms_fragment_limit'] == 250 + assert json_resp['financial_year_start'] == current_year + assert json_resp['free_sms_fragment_limit'] == 9999 -def test_update_free_sms_fragment_limit(client, sample_service): +def test_create_free_sms_fragment_limit_past_year(client, sample_service): - data_old = {'financial_year_start': 2016, 'free_sms_fragment_limit': 1000} + data = {'financial_year_start': 2016, 'free_sms_fragment_limit': 9999} response = client.post('service/{}/billing/free-sms-fragment-limit'.format(sample_service.id), - data=json.dumps(data_old), - headers=[('Content-Type', 'application/json'), create_authorization_header()]) - - data_new = {'financial_year_start': 2016, 'free_sms_fragment_limit': 9999} - response = client.post('service/{}/billing/free-sms-fragment-limit'.format(sample_service.id), - data=json.dumps(data_new), + data=json.dumps(data), headers=[('Content-Type', 'application/json'), create_authorization_header()]) response_get = client.get( @@ -303,97 +299,84 @@ def test_update_free_sms_fragment_limit(client, sample_service): headers=[('Content-Type', 'application/json'), create_authorization_header()]) json_resp = json.loads(response_get.get_data(as_text=True)) - assert response.status_code == 201 assert response_get.status_code == 200 - assert json_resp['data']['financial_year_start'] == 2016 - assert json_resp['data']['free_sms_fragment_limit'] == 9999 + assert json_resp['financial_year_start'] == 2016 + assert json_resp['free_sms_fragment_limit'] == 9999 -def test_get_free_sms_fragment_limit_year_return_correct_data(client, sample_service): - years = [2016, 2017, 2018] - limits = [1000, 2000, 3000] +def test_update_free_sms_fragment_limit(client, sample_service): + current_year = get_current_financial_year_start_year() - for i in range(0, len(years)): - annual_billing = {'financial_year_start': years[i], 'free_sms_fragment_limit': limits[i]} - response = client.post('service/{}/billing/free-sms-fragment-limit'.format(sample_service.id), - data=json.dumps(annual_billing), - headers=[('Content-Type', 'application/json'), create_authorization_header()]) + annual_billing = dao_get_free_sms_fragment_limit_for_year(sample_service.id, current_year) + assert annual_billing.free_sms_fragment_limit == 250000 - for i in range(0, len(years)): - response_get = client.get( - 'service/{}/billing/free-sms-fragment-limit?financial_year_start={}'.format(sample_service.id, years[i]), - headers=[('Content-Type', 'application/json'), create_authorization_header()]) - json_resp = json.loads(response_get.get_data(as_text=True)) - assert response_get.status_code == 200 - assert json_resp['data']['free_sms_fragment_limit'] == limits[i] - - -def test_get_free_sms_fragment_limit_for_all_years(client, sample_service): - years = [2016, 2017, 2018] - limits = [1000, 2000, 3000] - - for i in range(0, len(years)): - annual_billing = {'financial_year_start': years[i], 'free_sms_fragment_limit': limits[i]} - response = client.post('service/{}/billing/free-sms-fragment-limit'.format(sample_service.id), - data=json.dumps(annual_billing), - headers=[('Content-Type', 'application/json'), create_authorization_header()]) - - response_get = client.get( - # Not specify a particular year to return all data for that service - 'service/{}/billing/free-sms-fragment-limit'.format(sample_service.id), - headers=[('Content-Type', 'application/json'), create_authorization_header()]) - json_resp = json.loads(response_get.get_data(as_text=True)) - assert response_get.status_code == 200 - assert len(json_resp['data']) == 3 - print(json_resp) - for i in [0, 1, 2]: - assert json_resp['data'][i]['free_sms_fragment_limit'] == limits[i] - assert json_resp['data'][i]['financial_year_start'] == years[i] - - -def test_get_free_sms_fragment_limit_no_year_data_return_404(client, sample_service): - - response_get = client.get( - 'service/{}/billing/free-sms-fragment-limit?financial_year_start={}'.format(sample_service.id, 1999), - headers=[('Content-Type', 'application/json'), create_authorization_header()]) - json_resp = json.loads(response_get.get_data(as_text=True)) - - assert response_get.status_code == 404 - - -def test_get_free_sms_fragment_limit_unknown_service_id_return_404(client): - - response_get = client.get( - 'service/{}/billing/free-sms-fragment-limit'.format(uuid.uuid4()), - headers=[('Content-Type', 'application/json'), create_authorization_header()]) - json_resp = json.loads(response_get.get_data(as_text=True)) - assert response_get.status_code == 404 - - -def test_get_free_sms_fragment_limit_current_year(client, sample_service): - response = client.get( - 'service/{}/billing/free-sms-fragment-limit/current-year'.format(sample_service.id, True), - headers=[('Content-Type', 'application/json'), create_authorization_header()]) - json_resp = json.loads(response.get_data(as_text=True)) - - assert response.status_code == 200 - assert json_resp['data']['free_sms_fragment_limit'] == 250000 - - -def test_post_free_sms_fragment_limit_current_year(client, sample_service): - - data_new = {'free_sms_fragment_limit': 7777} + data_new = {'financial_year_start': current_year, 'free_sms_fragment_limit': 9999} response = client.post('service/{}/billing/free-sms-fragment-limit'.format(sample_service.id), data=json.dumps(data_new), headers=[('Content-Type', 'application/json'), create_authorization_header()]) response_get = client.get( - 'service/{}/billing/free-sms-fragment-limit/current-year'.format(sample_service.id), + 'service/{}/billing/free-sms-fragment-limit?financial_year_start={}' + .format(sample_service.id, current_year), headers=[('Content-Type', 'application/json'), create_authorization_header()]) + json_resp = json.loads(response_get.get_data(as_text=True)) assert response.status_code == 201 assert response_get.status_code == 200 - assert json_resp['data']['financial_year_start'] == get_current_financial_year_start_year() - assert json_resp['data']['free_sms_fragment_limit'] == 7777 + assert json_resp['financial_year_start'] == current_year + assert json_resp['free_sms_fragment_limit'] == 9999 + + +def test_get_free_sms_fragment_limit_current_year(client, sample_service): + + current_year = get_current_financial_year_start_year() + create_annual_billing(sample_service.id, free_sms_fragment_limit=9999, financial_year_start=current_year - 1) + + response_get = client.get( + 'service/{}/billing/free-sms-fragment-limit'.format(sample_service.id), + headers=[('Content-Type', 'application/json'), create_authorization_header()]) + + json_resp = json.loads(response_get.get_data(as_text=True)) + assert response_get.status_code == 200 + assert json_resp['financial_year_start'] == get_current_financial_year_start_year() + assert json_resp['free_sms_fragment_limit'] == 250000 + + +def test_get_free_sms_fragment_limit_past_year_not_exist(client, sample_service): + current_year = get_current_financial_year_start_year() + create_annual_billing(sample_service.id, 9999, current_year - 1) + create_annual_billing(sample_service.id, 10000, current_year + 1) + + annual_billing = dao_get_free_sms_fragment_limit_for_year(sample_service.id, current_year - 2) + assert annual_billing is None + + res_get = client.get( + 'service/{}/billing/free-sms-fragment-limit?financial_year_start={}' + .format(sample_service.id, current_year - 2), + headers=[('Content-Type', 'application/json'), create_authorization_header()]) + json_resp = json.loads(res_get.get_data(as_text=True)) + + assert res_get.status_code == 200 + assert json_resp['financial_year_start'] == current_year - 1 + assert json_resp['free_sms_fragment_limit'] == 9999 + + +def test_get_free_sms_fragment_limit_future_year_not_exist(client, sample_service): + current_year = get_current_financial_year_start_year() + create_annual_billing(sample_service.id, free_sms_fragment_limit=9999, financial_year_start=current_year - 1) + create_annual_billing(sample_service.id, free_sms_fragment_limit=10000, financial_year_start=current_year + 1) + + annual_billing = dao_get_free_sms_fragment_limit_for_year(sample_service.id, current_year + 2) + assert annual_billing is None + + res_get = client.get( + 'service/{}/billing/free-sms-fragment-limit?financial_year_start={}' + .format(sample_service.id, current_year + 2), + headers=[('Content-Type', 'application/json'), create_authorization_header()]) + json_resp = json.loads(res_get.get_data(as_text=True)) + + assert res_get.status_code == 200 + assert json_resp['financial_year_start'] == current_year + 2 + assert json_resp['free_sms_fragment_limit'] == 10000 diff --git a/tests/app/dao/test_annual_billing_dao.py b/tests/app/dao/test_annual_billing_dao.py index 10c6cd201..3e475ef5c 100644 --- a/tests/app/dao/test_annual_billing_dao.py +++ b/tests/app/dao/test_annual_billing_dao.py @@ -1,10 +1,11 @@ -from app.service.utils import get_current_financial_year_start_year -from app.models import AnnualBilling +from app.dao.date_util import get_current_financial_year_start_year + from app.dao.annual_billing_dao import ( dao_create_or_update_annual_billing_for_year, dao_get_free_sms_fragment_limit_for_year, - dao_get_annual_billing + dao_update_annual_billing_for_current_and_future_years, ) +from tests.app.db import create_annual_billing def test_get_sample_service_has_default_free_sms_fragment_limit(notify_db_session, sample_service): @@ -18,40 +19,44 @@ def test_get_sample_service_has_default_free_sms_fragment_limit(notify_db_sessio def test_dao_update_free_sms_fragment_limit(notify_db_session, sample_service): - year = 1999 - old_limit = 1000 new_limit = 9999 - - data = AnnualBilling( - free_sms_fragment_limit=old_limit, - financial_year_start=year, - service_id=sample_service.id, - ) - - dao_create_or_update_annual_billing_for_year(data) - data.free_sms_fragment_limit = new_limit - dao_create_or_update_annual_billing_for_year(data) + year = get_current_financial_year_start_year() + dao_create_or_update_annual_billing_for_year(sample_service.id, new_limit, year) 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 -def test_create_then_get_annual_billing(notify_db_session, sample_service): - years = [1999, 2001] - limits = [1000, 2000] +def test_create_annual_billing_not_specify_year(notify_db_session, sample_service): - for i in [0, 1]: - data = AnnualBilling( - free_sms_fragment_limit=limits[i], - financial_year_start=years[i], - service_id=sample_service.id, - ) - dao_create_or_update_annual_billing_for_year(data) + dao_create_or_update_annual_billing_for_year(sample_service.id, 9999) - free_limit = dao_get_annual_billing(sample_service.id) - assert len(free_limit) == 3 # sample service already has one entry - assert free_limit[0].free_sms_fragment_limit == 1000 - assert free_limit[0].financial_year_start == 1999 - assert free_limit[0].service_id == sample_service.id - assert free_limit[1].free_sms_fragment_limit == 2000 - assert free_limit[1].financial_year_start == 2001 + free_limit = dao_get_free_sms_fragment_limit_for_year(sample_service.id) + + assert free_limit.free_sms_fragment_limit == 9999 + + +def test_create_annual_billing_specify_year(notify_db_session, sample_service): + + dao_create_or_update_annual_billing_for_year(sample_service.id, 9999, 2016) + + free_limit = dao_get_free_sms_fragment_limit_for_year(sample_service.id, 2016) + + assert free_limit.free_sms_fragment_limit == 9999 + + +def test_dao_update_annual_billing_for_current_and_future_years(notify_db_session, sample_service): + current_year = get_current_financial_year_start_year() + limits = [240000, 250000, 260000, 270000] + create_annual_billing(sample_service.id, limits[0], current_year - 1) + create_annual_billing(sample_service.id, limits[2], current_year + 1) + create_annual_billing(sample_service.id, limits[3], current_year + 2) + + dao_update_annual_billing_for_current_and_future_years(sample_service.id, 9999, current_year) + + free_limit = dao_get_free_sms_fragment_limit_for_year(sample_service.id, current_year - 1) + assert free_limit.free_sms_fragment_limit == 240000 + + for year in range(current_year, current_year + 3): + free_limit = dao_get_free_sms_fragment_limit_for_year(sample_service.id, year) + assert free_limit.free_sms_fragment_limit == 9999 diff --git a/tests/app/db.py b/tests/app/db.py index 4be3a3799..da401b209 100644 --- a/tests/app/db.py +++ b/tests/app/db.py @@ -26,7 +26,8 @@ from app.models import ( EMAIL_TYPE, SMS_TYPE, INBOUND_SMS_TYPE, - KEY_TYPE_NORMAL + KEY_TYPE_NORMAL, + AnnualBilling, ) from app.dao.users_dao import save_model_user from app.dao.notifications_dao import ( @@ -415,3 +416,17 @@ def create_reply_to_email_for_notification( db.session.commit() return reply_to + + +def create_annual_billing( + service_id, free_sms_fragment_limit, financial_year_start +): + annual_billing = AnnualBilling( + service_id=service_id, + free_sms_fragment_limit=free_sms_fragment_limit, + financial_year_start=financial_year_start + ) + db.session.add(annual_billing) + db.session.commit() + + return annual_billing diff --git a/tests/app/service/test_rest.py b/tests/app/service/test_rest.py index e317f7a24..b281e133b 100644 --- a/tests/app/service/test_rest.py +++ b/tests/app/service/test_rest.py @@ -37,7 +37,7 @@ from tests.app.db import ( create_service_sms_sender ) from tests.app.db import create_user -from app.service.utils import get_current_financial_year_start_year +from app.dao.date_util import get_current_financial_year_start_year def test_get_service_list(client, service_factory): @@ -374,9 +374,9 @@ def test_create_service_free_sms_fragment_limit_is_optional(client, sample_user) .format(service_id, get_current_financial_year_start_year()), headers=[('Content-Type', 'application/json'), create_authorization_header()]) json_resp = json.loads(annual_billing.get_data(as_text=True)) - assert json_resp['data']['free_sms_fragment_limit'] == 9999 + assert json_resp['free_sms_fragment_limit'] == 9999 # TODO: Remove this after the new data is used - assert json_resp['data']['free_sms_fragment_limit'] == 9999 + assert json_resp['free_sms_fragment_limit'] == 9999 data2 = { 'name': 'service 2', @@ -402,9 +402,9 @@ def test_create_service_free_sms_fragment_limit_is_optional(client, sample_user) .format(service_id, get_current_financial_year_start_year()), headers=[('Content-Type', 'application/json'), create_authorization_header()]) json_resp = json.loads(annual_billing.get_data(as_text=True)) - assert json_resp['data']['free_sms_fragment_limit'] == current_app.config['FREE_SMS_TIER_FRAGMENT_COUNT'] + assert json_resp['free_sms_fragment_limit'] == current_app.config['FREE_SMS_TIER_FRAGMENT_COUNT'] # TODO: Remove this after the new data is used - assert json_resp['data']['free_sms_fragment_limit'] == current_app.config['FREE_SMS_TIER_FRAGMENT_COUNT'] + assert json_resp['free_sms_fragment_limit'] == current_app.config['FREE_SMS_TIER_FRAGMENT_COUNT'] def test_should_error_if_created_by_missing(notify_api, sample_user): diff --git a/tests/app/service/test_utils.py b/tests/app/service/test_utils.py index 4d59af22b..71b2770bb 100644 --- a/tests/app/service/test_utils.py +++ b/tests/app/service/test_utils.py @@ -1,4 +1,4 @@ -from app.service.utils import get_current_financial_year_start_year +from app.dao.date_util import get_current_financial_year_start_year from freezegun import freeze_time