use correct iso8601 datetime in availableTimeSlots (#80133)
gitea/ants-hub/pipeline/head This commit looks good
Details
gitea/ants-hub/pipeline/head This commit looks good
Details
This commit is contained in:
parent
3c4b0b50b5
commit
ee5bda2f36
|
@ -24,6 +24,7 @@ from ants_hub.data.models import (
|
|||
TypeDeRdv,
|
||||
make_available_time_slots,
|
||||
)
|
||||
from ants_hub.timezone import utc
|
||||
|
||||
ANTS_TIMEZONE = zoneinfo.ZoneInfo('Europe/Paris')
|
||||
|
||||
|
@ -32,7 +33,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(ANTS_TIMEZONE).isoformat().split('+')[0] + 'Z'
|
||||
return dt.astimezone(utc).isoformat().split('+')[0] + 'Z'
|
||||
|
||||
|
||||
AUTH_TOKEN = None
|
||||
|
|
|
@ -72,9 +72,11 @@ class TestEndpoints:
|
|||
# 3 days = 30 slots
|
||||
assert len(slots) == 30
|
||||
for slot in slots:
|
||||
assert 9 <= datetime.datetime.fromisoformat(slot['datetime'].rstrip('Z')).day <= 11
|
||||
assert 9 <= datetime.datetime.fromisoformat(slot['datetime'].replace('Z', '+00:00')).day <= 11
|
||||
# remove the Z suffix
|
||||
assert slot['datetime'][:-1] in slot['callback_url']
|
||||
assert datetime.datetime.fromisoformat(
|
||||
slot['datetime'].replace('Z', '+00:00')
|
||||
) == datetime.datetime.fromisoformat(slot['callback_url'].split('/')[-2])
|
||||
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'])
|
||||
|
@ -105,7 +107,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:00:00Z'}
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:00:00Z'}
|
||||
|
||||
# CNI matches CNI and CNI-PASSPORT
|
||||
response = django_app.get(
|
||||
|
@ -118,7 +120,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:00:00Z'}
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:00:00Z'}
|
||||
|
||||
response = django_app.get(
|
||||
'/api/ants/availableTimeSlots',
|
||||
|
@ -130,7 +132,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-04T08:30:00Z'}
|
||||
|
||||
response = django_app.get(
|
||||
'/api/ants/availableTimeSlots',
|
||||
|
@ -142,7 +144,7 @@ class TestEndpoints:
|
|||
},
|
||||
)
|
||||
assert len(response.json[str(lieu.id)]) == 1
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T11:00:00Z'}
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T09:00:00Z'}
|
||||
|
||||
def test_available_time_slots_documents_number(self, db, django_app, lieu):
|
||||
Plage.objects.all().delete()
|
||||
|
@ -168,7 +170,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:00:00Z'}
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:00:00Z'}
|
||||
|
||||
response = django_app.get(
|
||||
'/api/ants/availableTimeSlots',
|
||||
|
@ -180,7 +182,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:00:00Z'}
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T08:00:00Z'}
|
||||
|
||||
response = django_app.get(
|
||||
'/api/ants/availableTimeSlots',
|
||||
|
@ -192,7 +194,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-04T08:30:00Z'}
|
||||
|
||||
response = django_app.get(
|
||||
'/api/ants/availableTimeSlots',
|
||||
|
@ -204,7 +206,7 @@ class TestEndpoints:
|
|||
},
|
||||
)
|
||||
assert len(response.json[str(lieu.id)]) == 1
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T11:00:00Z'}
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T09:00:00Z'}
|
||||
|
||||
# implicit maximum is 5
|
||||
response = django_app.get(
|
||||
|
@ -217,7 +219,7 @@ class TestEndpoints:
|
|||
},
|
||||
)
|
||||
assert len(response.json[str(lieu.id)]) == 1
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T12:30:00Z'}
|
||||
assert {x['datetime'] for x in response.json[str(lieu.id)]} == {'2023-04-04T10:30:00Z'}
|
||||
|
||||
def test_search_application_ids(self, db, django_app, lieu):
|
||||
RendezVous.objects.create(
|
||||
|
@ -239,7 +241,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-11T11:00:00Z',
|
||||
'datetime': '2023-04-11T09: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',
|
||||
|
@ -249,7 +251,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-03T12:15:00Z',
|
||||
'datetime': '2023-04-03T10: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',
|
||||
|
|
Loading…
Reference in New Issue