fix contact list bst bug

the api returns UTC timestamps, we should keep them as UTC timestamps
until the very last moment, and only convert them into BST when we know
we want to return to a user (ie: in contact-list.html and other places
like that)
This commit is contained in:
Leo Hemsted
2021-09-14 13:28:27 +01:00
parent 96b91f9e1a
commit 9e915703fd
5 changed files with 7 additions and 19 deletions

View File

@@ -4285,7 +4285,7 @@ def test_redirects_to_template_if_job_exists_already(
'123 phone numbers',
),
))
@freeze_time('2020-03-13 13:00')
@freeze_time('2020-06-13 13:00')
def test_choose_from_contact_list(
mocker,
client_request,

View File

@@ -458,7 +458,7 @@ def test_cant_save_bad_contact_list(
(False, 'Not used yet.'),
(True, 'Not used in the last 7 days.'),
])
@freeze_time('2020-03-13 16:51:56')
@freeze_time('2020-06-13 16:51:56')
def test_view_contact_list(
mocker,
client_request,

View File

@@ -1,15 +1,7 @@
from datetime import datetime
from app.models.contact_list import ContactList
from app.models.job import PaginatedJobs
def test_created_at():
created_at = ContactList({'created_at': '2016-05-06T07:08:09.061258'}).created_at
assert isinstance(created_at, datetime)
assert created_at.isoformat() == '2016-05-06T08:08:09.061258+01:00'
def test_get_jobs(mock_get_jobs):
contact_list = ContactList({'id': 'a', 'service_id': 'b'})
assert isinstance(contact_list.get_jobs(page=123), PaginatedJobs)

View File

@@ -1852,7 +1852,7 @@ def mock_create_contact_list(mocker, api_user_active):
def mock_get_contact_lists(mocker, api_user_active, fake_uuid):
def _get(service_id, template_type=None):
return [{
'created_at': '2020-03-13 10:59:56',
'created_at': '2020-06-13T09:59:56.000000Z',
'created_by': 'Test User',
'id': fake_uuid,
'original_file_name': 'EmergencyContactList.xls',
@@ -1862,7 +1862,7 @@ def mock_get_contact_lists(mocker, api_user_active, fake_uuid):
'service_id': service_id,
'template_type': 'email',
}, {
'created_at': '2020-03-13 13:00:00',
'created_at': '2020-06-13T12:00:00.000000Z',
'created_by': 'Test User',
'id': 'd7b0bd1a-d1c7-4621-be5c-3c1b4278a2ad',
'original_file_name': 'phone number list.csv',
@@ -1872,7 +1872,7 @@ def mock_get_contact_lists(mocker, api_user_active, fake_uuid):
'service_id': service_id,
'template_type': 'sms',
}, {
'created_at': '2020-02-02 02:00:00',
'created_at': '2020-05-02T01:00:00.000000Z',
'created_by': 'Test User',
'id': fake_uuid,
'original_file_name': 'UnusedList.tsv',
@@ -1893,7 +1893,7 @@ def mock_get_contact_lists(mocker, api_user_active, fake_uuid):
def mock_get_contact_list(mocker, api_user_active, fake_uuid):
def _get(*, service_id, contact_list_id):
return {
'created_at': '2020-03-13 10:59:56',
'created_at': '2020-06-13T09:59:56.000000Z',
'created_by': 'Test User',
'id': fake_uuid,
'original_file_name': 'EmergencyContactList.xls',