From 7168309fbb2d3d83a18e2d9c5aac544a796c395b Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Mon, 26 Jun 2023 14:07:28 -0700 Subject: [PATCH] fix all tests --- app/__init__.py | 2 ++ app/formatters.py | 4 +++ app/templates/views/temp-history.html | 2 +- tests/app/main/views/test_conversation.py | 26 ++++++++--------- tests/app/main/views/test_dashboard.py | 2 +- tests/app/main/views/test_history.py | 28 +++++++++---------- tests/app/main/views/test_jobs.py | 14 +++++----- tests/app/main/views/test_notifications.py | 8 +++--- tests/app/main/views/test_providers.py | 2 +- tests/app/main/views/test_templates.py | 4 +-- .../app/main/views/uploads/test_upload_hub.py | 6 ++-- 11 files changed, 52 insertions(+), 46 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 9e570924e..bfd3da0f4 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -66,6 +66,7 @@ from app.formatters import ( format_notification_type, format_number_in_pounds_as_currency, format_thousands, + format_time_24h, format_yes_no, id_safe, iteration_count, @@ -554,6 +555,7 @@ def add_template_filters(application): format_day_of_week, format_delta, format_delta_days, + format_time_24h, format_notification_status, format_notification_type, format_notification_status_as_time, diff --git a/app/formatters.py b/app/formatters.py index 9ac2e7a6b..49411ddbf 100644 --- a/app/formatters.py +++ b/app/formatters.py @@ -47,6 +47,10 @@ def format_datetime_24h(date): ) +def format_time(date): + return format_datetime_24h(date) + + def format_datetime_normal(date): return '{} at {}'.format( format_date_normal(date), diff --git a/app/templates/views/temp-history.html b/app/templates/views/temp-history.html index 11e9e9aff..f1fdf5331 100644 --- a/app/templates/views/temp-history.html +++ b/app/templates/views/temp-history.html @@ -38,7 +38,7 @@ {{ user_getter(event.user_id) }}
- {{ event.time|format_time }} + {{ event.time | format_time_24h }}
diff --git a/tests/app/main/views/test_conversation.py b/tests/app/main/views/test_conversation.py index 2d151af65..04c3738ce 100644 --- a/tests/app/main/views/test_conversation.py +++ b/tests/app/main/views/test_conversation.py @@ -114,55 +114,55 @@ def test_view_conversation( for index, expected in enumerate([ ( 'message-8', - 'yesterday at 2:59pm', + 'yesterday at 14:59', ), ( 'message-7', - 'yesterday at 2:59pm', + 'yesterday at 14:59', ), ( 'message-6', - 'yesterday at 4:59pm', + 'yesterday at 16:59', ), ( 'message-5', - 'yesterday at 6:59pm', + 'yesterday at 18:59', ), ( 'message-4', - 'yesterday at 8:59pm', + 'yesterday at 20:59', ), ( 'message-3', - 'yesterday at 10:59pm', + 'yesterday at 22:59', ), ( 'message-2', - 'yesterday at 10:59pm', + 'yesterday at 22:59', ), ( 'message-1', - 'yesterday at 11:00pm', + 'yesterday at 23:00', ), ( expected_outbound_content, - 'yesterday at midnight', + 'yesterday at 00:00', ), ( expected_outbound_content, - 'yesterday at midnight', + 'yesterday at 00:00', ), ( expected_outbound_content, - 'yesterday at midnight', + 'yesterday at 00:00', ), ( expected_outbound_content, - 'yesterday at midnight', + 'yesterday at 00:00', ), ( expected_outbound_content, - 'yesterday at midnight', + 'yesterday at 00:00', ), ]): assert ( diff --git a/tests/app/main/views/test_dashboard.py b/tests/app/main/views/test_dashboard.py index 7d4bbb669..31ac51b78 100644 --- a/tests/app/main/views/test_dashboard.py +++ b/tests/app/main/views/test_dashboard.py @@ -648,7 +648,7 @@ def test_should_show_upcoming_jobs_on_dashboard( page.select_one('a.banner-dashboard').text ) == ( '2 files waiting to send ' - 'sending starts today at 11:09am' + 'sending starts today at 11:09' ) assert page.select_one('a.banner-dashboard')['href'] == url_for( diff --git a/tests/app/main/views/test_history.py b/tests/app/main/views/test_history.py index 08859ede6..6a0af7b72 100644 --- a/tests/app/main/views/test_history.py +++ b/tests/app/main/views/test_history.py @@ -9,34 +9,34 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces ( '12 December', ( - 'Test User 6:13pm ' + 'Test User 18:13 ' 'Renamed this service from ‘Before lunch’ to ‘After lunch’ ' - 'Test User 5:12pm ' + 'Test User 17:12 ' 'Renamed this service from ‘Example service’ to ‘Before lunch’' ), ), ( '11 November', ( - 'Test User 5:12pm ' + 'Test User 17:12 ' 'Revoked the ‘Bad key’ API key' ), ), ( '11 November 2011', ( - 'Test User 4:11pm ' + 'Test User 16:11 ' 'Created an API key called ‘Bad key’' ), ), ( '10 October 2010', ( - 'Test User 3:10pm ' + 'Test User 15:10 ' 'Created an API key called ‘Good key’ ' - 'Test User 2:09pm ' + 'Test User 14:09 ' 'Created an API key called ‘Key event returned in non-chronological order’ ' - 'Test User 6:01am ' + 'Test User 06:01 ' 'Created this service and called it ‘Example service’' ), ), @@ -45,23 +45,23 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces ( '11 November', ( - 'Test User 5:12pm ' + 'Test User 17:12 ' 'Revoked the ‘Bad key’ API key' ), ), ( '11 November 2011', ( - 'Test User 4:11pm ' + 'Test User 16:11 ' 'Created an API key called ‘Bad key’' ), ), ( '10 October 2010', ( - 'Test User 3:10pm ' + 'Test User 15:10 ' 'Created an API key called ‘Good key’ ' - 'Test User 2:09pm ' + 'Test User 14:09 ' 'Created an API key called ‘Key event returned in non-chronological order’' ), ), @@ -70,16 +70,16 @@ from tests.conftest import SERVICE_ONE_ID, normalize_spaces ( '12 December', ( - 'Test User 6:13pm ' + 'Test User 18:13 ' 'Renamed this service from ‘Before lunch’ to ‘After lunch’ ' - 'Test User 5:12pm ' + 'Test User 17:12 ' 'Renamed this service from ‘Example service’ to ‘Before lunch’' ), ), ( '10 October 2010', ( - 'Test User 6:01am ' + 'Test User 06:01 ' 'Created this service and called it ‘Example service’' ), ), diff --git a/tests/app/main/views/test_jobs.py b/tests/app/main/views/test_jobs.py index 98c74eccb..f3b691b6d 100644 --- a/tests/app/main/views/test_jobs.py +++ b/tests/app/main/views/test_jobs.py @@ -83,7 +83,7 @@ def test_should_show_page_for_one_job( assert page.h1.text.strip() == 'thisisatest.csv' assert ' '.join(page.find('tbody').find('tr').text.split()) == ( - '2021234567 template content Delivered 1 January at 11:10am' + '2021234567 template content Delivered 1 January at 11:10' ) assert page.find('div', {'data-key': 'notifications'})['data-resource'] == url_for( 'main.view_job_updates', @@ -104,7 +104,7 @@ def test_should_show_page_for_one_job( assert normalize_spaces(page.select_one('tbody tr').text) == normalize_spaces( '2021234567 ' 'template content ' - 'Delivered 1 January at 11:10am' + 'Delivered 1 January at 11:10' ) assert page.select_one('tbody tr a')['href'] == url_for( 'main.view_notification', @@ -329,7 +329,7 @@ def test_should_show_scheduled_job( ) assert normalize_spaces(page.select('main p')[1].text) == ( - 'Sending Two week reminder tomorrow at 5:00am' + 'Sending Two week reminder tomorrow at 05:00' ) assert page.select('main p a')[0]['href'] == url_for( 'main.view_template_version', @@ -402,8 +402,8 @@ def test_should_show_updates_for_one_job_as_json( assert '2021234567' in content['notifications'] assert 'Status' in content['notifications'] assert 'Delivered' in content['notifications'] - assert '5:01am' in content['notifications'] - assert 'Sent by Test User on 1 January at 5:00am' in content['status'] + assert '05:01' in content['notifications'] + assert 'Sent by Test User on 1 January at 05:00' in content['status'] @freeze_time("2016-01-01 05:00:00.000001") @@ -439,8 +439,8 @@ def test_should_show_updates_for_scheduled_job_as_json( assert '2021234567' in content['notifications'] assert 'Status' in content['notifications'] assert 'Delivered' in content['notifications'] - assert '5:01am' in content['notifications'] - assert 'Sent by Test User on 1 June at 8:00pm' in content['status'] + assert '05:01' in content['notifications'] + assert 'Sent by Test User on 1 June at 20:00' in content['status'] @pytest.mark.parametrize( diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index 857b215cd..e6d8c2791 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -182,16 +182,16 @@ def test_notification_status_shows_expected_back_link( @pytest.mark.parametrize('time_of_viewing_page, expected_message', ( ('2012-01-01 06:01', ( - "‘sample template’ was sent by Test User today at 6:01am UTC" + "‘sample template’ was sent by Test User today at 06:01 UTC" )), ('2012-01-02 06:01', ( - "‘sample template’ was sent by Test User yesterday at 6:01am UTC" + "‘sample template’ was sent by Test User yesterday at 06:01 UTC" )), ('2012-01-03 06:01', ( - "‘sample template’ was sent by Test User on 1 January at 6:01am UTC" + "‘sample template’ was sent by Test User on 1 January at 06:01 UTC" )), ('2013-01-03 06:01', ( - "‘sample template’ was sent by Test User on 1 January 2012 at 6:01am UTC" + "‘sample template’ was sent by Test User on 1 January 2012 at 06:01 UTC" )), )) def test_notification_page_doesnt_link_to_template_in_tour( diff --git a/tests/app/main/views/test_providers.py b/tests/app/main/views/test_providers.py index b9e2b21aa..cd04854ce 100644 --- a/tests/app/main/views/test_providers.py +++ b/tests/app/main/views/test_providers.py @@ -188,7 +188,7 @@ def test_view_providers_shows_all_providers( assert table_data[1].text.strip() == "20" assert table_data[2].text.strip() == "42" assert table_data[3].text.strip() == "True" - assert table_data[4].text.strip() == "16 January at 3:20pm" + assert table_data[4].text.strip() == "16 January at 15:20" assert table_data[5].text.strip() == "Test User" domestic_sms_second_row = domestic_sms_table.tbody.find_all('tr')[1] diff --git a/tests/app/main/views/test_templates.py b/tests/app/main/views/test_templates.py index 74494633e..486e57ef0 100644 --- a/tests/app/main/views/test_templates.py +++ b/tests/app/main/views/test_templates.py @@ -472,7 +472,7 @@ def test_caseworker_sees_template_page_if_template_is_deleted( content = str(page) assert url_for("main.send_one_off", service_id=SERVICE_ONE_ID, template_id=fake_uuid) not in content - assert page.select('p.hint')[0].text.strip() == 'This template was deleted today at 3:00pm.' + assert page.select('p.hint')[0].text.strip() == 'This template was deleted today at 15:00.' mock_get_deleted_template.assert_called_with(SERVICE_ONE_ID, template_id, None) @@ -1575,7 +1575,7 @@ def test_should_show_page_for_a_deleted_template( content = str(page) assert url_for("main.edit_service_template", service_id=SERVICE_ONE_ID, template_id=fake_uuid) not in content assert url_for("main.send_one_off", service_id=SERVICE_ONE_ID, template_id=fake_uuid) not in content - assert page.select('p.hint')[0].text.strip() == 'This template was deleted today at 3:00pm.' + assert page.select('p.hint')[0].text.strip() == 'This template was deleted today at 15:00.' assert 'Delete this template' not in page.select_one('main').text mock_get_deleted_template.assert_called_with(SERVICE_ONE_ID, template_id, None) diff --git a/tests/app/main/views/uploads/test_upload_hub.py b/tests/app/main/views/uploads/test_upload_hub.py index 6294f973e..2ca1c45f2 100644 --- a/tests/app/main/views/uploads/test_upload_hub.py +++ b/tests/app/main/views/uploads/test_upload_hub.py @@ -48,7 +48,7 @@ def test_get_upload_hub_page( assert normalize_spaces(uploads[0].text.strip()) == ( 'some.csv ' - 'Sent 1 January 2016 at 11:09am ' + 'Sent 1 January 2016 at 11:09 ' '0 sending 8 delivered 2 failed' ) assert uploads[0].select_one('a.file-list-filename-large')['href'] == ( @@ -79,12 +79,12 @@ def test_uploads_page_shows_scheduled_jobs( ), ( 'even_later.csv ' - 'Sending 1 January 2016 at 11:09pm ' + 'Sending 1 January 2016 at 23:09 ' '1 text message waiting to send' ), ( 'send_me_later.csv ' - 'Sending 1 January 2016 at 11:09am ' + 'Sending 1 January 2016 at 11:09 ' '1 text message waiting to send' ), ]