mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-21 07:51:13 -05:00
added a new end point current-year and tests
This commit is contained in:
@@ -18,6 +18,7 @@ from app.billing.billing_schemas import create_or_update_free_sms_fragment_limit
|
|||||||
from app.errors import InvalidRequest
|
from app.errors import InvalidRequest
|
||||||
from app.schema_validation import validate
|
from app.schema_validation import validate
|
||||||
from app.models import AnnualBilling
|
from app.models import AnnualBilling
|
||||||
|
from app.service.utils import get_current_financial_year_start_year
|
||||||
|
|
||||||
billing_blueprint = Blueprint(
|
billing_blueprint = Blueprint(
|
||||||
'billing',
|
'billing',
|
||||||
@@ -96,10 +97,14 @@ def _transform_billing_for_month(billing_for_month):
|
|||||||
|
|
||||||
|
|
||||||
@billing_blueprint.route('/free-sms-fragment-limit', methods=["GET"])
|
@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):
|
def get_free_sms_fragment_limit(service_id):
|
||||||
|
|
||||||
financial_year_start = request.args.get('financial_year_start')
|
financial_year_start = request.args.get('financial_year_start')
|
||||||
|
|
||||||
|
if request.path.split('/')[-1] == 'current-year':
|
||||||
|
financial_year_start = get_current_financial_year_start_year()
|
||||||
|
|
||||||
if financial_year_start is None:
|
if financial_year_start is None:
|
||||||
results = dao_get_all_free_sms_fragment_limit(service_id)
|
results = dao_get_all_free_sms_fragment_limit(service_id)
|
||||||
|
|
||||||
|
|||||||
@@ -369,3 +369,12 @@ def test_get_free_sms_fragment_limit_unknown_service_id_return_404(client):
|
|||||||
headers=[('Content-Type', 'application/json'), create_authorization_header()])
|
headers=[('Content-Type', 'application/json'), create_authorization_header()])
|
||||||
json_resp = json.loads(response_get.get_data(as_text=True))
|
json_resp = json.loads(response_get.get_data(as_text=True))
|
||||||
assert response_get.status_code == 404
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user