mirror of
https://github.com/GSA/notifications-api.git
synced 2026-07-13 09:50:39 -04:00
Merge pull request #2426 from alphagov/fix-platfom-admin-bug
Fix BST date bug for platform admin summary page.
This commit is contained in:
@@ -174,7 +174,7 @@ def fetch_notification_status_totals_for_all_services(start_date, end_date):
|
||||
FactNotificationStatus.key_type,
|
||||
)
|
||||
today = get_london_midnight_in_utc(datetime.utcnow())
|
||||
if start_date <= today.date() <= end_date:
|
||||
if start_date <= datetime.utcnow().date() <= end_date:
|
||||
stats_for_today = db.session.query(
|
||||
Notification.notification_type.cast(db.Text).label('notification_type'),
|
||||
Notification.status,
|
||||
|
||||
@@ -3,6 +3,7 @@ from datetime import datetime, timedelta
|
||||
import json
|
||||
|
||||
import pytest
|
||||
from freezegun import freeze_time
|
||||
|
||||
from app.models import FactBilling
|
||||
from app.dao.date_util import get_current_financial_year_start_year, get_month_start_and_end_date_in_utc
|
||||
@@ -156,6 +157,7 @@ def test_update_free_sms_fragment_limit_data(client, sample_service):
|
||||
assert annual_billing.free_sms_fragment_limit == 9999
|
||||
|
||||
|
||||
@freeze_time('2018-04-21 14:00')
|
||||
def test_get_yearly_usage_by_monthly_from_ft_billing_populates_deltas(client, notify_db_session):
|
||||
service = create_service()
|
||||
sms_template = create_template(service=service, template_type="sms")
|
||||
|
||||
@@ -319,6 +319,41 @@ def test_fetch_notification_status_totals_for_all_services(
|
||||
assert results[3].count == expected_sms
|
||||
|
||||
|
||||
@freeze_time('2018-04-21 14:00')
|
||||
def test_fetch_notification_status_totals_for_all_services_works_in_bst(
|
||||
notify_db_session
|
||||
):
|
||||
service_1 = create_service(service_name='service_1')
|
||||
sms_template = create_template(service=service_1, template_type=SMS_TYPE)
|
||||
email_template = create_template(service=service_1, template_type=EMAIL_TYPE)
|
||||
|
||||
create_notification(sms_template, created_at=datetime(2018, 4, 20, 12, 0, 0), status='delivered')
|
||||
create_notification(sms_template, created_at=datetime(2018, 4, 21, 11, 0, 0), status='created')
|
||||
create_notification(sms_template, created_at=datetime(2018, 4, 21, 12, 0, 0), status='delivered')
|
||||
create_notification(email_template, created_at=datetime(2018, 4, 21, 13, 0, 0), status='delivered')
|
||||
create_notification(email_template, created_at=datetime(2018, 4, 21, 14, 0, 0), status='delivered')
|
||||
|
||||
results = sorted(
|
||||
fetch_notification_status_totals_for_all_services(
|
||||
start_date=date(2018, 4, 21), end_date=date(2018, 4, 21)),
|
||||
key=lambda x: (x.notification_type, x.status)
|
||||
)
|
||||
|
||||
assert len(results) == 3
|
||||
|
||||
assert results[0].notification_type == 'email'
|
||||
assert results[0].status == 'delivered'
|
||||
assert results[0].count == 2
|
||||
|
||||
assert results[1].notification_type == 'sms'
|
||||
assert results[1].status == 'created'
|
||||
assert results[1].count == 1
|
||||
|
||||
assert results[2].notification_type == 'sms'
|
||||
assert results[2].status == 'delivered'
|
||||
assert results[2].count == 1
|
||||
|
||||
|
||||
def set_up_data():
|
||||
service_2 = create_service(service_name='service_2')
|
||||
create_template(service=service_2, template_type=LETTER_TYPE)
|
||||
|
||||
Reference in New Issue
Block a user