226 lines
6.6 KiB
Python
226 lines
6.6 KiB
Python
# ANTS-Hub - Copyright (C) Entr'ouvert
|
|
|
|
from ants_hub.data.models import Raccordement
|
|
|
|
|
|
def test_ping(django_app, db):
|
|
django_app.get('/api/chrono/ping/', status=401)
|
|
django_app.set_authorization(('Basic', ('abcd', '')))
|
|
django_app.get('/api/chrono/ping/', status=401)
|
|
Raccordement.objects.create(name='plateforme', apikey='abcd')
|
|
assert django_app.get('/api/chrono/ping/').json == {'err': 0}
|
|
|
|
|
|
def test_rendez_vous_dispomibles(django_app, db):
|
|
Raccordement.objects.create(name='plateforme', apikey='abcd')
|
|
django_app.set_authorization(('Basic', ('abcd', '')))
|
|
assert django_app.get('/api/chrono/rendez-vous-disponibles/').json == {
|
|
'err': 0,
|
|
'collectivites': [],
|
|
}
|
|
response = django_app.post_json(
|
|
'/api/chrono/rendez-vous-disponibles/',
|
|
params={
|
|
'collectivites': [
|
|
{
|
|
'id': 'col1',
|
|
'nom': 'Saint-Didier',
|
|
'url': 'https://saint-didier.fr/rdv/',
|
|
}
|
|
]
|
|
},
|
|
)
|
|
assert response.json == {
|
|
'err': 0,
|
|
'data': {
|
|
'collectivites_created': 1,
|
|
'collectivites_updated': 0,
|
|
'lieux_created': 0,
|
|
'lieux_updated': 0,
|
|
'plage_created': 0,
|
|
'plage_deleted': 0,
|
|
'rdv_created': 0,
|
|
'rdv_deleted': 0,
|
|
},
|
|
}
|
|
|
|
response = django_app.post_json(
|
|
'/api/chrono/rendez-vous-disponibles/',
|
|
params={
|
|
'collectivites': [
|
|
{
|
|
'id': 'col1',
|
|
'lieux': [
|
|
{
|
|
'id': 'lieu1',
|
|
'nom': 'Mairie de Saint-Didier',
|
|
'numero_rue': '2 rue du four',
|
|
'code_postal': '99999',
|
|
'ville': 'Saint-Didier',
|
|
'longitude': 1.5,
|
|
'latitude': 2.3,
|
|
}
|
|
],
|
|
}
|
|
]
|
|
},
|
|
)
|
|
assert response.json == {
|
|
'err': 0,
|
|
'data': {
|
|
'collectivites_created': 0,
|
|
'collectivites_updated': 0,
|
|
'lieux_created': 1,
|
|
'lieux_updated': 0,
|
|
'plage_created': 0,
|
|
'plage_deleted': 0,
|
|
'rdv_created': 0,
|
|
'rdv_deleted': 0,
|
|
},
|
|
}
|
|
|
|
response = django_app.post_json(
|
|
'/api/chrono/rendez-vous-disponibles/',
|
|
params={
|
|
'collectivites': [
|
|
{
|
|
'id': 'col1',
|
|
'lieux': [
|
|
{
|
|
'id': 'lieu1',
|
|
'plages': [
|
|
{
|
|
'date': '2023-03-20',
|
|
'types_rdv': ['CNI', 'PASSPORT'],
|
|
'heure_debut': '08:00+02:00',
|
|
'heure_fin': '12:00+02:00',
|
|
'duree': 15,
|
|
'personnes': 1,
|
|
}
|
|
],
|
|
}
|
|
],
|
|
}
|
|
]
|
|
},
|
|
)
|
|
assert response.json == {
|
|
'err': 0,
|
|
'data': {
|
|
'collectivites_created': 0,
|
|
'collectivites_updated': 0,
|
|
'lieux_created': 0,
|
|
'lieux_updated': 0,
|
|
'plage_created': 2,
|
|
'plage_deleted': 0,
|
|
'rdv_created': 0,
|
|
'rdv_deleted': 0,
|
|
},
|
|
}
|
|
|
|
response = django_app.post_json(
|
|
'/api/chrono/rendez-vous-disponibles/',
|
|
params={
|
|
'collectivites': [
|
|
{
|
|
'id': 'col1',
|
|
'lieux': [
|
|
{
|
|
'id': 'lieu1',
|
|
'plages': [
|
|
{
|
|
'date': '2023-03-20',
|
|
'types_rdv': ['PASSPORT'],
|
|
}
|
|
],
|
|
}
|
|
],
|
|
}
|
|
]
|
|
},
|
|
)
|
|
assert response.json == {
|
|
'err': 0,
|
|
'data': {
|
|
'collectivites_created': 0,
|
|
'collectivites_updated': 0,
|
|
'lieux_created': 0,
|
|
'lieux_updated': 0,
|
|
'plage_created': 0,
|
|
'plage_deleted': 1,
|
|
'rdv_created': 0,
|
|
'rdv_deleted': 0,
|
|
},
|
|
}
|
|
|
|
response = django_app.post_json(
|
|
'/api/chrono/rendez-vous-disponibles/',
|
|
params={
|
|
'collectivites': [
|
|
{
|
|
'id': 'col1',
|
|
'lieux': [
|
|
{
|
|
'id': 'lieu1',
|
|
'rdvs': [
|
|
{
|
|
'id': 'abcd',
|
|
'date': '2023-03-20T15:00:00+02:00',
|
|
}
|
|
],
|
|
}
|
|
],
|
|
}
|
|
]
|
|
},
|
|
)
|
|
assert response.json == {
|
|
'err': 0,
|
|
'data': {
|
|
'collectivites_created': 0,
|
|
'collectivites_updated': 0,
|
|
'lieux_created': 0,
|
|
'lieux_updated': 0,
|
|
'plage_created': 0,
|
|
'plage_deleted': 0,
|
|
'rdv_created': 1,
|
|
'rdv_deleted': 0,
|
|
},
|
|
}
|
|
|
|
response = django_app.post_json(
|
|
'/api/chrono/rendez-vous-disponibles/',
|
|
params={
|
|
'collectivites': [
|
|
{
|
|
'id': 'col1',
|
|
'lieux': [
|
|
{
|
|
'id': 'lieu1',
|
|
'rdvs': [
|
|
{
|
|
'id': 'abcd',
|
|
'date': '2023-03-20T15:00:00+02:00',
|
|
'annule': True,
|
|
}
|
|
],
|
|
}
|
|
],
|
|
}
|
|
]
|
|
},
|
|
)
|
|
assert response.json == {
|
|
'err': 0,
|
|
'data': {
|
|
'collectivites_created': 0,
|
|
'collectivites_updated': 0,
|
|
'lieux_created': 0,
|
|
'lieux_updated': 0,
|
|
'plage_created': 0,
|
|
'plage_deleted': 0,
|
|
'rdv_created': 0,
|
|
'rdv_deleted': 1,
|
|
},
|
|
}
|