Revert "use correct iso8601 datetime in availableTimeSlots (#80133)"
gitea/ants-hub/pipeline/head This commit looks good Details

This reverts commit ee5bda2f36.
This commit is contained in:
Benjamin Dauvergne 2023-09-13 15:17:48 +02:00
parent ee5bda2f36
commit b0c2736d63
2 changed files with 14 additions and 17 deletions

View File

@ -24,7 +24,6 @@ from ants_hub.data.models import (
TypeDeRdv,
make_available_time_slots,
)
from ants_hub.timezone import utc
ANTS_TIMEZONE = zoneinfo.ZoneInfo('Europe/Paris')
@ -33,7 +32,7 @@ logger = logging.getLogger('ants_hub.api.ants')
def format_date_ants(dt):
'''Format date as ANTS requests it, i.e. Paris local time with 'Z' suffix :/'''
return dt.astimezone(utc).isoformat().split('+')[0] + 'Z'
return dt.astimezone(ANTS_TIMEZONE).isoformat().split('+')[0] + 'Z'
AUTH_TOKEN = None

View File

@ -72,11 +72,9 @@ class TestEndpoints:
# 3 days = 30 slots
assert len(slots) == 30
for slot in slots:
assert 9 <= datetime.datetime.fromisoformat(slot['datetime'].replace('Z', '+00:00')).day <= 11
assert 9 <= datetime.datetime.fromisoformat(slot['datetime'].rstrip('Z')).day <= 11
# remove the Z suffix
assert datetime.datetime.fromisoformat(
slot['datetime'].replace('Z', '+00:00')
) == datetime.datetime.fromisoformat(slot['callback_url'].split('/')[-2])
assert slot['datetime'][:-1] in slot['callback_url']
assert f'{lieu.slug}-{lieu.id}' in slot['callback_url']
assert f'{lieu.collectivite.slug}-{lieu.collectivite.id}' in slot['callback_url']
response = django_app.get(slots[-1]['callback_url'])
@ -107,7 +105,7 @@ class TestEndpoints:
},
)
assert len(response.json[str(lieu.id)]) == 1
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:00:00Z'}
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T10:00:00Z'}
# CNI matches CNI and CNI-PASSPORT
response = django_app.get(
@ -120,7 +118,7 @@ class TestEndpoints:
},
)
assert len(response.json[str(lieu.id)]) == 1
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:00:00Z'}
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T10:00:00Z'}
response = django_app.get(
'/api/ants/availableTimeSlots',
@ -132,7 +130,7 @@ class TestEndpoints:
},
)
assert len(response.json[str(lieu.id)]) == 1
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:30:00Z'}
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T10:30:00Z'}
response = django_app.get(
'/api/ants/availableTimeSlots',
@ -144,7 +142,7 @@ class TestEndpoints:
},
)
assert len(response.json[str(lieu.id)]) == 1
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T09:00:00Z'}
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T11:00:00Z'}
def test_available_time_slots_documents_number(self, db, django_app, lieu):
Plage.objects.all().delete()
@ -170,7 +168,7 @@ class TestEndpoints:
},
)
assert len(response.json[str(lieu.id)]) == 1
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:00:00Z'}
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T10:00:00Z'}
response = django_app.get(
'/api/ants/availableTimeSlots',
@ -182,7 +180,7 @@ class TestEndpoints:
},
)
assert len(response.json[str(lieu.id)]) == 1
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:00:00Z'}
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T10:00:00Z'}
response = django_app.get(
'/api/ants/availableTimeSlots',
@ -194,7 +192,7 @@ class TestEndpoints:
},
)
assert len(response.json[str(lieu.id)]) == 1
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:30:00Z'}
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T10:30:00Z'}
response = django_app.get(
'/api/ants/availableTimeSlots',
@ -206,7 +204,7 @@ class TestEndpoints:
},
)
assert len(response.json[str(lieu.id)]) == 1
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T09:00:00Z'}
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T11:00:00Z'}
# implicit maximum is 5
response = django_app.get(
@ -219,7 +217,7 @@ class TestEndpoints:
},
)
assert len(response.json[str(lieu.id)]) == 1
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T10:30:00Z'}
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T12:30:00Z'}
def test_search_application_ids(self, db, django_app, lieu):
RendezVous.objects.create(
@ -241,7 +239,7 @@ class TestEndpoints:
{
'cancel_url': 'http://testserver/rdv/saint-didier-1/mairie-1/2023-04-11T11:00:00+02:00/'
'annulation/7621a90a-2dd3-44e5-9df7-879abddeaad5/',
'datetime': '2023-04-11T09:00:00Z',
'datetime': '2023-04-11T11:00:00Z',
'management_url': 'http://testserver/rdv/saint-didier-1/mairie-1/2023-04-11T11:00:00+02:00/'
'gestion/7621a90a-2dd3-44e5-9df7-879abddeaad5/',
'meeting_point': 'Mairie',
@ -251,7 +249,7 @@ class TestEndpoints:
{
'cancel_url': 'http://testserver/rdv/saint-didier-1/mairie-1/2023-04-03T12:15:00+02:00/'
'annulation/7cace277-9157-4fbc-9705-45522984805d/',
'datetime': '2023-04-03T10:15:00Z',
'datetime': '2023-04-03T12:15:00Z',
'management_url': 'http://testserver/rdv/saint-didier-1/mairie-1/2023-04-03T12:15:00+02:00/'
'gestion/7cace277-9157-4fbc-9705-45522984805d/',
'meeting_point': 'Mairie',