toulouse-maelis: add endpoint for school pre-registration with exemption (#73138) #31

Merged
smihai merged 1 commits from wip/73138-toulouse-maelis-add-school-pre-registration-with-exemption into main 2023-01-09 20:32:13 +01:00
4 changed files with 124 additions and 0 deletions

View File

@ -837,3 +837,59 @@ SCHOOL_PRE_REGISTRATION_SCHEMA = {
'unflatten': True,
'additionalProperties': False,
}
SCHOOL_PRE_REGISTRATION_WITH_EXEMPTION_SCHEMA = {
'$schema': 'http://json-schema.org/draft-04/schema#',
'title': 'School pre-registration',
'description': 'Crée une pré-inscription scolaire pour un enfant avec demande de dérogation',
'type': 'object',
'required': [
'numPerson',
'schoolYear',
'datePresubscribe',
'levelCode',
'idRequestSchool1',
'derogReasonCode',

Le commentaire relatif à la dérogation est obligatoire :
https://demo-toulouse.sigec.fr/maelisws-toulouse-recette/doc/family.html#bean-PresubscribeSchoolDerog

$ curl 'https://parsifal-passerelle.dev.publik.love/toulouse-maelis/test/create-child-school-pre-registration-with-exemption' -d '{"numPerson": "248478", "schoolYear": "2022", "levelCode": "CE1", "datePresubscribe": "2022-01-01", "idRequestSchool1": "2435", "derogReasonCode": "07DERO-1"}'
{"err": 1, "err_class": "zeep.exceptions.ValidationError", "err_desc": "Missing element derogComment (presubscribeSchoolDerog.derogComment)", "data": null}
Le commentaire relatif à la dérogation est obligatoire : https://demo-toulouse.sigec.fr/maelisws-toulouse-recette/doc/family.html#bean-PresubscribeSchoolDerog ``` $ curl 'https://parsifal-passerelle.dev.publik.love/toulouse-maelis/test/create-child-school-pre-registration-with-exemption' -d '{"numPerson": "248478", "schoolYear": "2022", "levelCode": "CE1", "datePresubscribe": "2022-01-01", "idRequestSchool1": "2435", "derogReasonCode": "07DERO-1"}' {"err": 1, "err_class": "zeep.exceptions.ValidationError", "err_desc": "Missing element derogComment (presubscribeSchoolDerog.derogComment)", "data": null} ```

Tu as raison, merci.
Corrigé.

Tu as raison, merci. Corrigé.
'derogComment',
],
'properties': {
'numPerson': {
'description': "Numéro de l'enfant",
'type': 'string',
},
'schoolYear': {
'description': "Année scolaire",
'type': 'string',
},
'datePresubscribe': {
'description': "Date d'inscription",
'type': 'string',
},
'levelCode': {
'description': "Le code du niveau scolaire",
'type': 'string',
},
'idRequestSchool1': {
'description': "Identifiant de l'établissement demandé 1",
'type': 'string',
},
'idRequestSchool2': {
'description': "Identifiant de l'établissement demandé 2",
'type': 'string',
},
'idRequestSchool3': {
'description': "Identifiant de l'établissement demandé 3",
'type': 'string',
},
'derogReasonCode': {
'description': "Code du motif de dérogation",
'type': 'string',
},
'derogComment': {
'description': "Commentaire relatif à la dérogation",
'type': 'string',
},
},
'unflatten': True,
'additionalProperties': False,
}

View File

@ -2011,6 +2011,21 @@ class ToulouseMaelis(BaseResource, HTTPResource):
response = self.call('Family', 'preSubscribeSchoolPerim', **post_data)
return {'data': serialize_object(response)}
@endpoint(
display_category='Inscriptions',
description="Création d'une pré-inscription scolaire avec demande de dérogation",
name='create-child-school-pre-registration-with-exemption',
perm='can_access',
post={
'request_body': {
'schema': {'application/json': family_schemas.SCHOOL_PRE_REGISTRATION_WITH_EXEMPTION_SCHEMA}
}
},
)
def create_child_school_pre_registration_with_exemption(self, request, post_data):
response = self.call('Family', 'presubscribeSchoolDerog', **post_data)
return {'data': serialize_object(response)}
class Link(models.Model):
resource = models.ForeignKey(ToulouseMaelis, on_delete=models.CASCADE)

View File

@ -0,0 +1,26 @@
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:presubscribeSchoolDerogResponse xmlns:ns2="family.ws.maelis.sigec.com">
<subscribeSchool3Bean>
<idInssco>S10053187805</idInssco>
<year>2023</year>
<idSchool>2435</idSchool>
<schoolName>DUPONT PIERRE ELEMENTAIRE</schoolName>
<levelBean><code>CM1</code>
<libelle>Cours moyen 1</libelle>
</levelBean>
<adresse> GRANDE-RUE SAINT MICHEL</adresse>
<headmaster>FOURCADE MARIE-SYLVIE</headmaster>
<dateIns>2023-09-01T00:00:00+02:00</dateIns>
<preSubscribeDate>2023-09-01T00:00:00+02:00</preSubscribeDate>
<isWaitList>true</isWaitList>
<codeWait>MO_DEROG</codeWait>
<libWait>GRU</libWait>
<isDerog>true</isDerog>
<derogReason>11DERO-1</derogReason>
<derogState>E</derogState>
<derogComment>exemption comment</derogComment>
</subscribeSchool3Bean>
</ns2:presubscribeSchoolDerogResponse>
</soap:Body>
</soap:Envelope>

View File

@ -4356,3 +4356,30 @@ def test_create_child_school_pre_registration(family_service, con, app):
assert resp.json['data']['subscribeSchoolBean']['idSchool'] == '2435'
assert resp.json['data']['subscribeSchoolBean']['schoolName'] == 'DUPONT PIERRE ELEMENTAIRE'
assert resp.json['data']['subscribeSchoolBean']['isWaitList']
def test_create_child_school_pre_registration_with_exemption(family_service, con, app):
family_service.add_soap_response(
'presubscribeSchoolDerog', get_xml_file('R_create_child_school_pre_registration_with_exemption.xml')
)
url = get_endpoint('create-child-school-pre-registration-with-exemption')
resp = app.post_json(
url,
params={
'numPerson': '248460',
'schoolYear': '2023',
'levelCode': 'CM1',
'datePresubscribe': '2023-09-01T00:00:00+02:00',
'idRequestSchool1': '2435',
'derogReasonCode': '11DERO-1',
'derogComment': 'exemption comment',
},
)
assert resp.json['err'] == 0
print(resp.json['data'])
assert resp.json['data']['idSchool'] == '2435'
assert resp.json['data']['schoolName'] == 'DUPONT PIERRE ELEMENTAIRE'
assert resp.json['data']['isWaitList']
assert resp.json['data']['isDerog']
assert resp.json['data']['derogReason'] == '11DERO-1'
assert resp.json['data']['derogComment'] == 'exemption comment'