toulouse-maelis: add child school pre-registration (#72751) #28
|
@ -65,10 +65,17 @@ def dump_csv_columns(columns):
|
|||
|
||||
class RSA13Form(GenericConnectorForm):
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs['initial'] = {}
|
||||
for name in RSA13Resource.CSV_EXPORTS:
|
||||
field = f'{name}_csv_columns'
|
||||
kwargs['initial'][field] = dump_csv_columns(DEFAULTS[field])
|
||||
instance = kwargs.get('instance')
|
||||
if instance is None:
|
||||
kwargs['initial'] = {}
|
||||
for name in RSA13Resource.CSV_EXPORTS:
|
||||
field = f'{name}_csv_columns'
|
||||
kwargs['initial'][field] = dump_csv_columns(DEFAULTS[field])
|
||||
else:
|
||||
for name in RSA13Resource.CSV_EXPORTS:
|
||||
field = f'{name}_csv_columns'
|
||||
if not getattr(instance, field):
|
||||
setattr(instance, field, dump_csv_columns(DEFAULTS[field]))
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
|
|
|
@ -809,3 +809,31 @@ SUPPLIED_DOCUMENTS_SCHEMA = {
|
|||
'unflatten': True,
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
||||
SCHOOL_PRE_REGISTRATION_SCHEMA = {
|
||||
'$schema': 'http://json-schema.org/draft-04/schema#',
|
||||
'title': 'School pre-registration',
|
||||
'description': 'Crée une pré-inscription scolaire pour un enfant',
|
||||
'type': 'object',
|
||||
'required': ['numPerson', 'schoolYear', 'dateSubscribe', 'levelCode'],
|
||||
'properties': {
|
||||
'numPerson': {
|
||||
'description': "Numéro de l'enfant",
|
||||
'type': 'string',
|
||||
},
|
||||
'schoolYear': {
|
||||
'description': "Année scolaire",
|
||||
'type': 'string',
|
||||
},
|
||||
'dateSubscribe': {
|
||||
'description': "Date d'inscription",
|
||||
'type': 'string',
|
||||
},
|
||||
'levelCode': {
|
||||
'description': "Le code du niveau scolaire",
|
||||
'type': 'string',
|
||||
},
|
||||
},
|
||||
'unflatten': True,
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
|
|
@ -1998,6 +1998,19 @@ class ToulouseMaelis(BaseResource, HTTPResource):
|
|||
)
|
||||
return {'data': serialize_object(response)}
|
||||
|
||||
@endpoint(
|
||||
display_category='Inscriptions',
|
||||
description="Création d'une pré-inscription scolaire pour un enfant",
|
||||
name='create-child-school-pre-registration',
|
||||
perm='can_access',
|
||||
post={
|
||||
'request_body': {'schema': {'application/json': family_schemas.SCHOOL_PRE_REGISTRATION_SCHEMA}}
|
||||
},
|
||||
)
|
||||
def create_child_school_pre_registration(self, request, post_data):
|
||||
response = self.call('Family', 'preSubscribeSchoolPerim', **post_data)
|
||||
return {'data': serialize_object(response)}
|
||||
|
||||
|
||||
class Link(models.Model):
|
||||
resource = models.ForeignKey(ToulouseMaelis, on_delete=models.CASCADE)
|
||||
|
|
|
@ -200,12 +200,12 @@ def clear_cache():
|
|||
|
||||
|
||||
@pytest.fixture
|
||||
def simple_user():
|
||||
def simple_user(db):
|
||||
return User.objects.create_user('user', password='user')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def admin_user():
|
||||
def admin_user(db):
|
||||
return User.objects.create_superuser('admin', email=None, password='admin')
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
|
||||
<soap:Body>
|
||||
<ns2:preSubscribeSchoolPerimResponse xmlns:ns2="family.ws.maelis.sigec.com">
|
||||
<resultSubscribeBean><subscribeSchoolBean>
|
||||
<year>2023</year>
|
||||
<idSchool>2435</idSchool>
|
||||
<schoolName>DUPONT PIERRE ELEMENTAIRE</schoolName>
|
||||
<levelBean/>
|
||||
<adresse> GRANDE-RUE SAINT MICHEL</adresse>
|
||||
<headmaster>FOURCADE MARIE-SYLVIE</headmaster>
|
||||
<dateIns>2023-09-01T00:00:00+02:00</dateIns>
|
||||
<isWaitList>true</isWaitList>
|
||||
<codeWait>MO_PERIM</codeWait>
|
||||
<libWait>GRU</libWait>
|
||||
</subscribeSchoolBean>
|
||||
</resultSubscribeBean>
|
||||
</ns2:preSubscribeSchoolPerimResponse>
|
||||
</soap:Body>
|
||||
</soap:Envelope>
|
||||
|
|
@ -26,7 +26,9 @@ from django.db import connection
|
|||
from django.db.migrations.executor import MigrationExecutor
|
||||
|
||||
import tests.utils
|
||||
from passerelle.contrib.rsa13.models import RSA13Resource
|
||||
from passerelle.contrib.rsa13.models import DEFAULTS, RSA13Resource, dump_csv_columns
|
||||
|
||||
from .test_manager import login
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -1405,3 +1407,33 @@ def test_csv_columns_migration(transactional_db, settings):
|
|||
assert resource.beneficiaire_csv_columns == 'A 2\nB'
|
||||
assert resource.facturation_csv_columns == 'C\nD'
|
||||
assert resource.sorti_csv_columns == 'E\nF'
|
||||
|
||||
|
||||
def test_manager(app, admin_user):
|
||||
app = login(app)
|
||||
resp = app.get('/manage/')
|
||||
resp = resp.click('Add Connector')
|
||||
resp = resp.click('RSA CD13')
|
||||
resp.forms[0]['title'] = 'Test Connector'
|
||||
resp.forms[0]['slug'] = 'test-connector'
|
||||
resp.forms[0]['description'] = 'Connector for a simple test'
|
||||
resp.forms[0]['webservice_base_url'] = 'https://example.com/'
|
||||
resp = resp.forms[0].submit().follow()
|
||||
assert 'Test Connector' in resp.text
|
||||
|
||||
instance = RSA13Resource.objects.get()
|
||||
for key, value in DEFAULTS.items():
|
||||
assert getattr(instance, key) == dump_csv_columns(value)
|
||||
|
||||
resp = resp.click('Edit')
|
||||
resp.form.set('beneficiaire_csv_columns', 'NUM_CAF')
|
||||
resp.form.set('facturation_csv_columns', 'MATRICULE')
|
||||
resp.form.set('sorti_csv_columns', 'NUM_CAF')
|
||||
resp = resp.form.submit().follow()
|
||||
instance = RSA13Resource.objects.get()
|
||||
for key in DEFAULTS:
|
||||
assert getattr(instance, key) in ['NUM_CAF', 'MATRICULE']
|
||||
|
||||
resp = resp.click('Edit')
|
||||
for key in DEFAULTS:
|
||||
assert resp.form[key].value in ['NUM_CAF', 'MATRICULE']
|
||||
|
|
|
@ -4336,3 +4336,23 @@ def test_read_child_school_subscription_information(family_service, con, app):
|
|||
assert 'rl1Info' in resp.json['data']
|
||||
assert 'childSubscribeSchoolInformation' in resp.json['data']
|
||||
assert 'personSubscribeSchoolList' in resp.json['data']
|
||||
|
||||
|
||||
def test_create_child_school_pre_registration(family_service, con, app):
|
||||
family_service.add_soap_response(
|
||||
'preSubscribeSchoolPerim', get_xml_file('R_create_child_school_pre_registration.xml')
|
||||
)
|
||||
url = get_endpoint('create-child-school-pre-registration')
|
||||
resp = app.post_json(
|
||||
url,
|
||||
params={
|
||||
'numPerson': '248460',
|
||||
'schoolYear': '2023',
|
||||
'levelCode': 'CM1',
|
||||
'dateSubscribe': '2023-09-01T00:00:00+02:00',
|
||||
},
|
||||
)
|
||||
assert resp.json['err'] == 0
|
||||
assert resp.json['data']['subscribeSchoolBean']['idSchool'] == '2435'
|
||||
assert resp.json['data']['subscribeSchoolBean']['schoolName'] == 'DUPONT PIERRE ELEMENTAIRE'
|
||||
assert resp.json['data']['subscribeSchoolBean']['isWaitList']
|
||||
|
|
Loading…
Reference in New Issue