toulouse-maelis: accept recurrent week on subscription endpoint (#74438)
gitea/passerelle/pipeline/pr-main This commit looks good Details
gitea/passerelle/pipeline/head Something is wrong with the build of this commit Details

This commit is contained in:
Nicolas Roche 2023-02-09 16:32:13 +01:00 committed by Gitea
parent cb46e3049e
commit f9d278eb41
3 changed files with 46 additions and 0 deletions

View File

@ -74,6 +74,10 @@ SUBSCRIPTION_SCHEMA = {
'type': 'string',
'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$',
},
'recurrent_week': {
'type': 'array',
'items': {'type': 'string'},
},
},
'required': [
'person_id',

View File

@ -2717,6 +2717,16 @@ class ToulouseMaelis(BaseResource, HTTPResource):
):
family_id = family_id or self.get_link(NameID).family_id
recurrent_week = []
for item in post_data.get('recurrent_week') or []:
day_num, key = item.split('-')
recurrent_week.append(
{
'dayNum': day_num,
'calendarLetter': key,
'isPresent': True,
}
)
payload = {
'addPersonUnitBasketRequestBean': {
'numFamily': family_id,

View File

@ -24,6 +24,7 @@ import responses
from django.utils.dateparse import parse_date
from requests.exceptions import ConnectionError
from zeep import Settings
from zeep.helpers import serialize_object
from passerelle.contrib.toulouse_maelis.models import Link, Referential, ToulouseMaelis
from passerelle.contrib.toulouse_maelis.utils import get_public_criterias, json_date_format
@ -6010,6 +6011,37 @@ def test_add_person_basket_subscription(activity_service, con, app):
}
def test_add_person_basket_subscription_with_recurrent_week(activity_service, con, app):
def request_check(request):
assert serialize_object(request.dayWeekInfoList) == [
{'dayNum': 1, 'isPresent': True, 'isOpen': None, 'calendarLetter': 'B'},
{'dayNum': 2, 'isPresent': True, 'isOpen': None, 'calendarLetter': 'C'},
]
activity_service.add_soap_response(
'addPersonUnitBasket',
get_xml_file('R_add_person_unit_basket.xml'),
request_check=request_check,
)
url = get_endpoint('add-person-basket-subscription')
params = {
'person_id': '246423',
'activity_id': 'A10051141965',
'unit_id': 'A10051141990',
'place_id': 'A10053179226',
'start_date': '2022-09-01',
'end_date': '2023-08-31',
'recurrent_week': ['1-B', '2-C'],
}
resp = app.post_json(url + '?family_id=311323', params=params)
assert resp.json['err'] == 0
Link.objects.create(resource=con, family_id='311323', name_id='local')
resp = app.post_json(url + '?NameID=local', params=params)
assert resp.json['err'] == 0
def test_add_person_basket_subscription_error(activity_service, con, app):
activity_service.add_soap_response(
'addPersonUnitBasket',