206 lines
6.8 KiB
Python
206 lines
6.8 KiB
Python
import pytest
|
|
import requests
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def school_year(conn):
|
|
url = conn + '/read-school-years-list'
|
|
resp = requests.get(url)
|
|
resp.raise_for_status()
|
|
res = resp.json()
|
|
assert res['err'] == 0
|
|
year = res['data'][0]['text']
|
|
return str(int(year) + 1) # bug ?
|
|
|
|
|
|
@pytest.fixture(scope='session')
|
|
def exemption(conn):
|
|
# get an exemption code
|
|
url = conn + '/read-exemption-reasons-list'
|
|
resp = requests.get(url)
|
|
resp.raise_for_status()
|
|
res = resp.json()
|
|
assert res['err'] == 0
|
|
return res['data'][0]['id']
|
|
|
|
|
|
def test_school_pre_registration_by_sector(conn, create_data, school_year, exemption):
|
|
"""
|
|
Pré-inscription de l'enfant de 7 ans dans son secteur
|
|
"""
|
|
# create a 7 year-old child
|
|
url = conn + '/create-child?NameID=%s' % create_data['name_id']
|
|
payload = {
|
|
'sexe': 'M',
|
|
'firstname': 'Sego',
|
|
'lastname': create_data['lastname'],
|
|
'birth': {'dateBirth': '2016-05-09'},
|
|
}
|
|
resp = requests.post(url, json=payload)
|
|
resp.raise_for_status()
|
|
assert resp.json()['err'] == 0
|
|
sego_id = str(resp.json()['data']['child_id'])
|
|
|
|
# assert there is a school at this address
|
|
url = conn + '/read-schools-for-address-and-level'
|
|
params = {
|
|
'id_street': '2317',
|
|
'num': '4',
|
|
'year': school_year,
|
|
'level': 'CE1',
|
|
}
|
|
resp = requests.get(url, params=params)
|
|
resp.raise_for_status()
|
|
assert resp.json()['err'] == 0
|
|
assert len(resp.json()['data']) == 1
|
|
assert resp.json()['data'][0]['text'] == 'DUPONT PIERRE ELEMENTAIRE'
|
|
|
|
# assert there is a school at child address
|
|
url = conn + '/read-schools-for-child-and-level'
|
|
params = {
|
|
'child_id': sego_id,
|
|
'year': school_year,
|
|
'level': 'CE1',
|
|
}
|
|
resp = requests.get(url, params=params)
|
|
resp.raise_for_status()
|
|
assert resp.json()['err'] == 0
|
|
assert len(resp.json()['data']) == 1
|
|
assert resp.json()['data'][0]['text'] == 'DUPONT PIERRE ELEMENTAIRE'
|
|
|
|
# book
|
|
url = conn + '/create-child-school-pre-registration'
|
|
payload = {
|
|
'numPerson': sego_id,
|
|
'schoolYear': school_year,
|
|
'levelCode': 'CE1',
|
|
'dateSubscribe': school_year + '-01-01',
|
|
}
|
|
resp = requests.get(url)
|
|
resp = requests.post(url, json=payload)
|
|
resp.raise_for_status()
|
|
assert resp.json()['err'] == 0
|
|
assert resp.json()['data']['returnMessage'] is None
|
|
assert resp.json()['data']['subscribeSchoolBean']['schoolName'] == 'DUPONT PIERRE ELEMENTAIRE'
|
|
|
|
"""
|
|
Pré-inscription d'un enfant de 5 ans en CP avec rappprochement de fratrie pour celui de 7 ans :
|
|
rapprochement dans le secteur de l'enfant.
|
|
"""
|
|
# get Sego school
|
|
url = conn + '/read-child-school-informations?NameID=%s' % create_data['name_id']
|
|
params = {
|
|
'child_id': sego_id,
|
|
'year': school_year,
|
|
'level': 'CE1',
|
|
}
|
|
resp = requests.get(url, params=params)
|
|
resp.raise_for_status()
|
|
assert resp.json()['err'] == 0
|
|
data = resp.json()['data']
|
|
schools = data['personSubscribeSchoolList']
|
|
assert len(schools) == 0 # bug ?
|
|
|
|
# get Sego school from read-family
|
|
url = conn + '/read-family?NameID=%s' % create_data['name_id']
|
|
resp = requests.get(url)
|
|
resp.raise_for_status()
|
|
res = resp.json()
|
|
assert res['err'] == 0
|
|
schools = res['data']['childList'][-1]['subscribeSchoolList']
|
|
assert len(schools) == 1
|
|
assert str(schools[0]['year']) == school_year
|
|
assert schools[0]['schoolName'] == 'DUPONT PIERRE ELEMENTAIRE'
|
|
assert schools[0]['isWaitList'] == True
|
|
school_id = schools[0]['idSchool']
|
|
|
|
url = conn + '/create-child-school-pre-registration-with-sibling'
|
|
payload = {
|
|
'numPerson': create_data['maggie_num'],
|
|
'schoolYear': school_year,
|
|
'levelCode': 'GS',
|
|
'datePresubscribe': school_year + '-01-01',
|
|
'idSchoolRequested': school_id,
|
|
'numPersonSibling': sego_id,
|
|
}
|
|
resp = requests.get(url)
|
|
resp = requests.post(url, json=payload)
|
|
resp.raise_for_status()
|
|
assert resp.json()['err'] == 0
|
|
assert 'returnMessage' not in resp.json()
|
|
assert resp.json()['data']['schoolName'] == 'DUPONT PIERRE ELEMENTAIRE'
|
|
|
|
|
|
def test_school_pre_registration_by_exemption(conn, create_data, school_year, exemption):
|
|
"""
|
|
Pré-inscription de l'enfant de 9 ans en dérogation :
|
|
c'est une dérogation avec sélection du motif sur un établissement hors secteur
|
|
"""
|
|
# school list
|
|
url = conn + '/read-child-school-informations?NameID=%s' % create_data['name_id']
|
|
params = {
|
|
'child_id': create_data['bart_num'],
|
|
'year': school_year,
|
|
'level': 'CM1',
|
|
}
|
|
resp = requests.get(url, params=params)
|
|
resp.raise_for_status()
|
|
assert resp.json()['err'] == 0
|
|
data = resp.json()['data']
|
|
schools = data['childSubscribeSchoolInformation']['subscribeSchoolInformation']['derogSchoolList']
|
|
assert len(schools) > 1
|
|
school_id = schools[0]['id']
|
|
|
|
# book
|
|
url = conn + '/create-child-school-pre-registration-with-exemption'
|
|
payload = {
|
|
'numPerson': create_data['bart_num'],
|
|
'schoolYear': school_year,
|
|
'levelCode': 'CM1',
|
|
'datePresubscribe': school_year + '-01-01',
|
|
'idRequestSchool1': school_id,
|
|
'derogReasonCode': exemption,
|
|
'derogComment': 'bla',
|
|
}
|
|
resp = requests.get(url)
|
|
resp = requests.post(url, json=payload)
|
|
resp.raise_for_status()
|
|
assert resp.json()['err'] == 0
|
|
assert 'returnMessage' not in resp.json()
|
|
assert resp.json()['data']['schoolName'] == 'AMIDONNIERS ELEMENTAIRE'
|
|
|
|
"""
|
|
Pré-inscription de l'autre enfant de 5 ans en CP
|
|
avec rapprochement de fratrie pour celui de 9 ans :
|
|
rapprochement hors du secteur de l'enfant.
|
|
"""
|
|
# get Bart school from read-family
|
|
url = conn + '/read-family?NameID=%s' % create_data['name_id']
|
|
resp = requests.get(url)
|
|
resp.raise_for_status()
|
|
res = resp.json()
|
|
assert res['err'] == 0
|
|
schools = res['data']['childList'][0]['subscribeSchoolList']
|
|
assert len(schools) == 1
|
|
assert str(schools[0]['year']) == school_year
|
|
assert schools[0]['schoolName'] == 'AMIDONNIERS ELEMENTAIRE'
|
|
assert schools[0]['isWaitList'] == True
|
|
school_id = schools[0]['idSchool']
|
|
|
|
# book
|
|
url = conn + '/create-child-school-pre-registration-with-sibling'
|
|
payload = {
|
|
'numPerson': create_data['hugo_num'],
|
|
'schoolYear': school_year,
|
|
'levelCode': 'GS',
|
|
'datePresubscribe': school_year + '-01-01',
|
|
'idSchoolRequested': school_id,
|
|
'numPersonSibling': create_data['bart_num'],
|
|
}
|
|
resp = requests.get(url)
|
|
resp = requests.post(url, json=payload)
|
|
resp.raise_for_status()
|
|
assert resp.json()['err'] == 0
|
|
assert 'returnMessage' not in resp.json()
|
|
assert resp.json()['data']['schoolName'] == 'AMIDONNIERS ELEMENTAIRE'
|