From ca135e32e8bcbaee6e28f73bd63e2979f3d376a3 Mon Sep 17 00:00:00 2001 From: stvnrlly Date: Mon, 28 Nov 2022 14:01:51 -0500 Subject: [PATCH] fix last test --- app/main/views/performance.py | 7 ++++--- tests/app/main/views/test_performance.py | 25 +++++++++++++++--------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/app/main/views/performance.py b/app/main/views/performance.py index a3948742c..a7e44fc75 100644 --- a/app/main/views/performance.py +++ b/app/main/views/performance.py @@ -2,8 +2,9 @@ from datetime import datetime, timedelta from itertools import groupby from operator import itemgetter from statistics import mean +import pytz -from flask import render_template +from flask import current_app, render_template from notifications_utils.timezones import convert_utc_to_local_timezone from app import performance_dashboard_api_client, status_api_client @@ -13,8 +14,8 @@ from app.main import main @main.route("/performance") def performance(): stats = performance_dashboard_api_client.get_performance_dashboard_stats( - start_date=(convert_utc_to_local_timezone(datetime.utcnow()) - timedelta(days=7)).date(), - end_date=convert_utc_to_local_timezone(datetime.utcnow()).date(), + start_date=(datetime.now(pytz.timezone(current_app.config['TIMEZONE'])) - timedelta(days=7)).date(), + end_date=datetime.now(pytz.timezone(current_app.config['TIMEZONE'])).date(), ) stats['organisations_using_notify'] = sorted( [ diff --git a/tests/app/main/views/test_performance.py b/tests/app/main/views/test_performance.py index 12552e5d5..4565482bd 100644 --- a/tests/app/main/views/test_performance.py +++ b/tests/app/main/views/test_performance.py @@ -6,6 +6,13 @@ from freezegun import freeze_time from tests.conftest import normalize_spaces +# E AssertionError: assert ('Performance data Messages sent since May 2016 1.8 billion total 1.1 billion '\n 'emails 987.7 million text messages 1.2 million letters Messages sent since '\n 'May 2016 Date Emails Text messages Letters 26 February 2021 1 2 3 25 '\n 'February 2021 1 2 3 24 February 2021 1 2 3 23 February 2021 1 2 3 22 '\n 'February 2021 1 2 3 21 February 2021 1 2 3 20 February 2021 1,234,567 '\n '123,456 123 Only showing the last 7 days Messages sent within 10 seconds '\n '98.31% on average Messages sent within 10 seconds Date Percentage 26 '\n 'February 2021 98.60% 25 February 2021 100.00% 24 February 2021 99.99% 23 '\n 'February 2021 100.00% 22 February 2021 95.00% 21 February 2021 95.30% 20 '\n 'February 2021 99.25% Only showing the last 7 days Organisations using Notify '\n 'There are 111 organisations and 9,999 services using Notify. Organisations '\n 'using Notify Organisation Number of live services Department of Examples and '\n 'Patterns 2 Department of One Service 1 No organisation 1') == ('Performance data Messages sent since May 2016 1.8 billion total 1.1 billion '\n 'emails 987.7 million text messages 1.2 million letters Messages sent since '\n 'May 2016 Date Emails Text messages Letters 27 February 2021 1 2 3 26 '\n 'February 2021 1 2 3 25 February 2021 1 2 3 24 February 2021 1 2 3 23 '\n 'February 2021 1 2 3 22 February 2021 1 2 3 21 February 2021 1,234,567 '\n '123,456 123 Only showing the last 7 days Messages sent within 10 seconds '\n '98.31% on average Messages sent within 10 seconds Date Percentage 27 '\n 'February 2021 98.60% 26 February 2021 100.00% 25 February 2021 99.99% 24 '\n 'February 2021 100.00% 23 February 2021 95.00% 22 February 2021 95.30% 21 '\n 'February 2021 99.25% Only showing the last 7 days Organisations using Notify '\n 'There are 111 organisations and 9,999 services using Notify. Organisations '\n 'using Notify Organisation Number of live services Department of Examples and '\n 'Patterns 2 Department of One Service 1 No organisation 1') +# E - Performance data Messages sent since May 2016 1.8 billion total 1.1 billion emails 987.7 million text messages 1.2 million letters Messages sent since May 2016 Date Emails Text messages Letters 27 February 2021 1 2 3 26 February 2021 1 2 3 25 February 2021 1 2 3 24 February 2021 1 2 3 23 February 2021 1 2 3 22 February 2021 1 2 3 21 February 2021 1,234,567 123,456 123 Only showing the last 7 days Messages sent within 10 seconds 98.31% on average Messages sent within 10 seconds Date Percentage 27 February 2021 98.60% 26 February 2021 100.00% 25 February 2021 99.99% 24 February 2021 100.00% 23 February 2021 95.00% 22 February 2021 95.30% 21 February 2021 99.25% Only showing the last 7 days Organisations using Notify There are 111 organisations and 9,999 services using Notify. Organisations using Notify Organisation Number of live services Department of Examples and Patterns 2 Department of One Service 1 No organisation 1 +# E ? ----------------------- ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +# E + Performance data Messages sent since May 2016 1.8 billion total 1.1 billion emails 987.7 million text messages 1.2 million letters Messages sent since May 2016 Date Emails Text messages Letters 26 February 2021 1 2 3 25 February 2021 1 2 3 24 February 2021 1 2 3 23 February 2021 1 2 3 22 February 2021 1 2 3 21 February 2021 1 2 3 20 February 2021 1,234,567 123,456 123 Only showing the last 7 days Messages sent within 10 seconds 98.31% on average Messages sent within 10 seconds Date Percentage 26 February 2021 98.60% 25 February 2021 100.00% 24 February 2021 99.99% 23 February 2021 100.00% 22 February 2021 95.00% 21 February 2021 95.30% 20 February 2021 99.25% Only showing the last 7 days Organisations using Notify There are 111 organisations and 9,999 services using Notify. Organisations using Notify Organisation Number of live services Department of Examples and Patterns 2 Department of One Service 1 No organisation 1 +# E ? +++++++++++++++++++++++ ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ^^^ ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^ + + def _get_example_performance_data(): return { @@ -132,13 +139,13 @@ def test_should_render_performance_page( '' 'Messages sent since May 2016 ' 'Date Emails Text messages Letters ' - '27 February 2021 1 2 3 ' '26 February 2021 1 2 3 ' '25 February 2021 1 2 3 ' '24 February 2021 1 2 3 ' '23 February 2021 1 2 3 ' '22 February 2021 1 2 3 ' - '21 February 2021 1,234,567 123,456 123 ' + '21 February 2021 1 2 3 ' + '20 February 2021 1,234,567 123,456 123 ' 'Only showing the last 7 days ' @@ -147,13 +154,13 @@ def test_should_render_performance_page( '98.31% on average ' 'Messages sent within 10 seconds ' 'Date Percentage ' - '27 February 2021 98.60% ' - '26 February 2021 100.00% ' - '25 February 2021 99.99% ' - '24 February 2021 100.00% ' - '23 February 2021 95.00% ' - '22 February 2021 95.30% ' - '21 February 2021 99.25% ' + '26 February 2021 98.60% ' + '25 February 2021 100.00% ' + '24 February 2021 99.99% ' + '23 February 2021 100.00% ' + '22 February 2021 95.00% ' + '21 February 2021 95.30% ' + '20 February 2021 99.25% ' 'Only showing the last 7 days ' '' 'Organisations using Notify '