mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-02 17:31:14 -05:00
remove unused codes
This commit is contained in:
@@ -11,7 +11,7 @@ from app.service.utils import get_current_financial_year_start_year
|
|||||||
def dao_get_annual_billing(service_id):
|
def dao_get_annual_billing(service_id):
|
||||||
return AnnualBilling.query.filter_by(
|
return AnnualBilling.query.filter_by(
|
||||||
service_id=service_id,
|
service_id=service_id,
|
||||||
).all()
|
).order_by(AnnualBilling.financial_year_start).all()
|
||||||
|
|
||||||
|
|
||||||
def dao_create_or_update_annual_billing_for_year(annual_billing):
|
def dao_create_or_update_annual_billing_for_year(annual_billing):
|
||||||
@@ -31,7 +31,7 @@ def dao_get_all_free_sms_fragment_limit(service_id):
|
|||||||
|
|
||||||
return AnnualBilling.query.filter_by(
|
return AnnualBilling.query.filter_by(
|
||||||
service_id=service_id,
|
service_id=service_id,
|
||||||
).all()
|
).order_by(AnnualBilling.financial_year_start).all()
|
||||||
|
|
||||||
|
|
||||||
def insert_annual_billing(service):
|
def insert_annual_billing(service):
|
||||||
|
|||||||
@@ -98,7 +98,6 @@ from app.schemas import (
|
|||||||
detailed_service_schema
|
detailed_service_schema
|
||||||
)
|
)
|
||||||
from app.utils import pagination_links
|
from app.utils import pagination_links
|
||||||
from app.dao.notifications_dao import get_financial_year
|
|
||||||
|
|
||||||
service_blueprint = Blueprint('service', __name__)
|
service_blueprint = Blueprint('service', __name__)
|
||||||
|
|
||||||
@@ -170,8 +169,6 @@ def create_service():
|
|||||||
raise InvalidRequest(errors, status_code=400)
|
raise InvalidRequest(errors, status_code=400)
|
||||||
|
|
||||||
# TODO: to be removed when front-end is updated
|
# TODO: to be removed when front-end is updated
|
||||||
# if 'free_sms_fragment_limit' not in data:
|
|
||||||
# data['free_sms_fragment_limit'] = current_app.config['FREE_SMS_TIER_FRAGMENT_COUNT']
|
|
||||||
|
|
||||||
# validate json with marshmallow
|
# validate json with marshmallow
|
||||||
service_schema.load(request.get_json())
|
service_schema.load(request.get_json())
|
||||||
|
|||||||
@@ -256,46 +256,6 @@ def test_transform_billing_calculates_with_different_rate_multipliers(sample_ser
|
|||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
def test_get_free_sms_fragment_limit(client, sample_service):
|
|
||||||
years = [2016, 2017, 2018]
|
|
||||||
sms_allowance = [1000, 2000, 3000]
|
|
||||||
|
|
||||||
for i in range(0, len(years)):
|
|
||||||
y = years[i]
|
|
||||||
sms_l = sms_allowance[i]
|
|
||||||
annual_billing = dao_get_free_sms_fragment_limit_for_year(sample_service.id, years[i])
|
|
||||||
if annual_billing:
|
|
||||||
annual_billing.free_sms_fragment_limit = sms_allowance[i]
|
|
||||||
else:
|
|
||||||
annual_billing = AnnualBilling(service_id=sample_service.id,
|
|
||||||
financial_year_start=years[i],
|
|
||||||
free_sms_fragment_limit=sms_allowance[i])
|
|
||||||
|
|
||||||
dao_create_or_update_annual_billing_for_year(annual_billing)
|
|
||||||
|
|
||||||
response = client.get('service/{}/billing/free-sms-fragment-limit?financial_year_start=2017'
|
|
||||||
.format(sample_service.id),
|
|
||||||
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'] == 2000
|
|
||||||
assert json_resp['data']['financial_year_start'] == 2017
|
|
||||||
|
|
||||||
response = 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_data(as_text=True))
|
|
||||||
|
|
||||||
assert len(json_resp['data']) == 3
|
|
||||||
assert response.status_code == 200
|
|
||||||
for i in range(0, len(years)):
|
|
||||||
assert json_resp['data'][i]['free_sms_fragment_limit'] == sms_allowance[i]
|
|
||||||
assert json_resp['data'][i]['financial_year_start'] == years[i]
|
|
||||||
|
|
||||||
|
|
||||||
def test_create_update_free_sms_fragment_limit_invalid_schema(client, sample_service):
|
def test_create_update_free_sms_fragment_limit_invalid_schema(client, sample_service):
|
||||||
|
|
||||||
response = client.post('service/{}/billing/free-sms-fragment-limit'.format(sample_service.id),
|
response = client.post('service/{}/billing/free-sms-fragment-limit'.format(sample_service.id),
|
||||||
@@ -385,6 +345,17 @@ def test_get_free_sms_fragment_limit_for_all_years(client, sample_service):
|
|||||||
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 == 200
|
assert response_get.status_code == 200
|
||||||
assert len(json_resp['data']) == 3
|
assert len(json_resp['data']) == 3
|
||||||
|
print(json_resp)
|
||||||
for i in [0, 1, 2]:
|
for i in [0, 1, 2]:
|
||||||
assert json_resp['data'][i]['free_sms_fragment_limit'] == limits[i]
|
assert json_resp['data'][i]['free_sms_fragment_limit'] == limits[i]
|
||||||
assert json_resp['data'][i]['financial_year_start'] == years[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
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ from app.dao.annual_billing_dao import (
|
|||||||
|
|
||||||
def test_sample_service_has_free_sms_fragment_limit(notify_db_session, sample_service):
|
def test_sample_service_has_free_sms_fragment_limit(notify_db_session, sample_service):
|
||||||
|
|
||||||
|
# when sample_service was created, it automatically create an entry in the annual_billing table
|
||||||
free_limit = dao_get_free_sms_fragment_limit_for_year(sample_service.id, get_current_financial_year_start_year())
|
free_limit = dao_get_free_sms_fragment_limit_for_year(sample_service.id, get_current_financial_year_start_year())
|
||||||
|
|
||||||
assert free_limit.free_sms_fragment_limit == 250000
|
assert free_limit.free_sms_fragment_limit == 250000
|
||||||
@@ -16,7 +17,7 @@ def test_sample_service_has_free_sms_fragment_limit(notify_db_session, sample_se
|
|||||||
|
|
||||||
|
|
||||||
def test_dao_update_free_sms_fragment_limit(notify_db_session, sample_service):
|
def test_dao_update_free_sms_fragment_limit(notify_db_session, sample_service):
|
||||||
year = 2016
|
year = 1999
|
||||||
old_limit = 1000
|
old_limit = 1000
|
||||||
new_limit = 9999
|
new_limit = 9999
|
||||||
|
|
||||||
|
|||||||
@@ -171,8 +171,7 @@ def test_should_remove_user_from_service(sample_user):
|
|||||||
email_from="email_from",
|
email_from="email_from",
|
||||||
message_limit=1000,
|
message_limit=1000,
|
||||||
restricted=False,
|
restricted=False,
|
||||||
created_by=sample_user,
|
created_by=sample_user)
|
||||||
free_sms_fragment_limit=9999)
|
|
||||||
dao_create_service(service, sample_user)
|
dao_create_service(service, sample_user)
|
||||||
new_user = User(
|
new_user = User(
|
||||||
name='Test User',
|
name='Test User',
|
||||||
|
|||||||
@@ -68,7 +68,6 @@ def create_service(
|
|||||||
service = Service(
|
service = Service(
|
||||||
name=service_name,
|
name=service_name,
|
||||||
message_limit=1000,
|
message_limit=1000,
|
||||||
free_sms_fragment_limit=7777,
|
|
||||||
restricted=restricted,
|
restricted=restricted,
|
||||||
email_from=email_from if email_from else service_name.lower().replace(' ', '.'),
|
email_from=email_from if email_from else service_name.lower().replace(' ', '.'),
|
||||||
created_by=user or create_user(email='{}@digital.cabinet-office.gov.uk'.format(uuid.uuid4())),
|
created_by=user or create_user(email='{}@digital.cabinet-office.gov.uk'.format(uuid.uuid4())),
|
||||||
|
|||||||
Reference in New Issue
Block a user