mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 00:11:16 -05:00
Update name of method to clarify the meaning.
Update group by to use label. Update test.
This commit is contained in:
@@ -20,7 +20,7 @@ from app.models import (
|
||||
from app.utils import convert_utc_to_bst, convert_bst_to_utc
|
||||
|
||||
|
||||
def fetch_annual_billing_for_year(service_id, year):
|
||||
def fetch_montly_billing_for_year(service_id, year):
|
||||
year_start_date, year_end_date = get_financial_year(year)
|
||||
utcnow = datetime.utcnow()
|
||||
today = convert_utc_to_bst(utcnow).date()
|
||||
@@ -45,7 +45,7 @@ def fetch_annual_billing_for_year(service_id, year):
|
||||
FactBilling.bst_date >= year_start_date,
|
||||
FactBilling.bst_date <= year_end_date
|
||||
).group_by(
|
||||
extract('month', FactBilling.bst_date),
|
||||
'Month',
|
||||
FactBilling.service_id,
|
||||
FactBilling.rate,
|
||||
FactBilling.rate_multiplier,
|
||||
|
||||
@@ -5,7 +5,7 @@ from freezegun import freeze_time
|
||||
|
||||
from app import db
|
||||
from app.dao.fact_billing_dao import (
|
||||
fetch_annual_billing_for_year, fetch_billing_data_for_day, get_rates_for_billing,
|
||||
fetch_montly_billing_for_year, fetch_billing_data_for_day, get_rates_for_billing,
|
||||
get_rate
|
||||
)
|
||||
from app.models import FactBilling
|
||||
@@ -23,11 +23,15 @@ from tests.app.db import (
|
||||
def test_fetch_billing_data_for_today_includes_data_with_the_right_status(notify_db_session):
|
||||
service = create_service()
|
||||
template = create_template(service=service, template_type="email")
|
||||
for status in ['delivered', 'sending', 'temporary-failure', 'created', 'technical-failure']:
|
||||
for status in ['created', 'technical-failure']:
|
||||
create_notification(template=template, status=status)
|
||||
|
||||
today = convert_utc_to_bst(datetime.utcnow())
|
||||
results = fetch_billing_data_for_day(today)
|
||||
assert results == []
|
||||
for status in ['delivered', 'sending', 'temporary-failure']:
|
||||
create_notification(template=template, status=status)
|
||||
results = fetch_billing_data_for_day(today)
|
||||
assert len(results) == 1
|
||||
assert results[0].notifications_sent == 3
|
||||
|
||||
@@ -193,8 +197,7 @@ def test_fetch_annual_billing_for_year(notify_db_session):
|
||||
notification_type='sms',
|
||||
rate=0.158)
|
||||
|
||||
results = fetch_annual_billing_for_year(service_id=service.id,
|
||||
year=2018)
|
||||
results = fetch_montly_billing_for_year(service_id=service.id, year=2018)
|
||||
|
||||
assert len(results) == 2
|
||||
assert results[0][0] == 6.0
|
||||
@@ -227,7 +230,7 @@ def test_fetch_annual_billing_for_year_adds_data_for_today(notify_db_session):
|
||||
create_notification(template=template, status='delivered')
|
||||
|
||||
assert db.session.query(FactBilling.bst_date).count() == 31
|
||||
results = fetch_annual_billing_for_year(service_id=service.id,
|
||||
results = fetch_montly_billing_for_year(service_id=service.id,
|
||||
year=2018)
|
||||
assert db.session.query(FactBilling.bst_date).count() == 32
|
||||
assert len(results) == 2
|
||||
|
||||
Reference in New Issue
Block a user