diff --git a/functests/toulouse_maelis/conftest.py b/functests/toulouse_maelis/conftest.py
index 26cc3da3..9564ed71 100644
--- a/functests/toulouse_maelis/conftest.py
+++ b/functests/toulouse_maelis/conftest.py
@@ -182,6 +182,9 @@ FAMILY_PAYLOAD = {
'lastname': 'Simpson',
'birth': {'dateBirth': '1989-12-17'},
'dietcode': 'BB',
+ 'paiInfoBean': {
+ 'code': 'PAIALI',
+ },
},
],
'emergencyPersonList': [
@@ -223,6 +226,9 @@ def pytest_addoption(parser):
)
parser.addoption('--nameid', help='Publik Name ID', default='functest')
parser.addoption('--dui', help='DUI number', default='')
+ parser.addoption(
+ '--lastname', help='override lastname to create a new "update" family', default='Simpson'
+ )
def unlink(conn, name_id):
@@ -351,7 +357,7 @@ def referentials(conn):
@pytest.fixture(scope='session')
-def create_data(request, conn, referentials):
+def create_data(request, conn):
name_id = request.config.getoption('--nameid')
unlink(conn, name_id)
lastname = uuid4().hex[0:30]
@@ -376,23 +382,24 @@ def create_data(request, conn, referentials):
'name_id': name_id, # linked
'family_id': str(create_result['data']['number']),
'lastname': lastname,
+ 'rl1_num': data['RL1']['num'],
'family_payload': create_family_payload,
'data': data,
}
@pytest.fixture(scope='session')
-def update_data(request, conn, referentials):
+def update_data(request, conn):
name_id = request.config.getoption('--nameid')
+ lastname = request.config.getoption('--lastname')
unlink(conn, name_id)
- debug = False # True allow to create then update a new family
- if debug:
- lastname = 'something new'
- FAMILY_PAYLOAD['rl1']['lastname'] = lastname
- FAMILY_PAYLOAD['rl2']['lastname'] = lastname
- for child in FAMILY_PAYLOAD['childList']:
- child['lastname'] = lastname
+ # allow to create then update a new family if current is broken,
+ # using --lastname option
+ FAMILY_PAYLOAD['rl1']['lastname'] = lastname
+ FAMILY_PAYLOAD['rl2']['lastname'] = lastname
+ for child in FAMILY_PAYLOAD['childList']:
+ child['lastname'] = lastname
# try to re-create test family
url = conn + '/create-family?NameID=%s' % name_id
@@ -432,16 +439,13 @@ def update_data(request, conn, referentials):
resp = requests.post(url, json=update_family_payload)
resp.raise_for_status()
assert resp.json()['err'] == 0
-
- if debug:
- data = read_family(conn, name_id)
- else:
- data = diff_family(conn, name_id, 'test_update_family.json')
+ data = diff_family(conn, name_id, 'test_update_family.json')
return {
'name_id': name_id, # linked
'family_id': family_id,
'family_payload': update_family_payload,
+ 'lastname': lastname,
'rl2_num': data['RL2']['num'],
'bart_num': data['childList'][0]['num'],
'lisa_num': data['childList'][1]['num'],
diff --git a/functests/toulouse_maelis/data/test_create_family.json b/functests/toulouse_maelis/data/test_create_family.json
index ecfa7360..12ee696c 100644
--- a/functests/toulouse_maelis/data/test_create_family.json
+++ b/functests/toulouse_maelis/data/test_create_family.json
@@ -188,7 +188,13 @@
"indicatorList": [],
"medicalRecord": null,
"insurance": null,
- "paiInfoBean": null,
+ "paiInfoBean": {
+ "code": "PAIALI",
+ "dateDeb": null,
+ "dateFin": null,
+ "description": null,
+ "code_text": "ALIMENTAIRE"
+ },
"mother": "N/A",
"father": "N/A",
"rl": null,
diff --git a/functests/toulouse_maelis/data/test_update_quotient.json b/functests/toulouse_maelis/data/test_update_quotient.json
new file mode 100644
index 00000000..a257f05a
--- /dev/null
+++ b/functests/toulouse_maelis/data/test_update_quotient.json
@@ -0,0 +1,29 @@
+[
+ {
+ "yearRev": 2021,
+ "dateStart": "2022-01-02T00:00:00+01:00",
+ "dateEnd": "2022-12-31T00:00:00+01:00",
+ "mtt": 1500.33,
+ "cdquo": "QS",
+ "codeUti": null,
+ "cdquo_text": "QUOTIENT SCOLAIRE"
+ },
+ {
+ "yearRev": 2020,
+ "dateStart": "2022-01-02T00:00:00+01:00",
+ "dateEnd": "2022-12-31T00:00:00+01:00",
+ "mtt": 1500.33,
+ "cdquo": "QS",
+ "codeUti": null,
+ "cdquo_text": "QUOTIENT SCOLAIRE"
+ },
+ {
+ "yearRev": 2021,
+ "dateStart": "2022-01-01T00:00:00+01:00",
+ "dateEnd": "2022-01-01T00:00:00+01:00",
+ "mtt": 1500.33,
+ "cdquo": "QS",
+ "codeUti": null,
+ "cdquo_text": "QUOTIENT SCOLAIRE"
+ }
+]
diff --git a/functests/toulouse_maelis/read_family.py b/functests/toulouse_maelis/read_family.py
index 7ab6ae1e..fabd7e03 100755
--- a/functests/toulouse_maelis/read_family.py
+++ b/functests/toulouse_maelis/read_family.py
@@ -21,7 +21,7 @@ def read_family(family_id, verbose):
result = client.service.readFamily(
dossierNumber=family_id,
# schoolYear=
- # incomeYear=2020, # <-- pour avoir les quotients
+ # incomeYear=2022, # <-- pour filtrer les quotients sur cette année
# referenceYear=2020,
)
print(result)
diff --git a/functests/toulouse_maelis/test_family.py b/functests/toulouse_maelis/test_family.py
index a8e331b8..722d2c44 100644
--- a/functests/toulouse_maelis/test_family.py
+++ b/functests/toulouse_maelis/test_family.py
@@ -189,6 +189,11 @@ def test_update_family(conn, update_data):
# reset fields
family_reset_payload = copy.deepcopy(FAMILY_RESET_PAYLOAD)
+ family_reset_payload['rl1']['lastname'] = update_data['lastname']
+ family_reset_payload['rl2']['lastname'] = update_data['lastname']
+ for child in family_reset_payload['childList']:
+ child['lastname'] = update_data['lastname']
+
family_reset_payload['childList'][0]['num'] = update_data['family_payload']['childList'][0]['num']
resp = requests.post(url, json=family_reset_payload)
resp.raise_for_status()
@@ -323,6 +328,7 @@ def test_update_rlg(conn, update_data, rl):
# reset responsable legal
payload = copy.deepcopy(FAMILY_RESET_PAYLOAD[rlg])
+ payload['lastname'] = update_data['lastname']
for key in 'adresse', 'contact', 'profession', 'CAFInfo', 'indicatorList':
if key in payload:
del payload[key]
@@ -361,7 +367,7 @@ def test_update_rlg(conn, update_data, rl):
)
# update birtday is refused
- payload['lastname'] = 'Simpson'
+ payload['lastname'] = update_data['lastname']
payload['birth']['dateBirth'] = '1970-01-01'
resp = requests.post(url, json=payload)
resp.raise_for_status()
@@ -752,3 +758,57 @@ def test_update_child_indicator(conn, update_data):
resp.raise_for_status()
assert resp.json()['err'] == 0
assert diff_family(conn, update_data['name_id'], 'test_update_family.json')
+
+
+def test_update_quotient(conn, create_data):
+ unlink(conn, create_data['name_id'])
+ link(conn, create_data)
+
+ # add quotient
+ url = conn + '/update-quotient?NameID=%s&rl_id=%s' % (create_data['name_id'], create_data['rl1_num'])
+ payload = {
+ 'yearRev': '2021',
+ 'dateStart': '2022-01-01',
+ 'dateEnd': '2022-12-31',
+ 'mtt': '1500.33',
+ 'cdquo': 'QS',
+ }
+ resp = requests.post(url, json=payload)
+ resp.raise_for_status()
+ assert resp.json()['err'] == 0
+ data = read_family(conn, create_data['name_id'])
+ assert data['RL1']['quotientList'] == [
+ {
+ 'yearRev': 2021,
+ 'dateStart': '2022-01-01T00:00:00+01:00',
+ 'dateEnd': '2022-12-31T00:00:00+01:00',
+ 'mtt': 1500.33,
+ 'cdquo': 'QS',
+ 'codeUti': None,
+ 'cdquo_text': 'QUOTIENT SCOLAIRE',
+ }
+ ]
+
+ # add quotient
+ payload['dateStart'] = '2022-01-02'
+ resp = requests.post(url, json=payload)
+ resp.raise_for_status()
+ assert resp.json()['err'] == 0
+ data = read_family(conn, create_data['name_id'])
+ assert len(data['RL1']['quotientList']) == 2
+
+ # add quotient on another income year
+ payload['yearRev'] = '2020'
+ resp = requests.post(url, json=payload)
+ resp.raise_for_status()
+ assert resp.json()['err'] == 0
+ data = diff_rlg(conn, create_data['name_id'], 1, 'test_update_quotient.json', 'quotientList')
+ assert len(data['RL1']['quotientList']) == 3
+
+ # test read-family with reference year
+ url = conn + '/read-family?NameID=%s&income_year=%s' % (create_data['name_id'], '2020')
+ resp = requests.get(url)
+ resp.raise_for_status()
+ res = resp.json()
+ assert res['err'] == 0
+ return len(res['data']['RL1']['quotientList']) == 1
diff --git a/functests/toulouse_maelis/test_misc.py b/functests/toulouse_maelis/test_misc.py
index f6b9fa14..8c8664e5 100644
--- a/functests/toulouse_maelis/test_misc.py
+++ b/functests/toulouse_maelis/test_misc.py
@@ -51,9 +51,5 @@ def test_link(conn, update_data):
resp = requests.post(url, json=payload)
resp.raise_for_status()
res = resp.json()
- assert res == {
- 'err': 'not-found',
- 'err_class': 'passerelle.utils.jsonresponse.APIError',
- 'err_desc': "RL1 does not match '196947' family",
- 'data': None,
- }
+ assert res['err'] == 'not-found'
+ assert 'RL1 does not match' in res['err_desc']
diff --git a/passerelle/contrib/rsa13/models.py b/passerelle/contrib/rsa13/models.py
index 28b74839..08489f8c 100644
--- a/passerelle/contrib/rsa13/models.py
+++ b/passerelle/contrib/rsa13/models.py
@@ -22,7 +22,7 @@ from django.db import models
from django.http import HttpResponse
from django.urls import reverse
from django.utils.http import urlencode
-from django.utils.timezone import now
+from django.utils.timezone import localtime, now
from django.utils.translation import gettext_lazy as _
from passerelle.base.models import BaseResource, HTTPResource
@@ -665,7 +665,7 @@ class RSA13Resource(BaseResource, HTTPResource):
if locals().get(key):
params[key] = locals()[key]
content = self.get('platform/%s/beneficiaire/csv/' % platform_id, email=email, ip=ip, params=params)
- date = now().strftime('%Y-%m-%d_%H:%M')
+ date = localtime(now()).strftime('%Y-%m-%d_%H:%M')
return self.csv_response('beneficiaire', data=content['data'], filename=f'beneficiaire-{date}.csv')
@endpoint(
@@ -1963,7 +1963,7 @@ class RSA13Resource(BaseResource, HTTPResource):
):
url = 'platform/%s/beneficiaire/sorti/csv' % platform_id
content = self.get(url, email=email, ip=ip)
- date = now().strftime('%Y-%m-%d_%H:%M')
+ date = localtime(now()).strftime('%Y-%m-%d_%H:%M')
return self.csv_response(
'sorti', data=content.get('data') or [], filename=f'beneficiaire-sorti-{date}.csv'
)
diff --git a/passerelle/contrib/tcl/models.py b/passerelle/contrib/tcl/models.py
index 5ae31ea7..bacfaf8c 100644
--- a/passerelle/contrib/tcl/models.py
+++ b/passerelle/contrib/tcl/models.py
@@ -127,7 +127,7 @@ class Tcl(BaseResource):
with transaction.atomic():
for key in ('tcllignebus', 'tcllignemf', 'tcllignetram'):
- url = get_tcl_data_url(key)
+ url = get_tcl_data_url(key + '_2_0_0')
response = self.requests.get(url)
response.raise_for_status()
for line_data in response.json()['values']:
@@ -139,6 +139,7 @@ class Tcl(BaseResource):
code_titan=line_data['code_titan'],
defaults={'transport_key': key, 'ligne': line_data['ligne']},
)
+ line.ut = None
line.__dict__.update(line_data)
line.transport_key = key
line.save()
diff --git a/passerelle/contrib/toulouse_maelis/models.py b/passerelle/contrib/toulouse_maelis/models.py
index b44e60b9..5eb636aa 100644
--- a/passerelle/contrib/toulouse_maelis/models.py
+++ b/passerelle/contrib/toulouse_maelis/models.py
@@ -187,13 +187,13 @@ class ToulouseMaelis(BaseResource, HTTPResource):
except Link.DoesNotExist:
raise APIError('User not linked to family', err_code='not-linked')
- def get_family_raw(self, family_id):
- response = self.call('Family', 'readFamily', dossierNumber=family_id)
+ def get_family_raw(self, family_id, **kwargs):
+ response = self.call('Family', 'readFamily', dossierNumber=family_id, **kwargs)
data = serialize_object(response)
return data
- def get_rl_raw(self, family_id, rl_id):
- data = self.get_family_raw(family_id)
+ def get_rl_raw(self, family_id, rl_id, **kwargs):
+ data = self.get_family_raw(family_id, **kwargs)
if data['RL1']['num'] == rl_id:
return data['RL1']
elif data['RL2'] and data['RL2']['num'] == rl_id:
@@ -275,6 +275,8 @@ class ToulouseMaelis(BaseResource, HTTPResource):
self.add_text_value('Organ', data, ['CAFInfo', 'organ'])
for indicator in data['indicatorList']:
self.add_text_value_to_rl_indicator(indicator)
+ for quotient in data['quotientList']:
+ self.add_text_value('Quotient', quotient, ['cdquo'])
# sort indicators
if data['indicatorList']:
@@ -307,13 +309,13 @@ class ToulouseMaelis(BaseResource, HTTPResource):
self.add_text_value_to_person(data)
return data
- def get_rl(self, family_id, rl_id):
- data = self.get_rl_raw(family_id, rl_id)
+ def get_rl(self, family_id, rl_id, **kwargs):
+ data = self.get_rl_raw(family_id, rl_id, **kwargs)
self.add_text_value_to_rl(data)
return data
- def get_family(self, family_id):
- data = self.get_family_raw(family_id)
+ def get_family(self, family_id, **kwargs):
+ data = self.get_family_raw(family_id, **kwargs)
self.add_text_value_to_family(data)
return data
@@ -727,11 +729,14 @@ class ToulouseMaelis(BaseResource, HTTPResource):
description='Informations sur la famille',
perm='can_access',
name='read-family',
- parameters={'NameID': {'description': 'Publik NameID'}},
+ parameters={
+ 'NameID': {'description': 'Publik NameID'},
+ 'income_year': {'description': 'Année de revenu pour filtrer les quotients'},
+ },
)
- def read_family(self, request, NameID):
+ def read_family(self, request, NameID, income_year=None):
family_id = self.get_link(NameID).family_id
- data = self.get_family(family_id)
+ data = self.get_family(family_id, incomeYear=income_year)
return {'data': data}
@endpoint(
@@ -742,11 +747,12 @@ class ToulouseMaelis(BaseResource, HTTPResource):
parameters={
'NameID': {'description': 'Publik NameID'},
'rl_id': {'description': 'Numéro du représentant légal'},
+ 'income_year': {'description': 'Année de revenu pour filtrer les quotients'},
},
)
- def read_rl(self, request, NameID, rl_id):
+ def read_rl(self, request, NameID, rl_id, income_year=None):
family_id = self.get_link(NameID).family_id
- data = self.get_rl(family_id, rl_id)
+ data = self.get_rl(family_id, rl_id, incomeYear=income_year)
return {'data': data}
@endpoint(
@@ -1086,6 +1092,29 @@ class ToulouseMaelis(BaseResource, HTTPResource):
self.call('Family', 'updatePersonIndicatorList', numPerson=rl_id, **post_data)
return {'data': 'ok'}
+ @endpoint(
+ display_category='Famille',
+ description="Créer ou mettre à jour un quotient d'un responsable légal",
+ name='update-quotient',
+ perm='can_access',
+ parameters={
+ 'NameID': {'description': 'Publik NameID'},
+ 'rl_id': {'description': "Numéro du responsable légal"},
+ },
+ post={'request_body': {'schema': {'application/json': schemas.UPDATE_QUOTIENT_SCHEMA}}},
+ )
+ def update_quotient(self, request, NameID, rl_id, post_data):
+ family_id = self.get_link(NameID).family_id
+ self.assert_post_data_in_referential('Quotient', post_data, ['cdquo'])
+
+ payload = {
+ 'dossierNumber': family_id,
+ 'personNumber': rl_id,
+ 'quotient': post_data,
+ }
+ self.call('Family', 'createUpdateQuotient', **payload)
+ return {'data': 'ok'}
+
@endpoint(
display_category='Famille',
description="Création d'une personne à prévenir en cas d'urgence",
diff --git a/passerelle/contrib/toulouse_maelis/schemas.py b/passerelle/contrib/toulouse_maelis/schemas.py
index d6573420..03854375 100644
--- a/passerelle/contrib/toulouse_maelis/schemas.py
+++ b/passerelle/contrib/toulouse_maelis/schemas.py
@@ -720,3 +720,39 @@ UPDATE_INDICATOR_SCHEMA = {
'additionalProperties': False,
'unflatten': True,
}
+
+UPDATE_QUOTIENT_SCHEMA = {
+ '$schema': 'http://json-schema.org/draft-04/schema#',
+ 'title': 'Family persons',
+ 'description': "Mise à jours des quotients sur les responsables légaux",
+ 'type': 'object',
+ 'required': ['yearRev', 'dateStart', 'dateEnd', 'mtt', 'cdquo'],
+ 'properties': {
+ 'yearRev': {
+ 'description': 'Année de revenu',
+ 'type': 'string',
+ 'pattern': '^[0-9]{4}$',
+ },
+ 'dateStart': {
+ 'description': 'Date de début',
+ 'type': 'string',
+ 'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$',
+ },
+ 'dateEnd': {
+ 'description': 'Date de fin',
+ 'type': 'string',
+ 'pattern': '^[0-9]{4}-[0-9]{2}-[0-9]{2}$',
+ },
+ 'mtt': {
+ 'description': 'Montant',
+ 'type': 'string',
+ 'pattern': r'^[0-9]+\.?[0-9]*$',
+ },
+ 'cdquo': {
+ 'description': 'Code du quotient (depuis référentiel)',
+ 'type': 'string',
+ 'pattern': '.+',
+ },
+ },
+ 'additionalProperties': False,
+}
diff --git a/tests/data/toulouse_maelis/Q_create_update_quotient.xml b/tests/data/toulouse_maelis/Q_create_update_quotient.xml
new file mode 100644
index 00000000..0d519a11
--- /dev/null
+++ b/tests/data/toulouse_maelis/Q_create_update_quotient.xml
@@ -0,0 +1,23 @@
+
+
+
+
+ maelis-webservice
+ maelis-password
+
+
+
+
+
+ 1312
+ 613878
+
+ 2021
+ 2022-10-01
+ 2023-01-31
+ 1500.33
+ QS
+
+
+
+
diff --git a/tests/data/toulouse_maelis/R_create_update_quotient.xml b/tests/data/toulouse_maelis/R_create_update_quotient.xml
new file mode 100644
index 00000000..76428f17
--- /dev/null
+++ b/tests/data/toulouse_maelis/R_create_update_quotient.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/tests/data/toulouse_maelis/R_create_update_quotient_soap_error.xml b/tests/data/toulouse_maelis/R_create_update_quotient_soap_error.xml
new file mode 100644
index 00000000..1e86f858
--- /dev/null
+++ b/tests/data/toulouse_maelis/R_create_update_quotient_soap_error.xml
@@ -0,0 +1,13 @@
+
+
+
+ soap:Server
+ E07 : Il existe déjà un quotient postérieur pour cette période
+
+
+ E07 : Il existe déjà un quotient postérieur pour cette période
+
+
+
+
+
diff --git a/tests/data/toulouse_maelis/R_read_family.xml b/tests/data/toulouse_maelis/R_read_family.xml
index 705a02cc..b23d33cd 100644
--- a/tests/data/toulouse_maelis/R_read_family.xml
+++ b/tests/data/toulouse_maelis/R_read_family.xml
@@ -45,6 +45,20 @@
AVL
+
+ 2020
+ 2021-01-01T00:00:00+01:00
+ 2021-12-31T00:00:00+01:00
+ 1500.33
+ QS
+
+
+ 2021
+ 2022-01-01T00:00:00+01:00
+ 2022-12-31T00:00:00+01:00
+ 1500.44
+ MOY ECO
+
613879
diff --git a/tests/data/toulouse_maelis/R_read_family_relax.xml b/tests/data/toulouse_maelis/R_read_family_relax.xml
index 1463719e..37f9e649 100644
--- a/tests/data/toulouse_maelis/R_read_family_relax.xml
+++ b/tests/data/toulouse_maelis/R_read_family_relax.xml
@@ -45,6 +45,20 @@
AVL
+
+ 2020
+ 2021-01-01T00:00:00+01:00
+ 2021-12-31T00:00:00+01:00
+ 1500.33
+ QS
+
+
+ 2021
+ 2022-01-01T00:00:00+01:00
+ 2022-12-31T00:00:00+01:00
+ 1500.44
+ MOY ECO
+
613879
diff --git a/tests/data/toulouse_maelis/R_read_family_reordered.xml b/tests/data/toulouse_maelis/R_read_family_reordered.xml
index c4318ba7..8186cc29 100644
--- a/tests/data/toulouse_maelis/R_read_family_reordered.xml
+++ b/tests/data/toulouse_maelis/R_read_family_reordered.xml
@@ -45,6 +45,20 @@
AVL
+
+ 2020
+ 2021-01-01T00:00:00+01:00
+ 2021-12-31T00:00:00+01:00
+ 1500.33
+ QS
+
+
+ 2021
+ 2022-01-01T00:00:00+01:00
+ 2022-12-31T00:00:00+01:00
+ 1500.44
+ MOY ECO
+
613879
diff --git a/tests/data/toulouse_maelis/R_read_family_with_income_year.xml b/tests/data/toulouse_maelis/R_read_family_with_income_year.xml
new file mode 100644
index 00000000..c7d708e0
--- /dev/null
+++ b/tests/data/toulouse_maelis/R_read_family_with_income_year.xml
@@ -0,0 +1,211 @@
+
+
+
+
+ 1312
+ BI
+ M
+ true
+ 2
+
+ 613878
+ DOE
+ JHON
+ PERE
+ M.
+
+ 1938-07-26T00:00:00+01:00
+ Rabbat
+ 99350
+
+
+
+ 170
+ Chateau d'eau
+ Paris
+ 75014
+
+
+ non
+ 0777777777
+ djhon@example.org
+ true
+ true
+ true
+
+
+
+
+
+ 2020
+ 2021-01-01T00:00:00+01:00
+ 2021-12-31T00:00:00+01:00
+ 1500.33
+ QS
+
+
+
+ 613879
+ DOE
+ JANE
+ SMITH
+ MERE
+ MME
+
+ 1940-06-22T00:00:00+02:00
+ Bardot
+ 99351
+
+
+
+ 170
+ Chateau d'eau
+ Paris
+ 75014
+
+
+ false
+ false
+ false
+
+
+ ART
+ informaticien
+ EO
+ 0123456789
+
+ Orléans
+
+
+
+ 789
+ A10007752822
+
+
+
+ 614059
+ MME
+ KENY
+ ARKANA
+ 1982-12-20T00:00:00+01:00
+ T
+
+ 0123456789
+ pueblo@example.org
+
+
+
+ 613880
+ DOE
+ JANNIS
+ F
+
+ 1943-01-19T00:00:00+01:00
+ Saint-louis
+ 91122
+ 99100
+
+ RSV
+ true
+ false
+
+
+ 614719
+ BENT
+ AMEL
+ 1985-06-21T00:00:00+02:00
+ MME
+ F
+
+ 0123456789
+ 0623456789
+ abent@example.org
+
+
+
+ T
+ TANTE
+
+
+
+
+ DRE
+ 0612341234
+
+ Alameda
+ 90220
+ Compton
+
+
+ butterscotch, imitation butterscotch, glow-in-the-dark monster make-up
+ shrimp and cauliflower
+ the shrimp allergy isn't fully identified
+ Ay Caramba!
+ Eat my shorts!
+ true
+ Springfield General Hospital
+
+ ROR
+
+ 2012-02-22T00:00:00+01:00
+
+
+ DTC
+
+ 2011-01-11T00:00:00+01:00
+
+
+ ROR
+
+ 1970-01-11T00:00:00+01:00
+
+
+
+ 613963
+ MME
+ JANE
+ DOE
+
+
+ 613878
+ M.
+ JHON
+ DOE
+
+
+ PAIALI
+ 2022-01-01T00:00:00+01:00
+ 2022-12-31T00:00:00+01:00
+ bla bla PAI
+
+
+
+ 613987
+ DOE
+ JOHNNY ALLEN
+ M
+
+ 1942-11-27T00:00:00+01:00
+ Seattle
+
+ false
+ false
+
+
+
+ 614051
+ DOE
+ ROBERT
+ M
+
+ 1941-05-24T00:00:00+02:00
+ Duluth
+
+ true
+ false
+
+
+
+
+
+
diff --git a/tests/test_tcl.py b/tests/test_tcl.py
index 13c1472a..fa11c819 100644
--- a/tests/test_tcl.py
+++ b/tests/test_tcl.py
@@ -115,9 +115,9 @@ def connector(db):
def tcl_responses(url, **kwargs):
content = {
- '/tcllignebus': LIGNE_BUS,
- '/tcllignemf': LIGNE_MF,
- '/tcllignetram': LIGNE_TRAM,
+ '/tcllignebus_2_0_0': LIGNE_BUS,
+ '/tcllignemf_2_0_0': LIGNE_MF,
+ '/tcllignetram_2_0_0': LIGNE_TRAM,
'/geojson/tclarret': ARRETS,
'/tclpassagearret': PASSAGES,
}.get(urlparse.urlparse(url).path)
diff --git a/tests/test_toulouse_maelis.py b/tests/test_toulouse_maelis.py
index 773af074..1137efe0 100644
--- a/tests/test_toulouse_maelis.py
+++ b/tests/test_toulouse_maelis.py
@@ -44,6 +44,9 @@ ISWSRUNNING_FALSE = FakedResponse(content=get_xml_file('R_is_ws_running.xml') %
READ_FAMILY = FakedResponse(content=get_xml_file('R_read_family.xml'), status_code=200)
READ_FAMILY_LAX = FakedResponse(content=get_xml_file('R_read_family_relax.xml'), status_code=200)
READ_FAMILY_ORD = FakedResponse(content=get_xml_file('R_read_family_reordered.xml'), status_code=200)
+READ_FAMILY_QUOTIENT = FakedResponse(
+ content=get_xml_file('R_read_family_with_income_year.xml'), status_code=200
+)
READ_RL1_FAMILY = FakedResponse(content=get_xml_file('R_read_family_with_only_rl1.xml'), status_code=200)
IS_RL_EXISTS_TRUE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'true', status_code=200)
IS_RL_EXISTS_FALSE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'false', status_code=200)
@@ -58,6 +61,10 @@ CREATE_CHILD_ERR = FakedResponse(content=get_xml_file('R_create_child_error.xml'
UPDATE_FAMILY = FakedResponse(content=get_xml_file('R_update_family.xml'), status_code=200)
UPDATE_FAMILY_ERR = FakedResponse(content=get_xml_file('R_update_family_error.xml'), status_code=200)
UPDATE_FAMILY_500 = FakedResponse(content=get_xml_file('R_update_family_soap_error.xml'), status_code=500)
+UPDATE_QUOTIENT = FakedResponse(content=get_xml_file('R_create_update_quotient.xml'), status_code=200)
+UPDATE_QUOTIENT_500 = FakedResponse(
+ content=get_xml_file('R_create_update_quotient_soap_error.xml'), status_code=500
+)
UPDATE_DIETCODE = FakedResponse(content=get_xml_file('R_update_child_dietcode.xml'), status_code=200)
UPDATE_PAI = FakedResponse(content=get_xml_file('R_update_child_pai.xml'), status_code=200)
UPDATE_PAI_500 = FakedResponse(content=get_xml_file('R_update_child_pai_soap_error.xml'), status_code=500)
@@ -705,7 +712,6 @@ def test_read_family(mocked_post, mocked_get, read_family, con, app):
'CAFInfo': None,
'civility_text': 'Monsieur',
'quality_text': 'PERE',
- 'quotientList': [],
'indicatorList': [
{
'choice': None,
@@ -722,6 +728,26 @@ def test_read_family(mocked_post, mocked_get, read_family, con, app):
'note': 'SNPP',
},
],
+ 'quotientList': [
+ {
+ 'cdquo': 'QS',
+ 'cdquo_text': 'QUOTIENT SCOLAIRE',
+ 'codeUti': None,
+ 'dateEnd': '2021-12-31T00:00:00+01:00',
+ 'dateStart': '2021-01-01T00:00:00+01:00',
+ 'mtt': 1500.33,
+ 'yearRev': 2020,
+ },
+ {
+ 'cdquo': 'MOY ECO',
+ 'cdquo_text': 'REVENU MOYEN ( MENSUEL OU ANNUEL)',
+ 'codeUti': None,
+ 'dateEnd': '2022-12-31T00:00:00+01:00',
+ 'dateStart': '2022-01-01T00:00:00+01:00',
+ 'mtt': 1500.44,
+ 'yearRev': 2021,
+ },
+ ],
'subscribeActivityList': [],
}
data = resp.json['data']['childList'][0]
@@ -862,6 +888,29 @@ def test_read_rl1(mocked_post, mocked_get, con, app):
assert resp.json['data']['firstname'] == 'JHON'
+@mock.patch('passerelle.utils.Request.get')
+@mock.patch('passerelle.utils.Request.post')
+def test_read_rl1_with_income_year(mocked_post, mocked_get, con, app):
+ mocked_get.return_value = FAMILY_SERVICE_WSDL
+ mocked_post.return_value = READ_FAMILY_QUOTIENT
+ url = get_endpoint('read-rl')
+ Link.objects.create(resource=con, family_id='1312', name_id='local')
+
+ resp = app.get(url + '?NameID=local&rl_id=613878&income_year=2020')
+ assert resp.json['err'] == 0
+ assert resp.json['data']['quotientList'] == [
+ {
+ 'yearRev': 2020,
+ 'dateStart': '2021-01-01T00:00:00+01:00',
+ 'dateEnd': '2021-12-31T00:00:00+01:00',
+ 'mtt': 1500.33,
+ 'cdquo': 'QS',
+ 'cdquo_text': 'QUOTIENT SCOLAIRE',
+ 'codeUti': None,
+ }
+ ]
+
+
@mock.patch('passerelle.utils.Request.get')
@mock.patch('passerelle.utils.Request.post')
def test_read_rl2(mocked_post, mocked_get, con, app):
@@ -2111,6 +2160,79 @@ def test_update_coordinate_wrong_referential_key_error(mocked_post, mocked_get,
)
+@mock.patch('passerelle.utils.Request.get')
+@mock.patch('passerelle.utils.Request.post')
+def test_update_quotient(mocked_post, mocked_get, con, app):
+ mocked_get.return_value = FAMILY_SERVICE_WSDL
+ mocked_post.return_value = UPDATE_QUOTIENT
+ url = get_endpoint('update-quotient')
+ params = {
+ 'yearRev': '2021',
+ 'dateStart': '2022-10-01',
+ 'dateEnd': '2023-01-31',
+ 'mtt': '1500.33',
+ 'cdquo': 'QS',
+ }
+
+ Link.objects.create(resource=con, family_id='1312', name_id='local')
+ resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params)
+ assert_sent_payload(mocked_post, 'Q_create_update_quotient.xml')
+ assert resp.json['err'] == 0
+ assert resp.json['data'] == 'ok'
+
+
+def test_update_quotient_schema_error(con, app):
+ url = get_endpoint('update-quotient')
+ params = {
+ 'yearRev': '2021',
+ 'dateStart': '2022-10-01',
+ 'dateEnd': '2023-01-31',
+ 'mtt': '1500,33',
+ 'cdquo': 'QS',
+ }
+
+ Link.objects.create(resource=con, family_id='1312', name_id='local')
+ resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params, status=400)
+ assert resp.json['err'] == 1
+ assert resp.json['err_desc'] == "mtt: '1500,33' does not match '^[0-9]+\\\\.?[0-9]*$'"
+
+
+@mock.patch('passerelle.utils.Request.get')
+@mock.patch('passerelle.utils.Request.post')
+def test_update_quotient_soap_error(mocked_post, mocked_get, con, app):
+ mocked_get.return_value = FAMILY_SERVICE_WSDL
+ mocked_post.return_value = UPDATE_QUOTIENT_500
+ url = get_endpoint('update-quotient')
+ params = {
+ 'yearRev': '2021',
+ 'dateStart': '2022-10-01',
+ 'dateEnd': '2023-01-31',
+ 'mtt': '1500.33',
+ 'cdquo': 'QS',
+ }
+
+ Link.objects.create(resource=con, family_id='1312', name_id='local')
+ resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params)
+ assert resp.json['err'] == 'Family-createUpdateQuotient-soap:Server'
+ assert 'E07 : Il existe déjà un quotient postérieur' in resp.json['err_desc']
+
+
+def test_update_quotient_wrong_referential_key_error(con, app):
+ url = get_endpoint('update-quotient')
+ params = {
+ 'yearRev': '2021',
+ 'dateStart': '2023-10-01',
+ 'dateEnd': '2023-01-31',
+ 'mtt': '1500.33',
+ 'cdquo': 'plop',
+ }
+
+ Link.objects.create(resource=con, family_id='1312', name_id='local')
+ resp = app.post_json(url + '?NameID=local&rl_id=613878', params=params)
+ assert resp.json['err'] == 'wrong-key'
+ assert resp.json['err_desc'] == "cdquo key value 'plop' do not belong to 'Quotient' required referential"
+
+
@mock.patch('passerelle.utils.Request.get')
@mock.patch('passerelle.utils.Request.post')
def test_create_person(mocked_post, mocked_get, con, app):