Remove get yearly usage endpoint

This commit is contained in:
Imdad Ahad
2017-08-30 14:37:27 +01:00
parent 5c25b12b0f
commit 9478af0941
2 changed files with 0 additions and 63 deletions
-19
View File
@@ -458,25 +458,6 @@ def get_monthly_template_stats(service_id):
raise InvalidRequest('Year must be a number', status_code=400)
@service_blueprint.route('/<uuid:service_id>/yearly-usage')
def get_yearly_billing_usage(service_id):
try:
year = int(request.args.get('year'))
results = notification_usage_dao.get_yearly_billing_data(service_id, year)
json_result = [{
"credits": x[0],
"billing_units": x[1],
"rate_multiplier": x[2],
"notification_type": x[3],
"international": x[4],
"rate": x[5]
} for x in results]
return json.dumps(json_result)
except TypeError:
return jsonify(result='error', message='No valid year provided'), 400
@service_blueprint.route('/<uuid:service_id>/monthly-usage')
def get_yearly_monthly_usage(service_id):
try:
-44
View File
@@ -1730,50 +1730,6 @@ def test_get_template_stats_by_month_returns_error_for_incorrect_year(
assert json.loads(response.get_data(as_text=True)) == expected_json
def test_get_yearly_billing_usage(client, notify_db, notify_db_session, sample_service):
rate = Rate(id=uuid.uuid4(), valid_from=datetime(2016, 3, 31, 23, 00), rate=0.0158, notification_type=SMS_TYPE)
notify_db.session.add(rate)
after_rate_created = datetime(2016, 6, 5)
notification = create_sample_notification(
notify_db,
notify_db_session,
created_at=after_rate_created,
sent_at=after_rate_created,
status='sending',
service=sample_service
)
create_or_update_monthly_billing(sample_service.id, after_rate_created)
response = client.get(
'/service/{}/yearly-usage?year=2016'.format(notification.service_id),
headers=[create_authorization_header()]
)
assert response.status_code == 200
assert json.loads(response.get_data(as_text=True)) == [{'credits': 1,
'billing_units': 1,
'rate_multiplier': 1,
'notification_type': SMS_TYPE,
'international': False,
'rate': 0.0158},
{'credits': 0,
'billing_units': 0,
'rate_multiplier': 1,
'notification_type': EMAIL_TYPE,
'international': False,
'rate': 0}]
def test_get_yearly_billing_usage_returns_400_if_missing_year(client, sample_service):
response = client.get(
'/service/{}/yearly-usage'.format(sample_service.id),
headers=[create_authorization_header()]
)
assert response.status_code == 400
assert json.loads(response.get_data(as_text=True)) == {
'message': 'No valid year provided', 'result': 'error'
}
def test_get_monthly_billing_usage(client, notify_db, notify_db_session, sample_service):
rate = Rate(id=uuid.uuid4(), valid_from=datetime(2016, 3, 31, 23, 00), rate=0.0158, notification_type=SMS_TYPE)
notify_db.session.add(rate)