mirror of
https://github.com/GSA/notifications-api.git
synced 2026-01-04 17:53:57 -05:00
The performance platform is going away soon. The only stat that we do not have in our database is the processing time. Let me clarify the only statistic we don't have in our database that we can query efficiently is the processing time. Any queries on notification_history are too inefficient to use on a web page. Processing time = the total number of normal/team emails and text messages plus the number of messages that have gone from created to sending within 10 seconds per whole day. We can then easily calculate the percentage of messages that were marked as sending under 10 seconds.
30 lines
1.6 KiB
Python
30 lines
1.6 KiB
Python
from datetime import datetime
|
|
|
|
from app.commands import backfill_performance_platform_totals, backfill_processing_time
|
|
|
|
|
|
def test_backfill_processing_time_works_for_correct_dates(mocker, notify_api):
|
|
send_mock = mocker.patch('app.commands.send_processing_time_for_start_and_end')
|
|
|
|
# backfill_processing_time is a click.Command object - if you try invoking the callback on its own, it
|
|
# throws a `RuntimeError: There is no active click context.` - so get at the original function using __wrapped__
|
|
backfill_processing_time.callback.__wrapped__(datetime(2017, 8, 1), datetime(2017, 8, 3))
|
|
|
|
assert send_mock.call_count == 3
|
|
send_mock.assert_any_call(datetime(2017, 7, 31, 23, 0), datetime(2017, 8, 1, 23, 0), datetime(2017, 8, 2, 0, 0))
|
|
send_mock.assert_any_call(datetime(2017, 8, 1, 23, 0), datetime(2017, 8, 2, 23, 0), datetime(2017, 8, 3, 0, 0))
|
|
send_mock.assert_any_call(datetime(2017, 8, 2, 23, 0), datetime(2017, 8, 3, 23, 0), datetime(2017, 8, 4, 0, 0))
|
|
|
|
|
|
def test_backfill_totals_works_for_correct_dates(mocker, notify_api):
|
|
send_mock = mocker.patch('app.commands.send_total_sent_notifications_to_performance_platform')
|
|
|
|
# backfill_processing_time is a click.Command object - if you try invoking the callback on its own, it
|
|
# throws a `RuntimeError: There is no active click context.` - so get at the original function using __wrapped__
|
|
backfill_performance_platform_totals.callback.__wrapped__(datetime(2017, 8, 1), datetime(2017, 8, 3))
|
|
|
|
assert send_mock.call_count == 3
|
|
send_mock.assert_any_call(datetime(2017, 8, 1))
|
|
send_mock.assert_any_call(datetime(2017, 8, 2))
|
|
send_mock.assert_any_call(datetime(2017, 8, 3))
|