diff --git a/app/utils.py b/app/utils.py index e178c2dbb..752eadebc 100644 --- a/app/utils.py +++ b/app/utils.py @@ -680,5 +680,5 @@ def format_thousands(value): def is_less_than_90_days_ago(date_from_db): return (datetime.utcnow() - datetime.strptime( - date_from_db, '%a, %d %b %Y %X %Z' + date_from_db, "%Y-%m-%dT%H:%M:%S.%fZ" )).days < 90 diff --git a/tests/app/main/views/test_two_factor.py b/tests/app/main/views/test_two_factor.py index 213066a5e..0eaff8489 100644 --- a/tests/app/main/views/test_two_factor.py +++ b/tests/app/main/views/test_two_factor.py @@ -49,7 +49,7 @@ def test_should_login_user_and_should_redirect_to_next_url( session['user_details'] = { 'id': api_user_active['id'], 'email': api_user_active['email_address']} - api_user_active['email_access_validated_at'] = 'Sun, 23 Jan 2020 11:28:25 GMT' + api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z' response = client.post(url_for('main.two_factor', next='/services/{}'.format(SERVICE_ONE_ID)), data={'sms_code': '12345'}) @@ -72,7 +72,7 @@ def test_should_send_email_and_redirect_to_info_page_if_user_needs_to_revalidate mocker ): mocker.patch('app.user_api_client.get_user', return_value=api_user_active) - api_user_active['email_access_validated_at'] = 'Sun, 03 Mar 2019 11:28:25 GMT' + api_user_active['email_access_validated_at'] = '2019-03-23T11:35:21.726132Z' with client.session_transaction() as session: session['user_details'] = { 'id': api_user_active['id'], @@ -99,7 +99,7 @@ def test_should_login_user_and_not_redirect_to_external_url( session['user_details'] = { 'id': api_user_active['id'], 'email': api_user_active['email_address']} - api_user_active['email_access_validated_at'] = 'Sun, 23 Jan 2020 11:28:25 GMT' + api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z' response = client.post(url_for('main.two_factor', next='http://www.google.com'), data={'sms_code': '12345'}) @@ -120,7 +120,7 @@ def test_should_login_user_and_redirect_to_show_accounts( session['user_details'] = { 'id': api_user_active['id'], 'email': api_user_active['email_address']} - api_user_active['email_access_validated_at'] = 'Sun, 23 Jan 2020 11:28:25 GMT' + api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z' response = client.post(url_for('main.two_factor'), data={'sms_code': '12345'}) @@ -162,7 +162,7 @@ def test_should_login_user_when_multiple_valid_codes_exist( session['user_details'] = { 'id': api_user_active['id'], 'email': api_user_active['email_address']} - api_user_active['email_access_validated_at'] = 'Sun, 23 Jan 2020 11:28:25 GMT' + api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z' response = client.post(url_for('main.two_factor'), data={'sms_code': '23456'}) @@ -184,7 +184,7 @@ def test_two_factor_should_set_password_when_new_password_exists_in_session( 'id': api_user_active['id'], 'email': api_user_active['email_address'], 'password': 'changedpassword'} - api_user_active['email_access_validated_at'] = 'Sun, 23 Jan 2020 11:28:25 GMT' + api_user_active['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z' response = client.post(url_for('main.two_factor'), data={'sms_code': '12345'}) @@ -234,7 +234,7 @@ def test_two_factor_should_activate_pending_user( ): mocker.patch('app.user_api_client.get_user', return_value=api_user_pending) mocker.patch('app.service_api_client.get_services', return_value={'data': []}) - api_user_pending['email_access_validated_at'] = 'Sun, 23 Jan 2020 11:28:25 GMT' + api_user_pending['email_access_validated_at'] = '2020-01-23T11:35:21.726132Z' with client.session_transaction() as session: session['user_details'] = { 'id': api_user_pending['id'], diff --git a/tests/app/test_utils.py b/tests/app/test_utils.py index ce87009cc..fd0b991f3 100644 --- a/tests/app/test_utils.py +++ b/tests/app/test_utils.py @@ -510,8 +510,8 @@ def test_get_letter_validation_error_for_known_errors( @pytest.mark.parametrize("date_from_db, expected_result", [ - ('Sun, 17 Nov 2019 11:28:25 GMT', True), - ('Sun, 16 Nov 2019 11:28:25 GMT', False), + ('2019-11-17T11:35:21.726132Z', True), + ('2019-11-16T11:35:21.726132Z', False), ]) @freeze_time('2020-02-14T12:00:00') def test_is_less_than_90_days_ago(date_from_db, expected_result):