0003-toulouse-maelis-return-an-indicators-dict-72523.patch
functests/toulouse_maelis/conftest.py | ||
---|---|---|
283 | 283 | |
284 | 284 |
def remove_id_on_child(child): |
285 | 285 |
child['num'] = 'N/A' |
286 | 286 |
child['lastname'] = 'N/A' |
287 | 287 |
child['mother'] = 'N/A' # dont care yet |
288 | 288 |
child['father'] = 'N/A' # dont care yet |
289 | 289 |
for person in child['authorizedPersonList']: |
290 | 290 |
person['personInfo']['num'] = 'N/A' |
291 |
child['indicatorList'].sort(key=lambda x: x['code']) |
|
292 |
del child['indicators'] # order may change |
|
291 | 293 | |
292 | 294 | |
293 | 295 |
def remove_id_on_rlg(rlg): |
294 | 296 |
if rlg: |
295 | 297 |
rlg['num'] = 'N/A' |
296 | 298 |
rlg['lastname'] = 'N/A' |
299 |
rlg['indicatorList'].sort(key=lambda x: x['code']) |
|
300 |
del rlg['indicators'] # order may change |
|
297 | 301 | |
298 | 302 | |
299 | 303 |
def remove_id_on_family(family): |
300 | 304 |
family['number'] = 'N/A' |
301 | 305 |
remove_id_on_rlg(family['RL1']) |
302 | 306 |
remove_id_on_rlg(family['RL2']) |
303 | 307 |
for child in family['childList']: |
304 | 308 |
remove_id_on_child(child) |
functests/toulouse_maelis/data/test_child_indicators.json | ||
---|---|---|
1 |
[ |
|
2 |
{ |
|
3 |
"id": "APPDENTAIRE", |
|
4 |
"code": "APPDENTAIRE", |
|
5 |
"text": "Port appareil dentaire", |
|
6 |
"label": "Port appareil dentaire", |
|
7 |
"typeDesc": "NONE", |
|
8 |
"isActive": false |
|
9 |
}, |
|
10 |
{ |
|
11 |
"id": "AUTRE", |
|
12 |
"code": "AUTRE", |
|
13 |
"text": "Autre", |
|
14 |
"label": "Autre", |
|
15 |
"typeDesc": "NOTE", |
|
16 |
"isActive": true |
|
17 |
}, |
|
18 |
{ |
|
19 |
"id": "AVL", |
|
20 |
"code": "AVL", |
|
21 |
"text": "Auxiliaire de Vie loisirs", |
|
22 |
"label": "Auxiliaire de Vie loisirs", |
|
23 |
"typeDesc": "NONE", |
|
24 |
"isActive": false |
|
25 |
}, |
|
26 |
{ |
|
27 |
"id": "AVS", |
|
28 |
"code": "AVS", |
|
29 |
"text": "Auxiliaire de Vie scolaire", |
|
30 |
"label": "Auxiliaire de Vie scolaire ", |
|
31 |
"typeDesc": "NONE", |
|
32 |
"isActive": false |
|
33 |
}, |
|
34 |
{ |
|
35 |
"id": "ETABSPEC", |
|
36 |
"code": "ETABSPEC", |
|
37 |
"text": "Etablissement sp\u00e9cialis\u00e9", |
|
38 |
"label": "Etablissement sp\u00e9cialis\u00e9", |
|
39 |
"typeDesc": "NOTE", |
|
40 |
"isActive": false |
|
41 |
}, |
|
42 |
{ |
|
43 |
"id": "LENTILLE", |
|
44 |
"code": "LENTILLE", |
|
45 |
"text": "Port lentilles de contact", |
|
46 |
"label": "Port lentilles de contact", |
|
47 |
"typeDesc": "NONE", |
|
48 |
"isActive": false |
|
49 |
}, |
|
50 |
{ |
|
51 |
"id": "LUNETTE", |
|
52 |
"code": "LUNETTE", |
|
53 |
"text": "Port de lunettes", |
|
54 |
"label": "Port de lunettes", |
|
55 |
"typeDesc": "NONE", |
|
56 |
"isActive": true |
|
57 |
}, |
|
58 |
{ |
|
59 |
"id": "MDPH", |
|
60 |
"code": "MDPH", |
|
61 |
"text": "Notification MDPH", |
|
62 |
"label": "Notification MDPH", |
|
63 |
"typeDesc": "NONE", |
|
64 |
"isActive": false |
|
65 |
} |
|
66 |
] |
functests/toulouse_maelis/data/test_rl_indicators.json | ||
---|---|---|
1 |
[ |
|
2 |
{ |
|
3 |
"id": "AVL", |
|
4 |
"code": "AVL", |
|
5 |
"text": "Auxiliaire de Vie loisirs", |
|
6 |
"label": "Auxiliaire de Vie loisirs", |
|
7 |
"typeDesc": "NONE", |
|
8 |
"isActive": true |
|
9 |
}, |
|
10 |
{ |
|
11 |
"id": "AVS", |
|
12 |
"code": "AVS", |
|
13 |
"text": "Auxiliaire de Vie scolaire", |
|
14 |
"label": "Auxiliaire de Vie scolaire ", |
|
15 |
"typeDesc": "NONE", |
|
16 |
"isActive": false |
|
17 |
}, |
|
18 |
{ |
|
19 |
"id": "ETABSPEC", |
|
20 |
"code": "ETABSPEC", |
|
21 |
"text": "Etablissement sp\u00e9cialis\u00e9", |
|
22 |
"label": "Etablissement sp\u00e9cialis\u00e9", |
|
23 |
"typeDesc": "NOTE", |
|
24 |
"isActive": true |
|
25 |
}, |
|
26 |
{ |
|
27 |
"id": "MDPH", |
|
28 |
"code": "MDPH", |
|
29 |
"text": "Notification MDPH", |
|
30 |
"label": "Notification MDPH", |
|
31 |
"typeDesc": "NONE", |
|
32 |
"isActive": false |
|
33 |
} |
|
34 |
] |
functests/toulouse_maelis/test_family.py | ||
---|---|---|
729 | 729 |
assert resp.json()['err'] == 0 |
730 | 730 |
assert diff_rlg(conn, update_data['name_id'], 1, 'test_rl_indicator.json', key='indicatorList') |
731 | 731 | |
732 | 732 |
# restore RL indicators |
733 | 733 |
payload = {'indicatorList': update_data['family_payload']['rl2']['indicatorList']} |
734 | 734 |
resp = requests.post(url, json=payload) |
735 | 735 |
resp.raise_for_status() |
736 | 736 |
assert resp.json()['err'] == 0 |
737 |
assert diff_family(conn, update_data['name_id'], 'test_update_family.json') |
|
737 |
data = diff_family(conn, update_data['name_id'], 'test_update_family.json') |
|
738 | ||
739 |
# check indicator dict |
|
740 |
indicators = sorted(data['RL2']['indicators'].values(), key=lambda x: x['id']) |
|
741 |
assert diff(indicators, 'test_rl_indicators.json') |
|
738 | 742 | |
739 | 743 | |
740 | 744 |
def test_update_child_indicator(conn, update_data): |
741 | 745 |
unlink(conn, update_data['name_id']) |
742 | 746 |
link(conn, update_data) |
743 | 747 |
url = conn + '/update-child-indicator?NameID=%s&child_id=%s' % ( |
744 | 748 |
update_data['name_id'], |
745 | 749 |
update_data['bart_num'], |
... | ... | |
752 | 756 |
assert resp.json()['err'] == 0 |
753 | 757 |
assert diff_child(conn, update_data['name_id'], 0, 'test_child_indicator.json', key='indicatorList') |
754 | 758 | |
755 | 759 |
# restore Bart indicators |
756 | 760 |
payload = {'indicatorList': update_data['family_payload']['childList'][0]['indicatorList']} |
757 | 761 |
resp = requests.post(url, json=payload) |
758 | 762 |
resp.raise_for_status() |
759 | 763 |
assert resp.json()['err'] == 0 |
760 |
assert diff_family(conn, update_data['name_id'], 'test_update_family.json') |
|
764 |
data = diff_family(conn, update_data['name_id'], 'test_update_family.json') |
|
765 | ||
766 |
# check indicator dict |
|
767 |
indicators = sorted(data['childList'][0]['indicators'].values(), key=lambda x: x['id']) |
|
768 |
assert diff(indicators, 'test_child_indicators.json') |
|
761 | 769 | |
762 | 770 | |
763 | 771 |
def test_update_quotient(conn, create_data): |
764 | 772 |
unlink(conn, create_data['name_id']) |
765 | 773 |
link(conn, create_data) |
766 | 774 | |
767 | 775 |
# add quotient |
768 | 776 |
url = conn + '/update-quotient?NameID=%s&rl_id=%s' % (create_data['name_id'], create_data['rl1_num']) |
passerelle/contrib/toulouse_maelis/models.py | ||
---|---|---|
231 | 231 |
last_key = keys.pop() |
232 | 232 |
for key in keys: |
233 | 233 |
if not isinstance(data, dict) or not key in data: |
234 | 234 |
return |
235 | 235 |
data = data[key] |
236 | 236 |
if isinstance(data, dict) and last_key in data and data[last_key] is not None: |
237 | 237 |
data[last_key + '_text'] = self.get_referential_value(referential_name, data[last_key]) |
238 | 238 | |
239 |
def add_indicators_field(self, referential_name, data): |
|
240 |
active_indicators = [x['code'] for x in data['indicatorList']] |
|
241 |
indicators = self.get_referential(referential_name) |
|
242 |
result = {} |
|
243 |
for item in indicators: |
|
244 |
item['isActive'] = item['id'] in active_indicators |
|
245 |
del item['choiceList'] # no list based indicator on parsifal project |
|
246 |
result[item['id']] = item |
|
247 |
data['indicators'] = result |
|
248 | ||
239 | 249 |
def add_text_value_to_rl_indicator(self, data): |
240 | 250 |
self.add_text_value('RLIndicator', data, ['code']) |
241 | 251 | |
242 | 252 |
def add_text_value_to_child_indicator(self, data): |
243 | 253 |
self.add_text_value('ChildIndicator', data, ['code']) |
244 | 254 | |
245 | 255 |
def add_text_value_to_child_person(self, data): |
246 | 256 |
self.add_text_value('Civility', data, ['personInfo', 'civility']) |
... | ... | |
251 | 261 |
def add_text_value_to_child(self, data): |
252 | 262 |
self.add_text_value('Sex', data, ['sexe']) |
253 | 263 |
self.add_text_value('DietCode', data, ['dietcode']) |
254 | 264 |
self.add_text_value('PAI', data, ['paiInfoBean', 'code']) |
255 | 265 |
for person in data['authorizedPersonList']: |
256 | 266 |
self.add_text_value_to_child_person(person) |
257 | 267 |
for indicator in data['indicatorList']: |
258 | 268 |
self.add_text_value_to_child_indicator(indicator) |
259 | ||
260 |
# sort indicators |
|
261 |
if data['indicatorList']: |
|
262 |
data['indicatorList'].sort(key=lambda x: x['code']) |
|
269 |
self.add_indicators_field('ChildIndicator', data) |
|
263 | 270 |
return data |
264 | 271 | |
265 | 272 |
def add_text_value_to_person(self, data): |
266 | 273 |
self.add_text_value('Civility', data, ['civility']) |
267 | 274 |
self.add_text_value('Quality', data, ['quality']) |
268 | 275 |
self.add_text_value('Sex', data, ['sexe']) |
269 | 276 | |
270 | 277 |
def add_text_value_to_rl(self, data): |
... | ... | |
273 | 280 |
self.add_text_value('Complement', data, ['adresse', 'numComp']) |
274 | 281 |
self.add_text_value('Street', data, ['adresse', 'idStreet']) |
275 | 282 |
self.add_text_value('CSP', data, ['profession', 'codeCSP']) |
276 | 283 |
self.add_text_value('Organ', data, ['CAFInfo', 'organ']) |
277 | 284 |
for indicator in data['indicatorList']: |
278 | 285 |
self.add_text_value_to_rl_indicator(indicator) |
279 | 286 |
for quotient in data['quotientList']: |
280 | 287 |
self.add_text_value('Quotient', quotient, ['cdquo']) |
281 | ||
282 |
# sort indicators |
|
283 |
if data['indicatorList']: |
|
284 |
data['indicatorList'].sort(key=lambda x: x['code']) |
|
288 |
self.add_indicators_field('RLIndicator', data) |
|
285 | 289 | |
286 | 290 |
def add_text_value_to_family(self, data): |
287 | 291 |
self.add_text_value('Category', data, ['category']) |
288 | 292 |
self.add_text_value('Situation', data, ['situation']) |
289 | 293 |
for rlg in 'RL1', 'RL2': |
290 | 294 |
if data.get(rlg): |
291 | 295 |
self.add_text_value_to_rl(data[rlg]) |
292 | 296 |
for child in data['childList']: |
tests/test_toulouse_maelis.py | ||
---|---|---|
806 | 806 |
'quotientList': [], |
807 | 807 |
'indicatorList': [], |
808 | 808 |
'childErrorList': [], |
809 | 809 |
'category_text': 'BIPARENTALE', |
810 | 810 |
'situation_text': 'Marié (e)', |
811 | 811 |
} |
812 | 812 |
data = resp.json['data']['RL1'] |
813 | 813 |
del data['profession'] |
814 |
del data['indicatorList'] |
|
815 |
del data['indicators'] |
|
814 | 816 |
assert data == { |
815 | 817 |
'num': '613878', |
816 | 818 |
'lastname': 'DOE', |
817 | 819 |
'firstname': 'JHON', |
818 | 820 |
'maidenName': None, |
819 | 821 |
'quality': 'PERE', |
820 | 822 |
'civility': 'M.', |
821 | 823 |
'birth': { |
... | ... | |
840 | 842 |
'mail': 'djhon@example.org', |
841 | 843 |
'isContactMail': True, |
842 | 844 |
'isContactSms': True, |
843 | 845 |
'isInvoicePdf': True, |
844 | 846 |
}, |
845 | 847 |
'CAFInfo': None, |
846 | 848 |
'civility_text': 'Monsieur', |
847 | 849 |
'quality_text': 'PERE', |
848 |
'indicatorList': [ |
|
849 |
{ |
|
850 |
'choice': None, |
|
851 |
'code': 'AVL', |
|
852 |
'code_text': 'Auxiliaire de Vie loisirs', |
|
853 |
'label': 'Auxiliaire de Vie loisirs', |
|
854 |
'note': None, |
|
855 |
}, |
|
856 |
{ |
|
857 |
'choice': None, |
|
858 |
'code': 'ETABSPEC', |
|
859 |
'code_text': 'Etablissement spécialisé', |
|
860 |
'label': 'Etablissement spécialisé', |
|
861 |
'note': 'SNPP', |
|
862 |
}, |
|
863 |
], |
|
864 | 850 |
'quotientList': [ |
865 | 851 |
{ |
866 | 852 |
'cdquo': 'QS', |
867 | 853 |
'cdquo_text': 'QUOTIENT SCOLAIRE', |
868 | 854 |
'codeUti': None, |
869 | 855 |
'dateEnd': '2021-12-31T00:00:00+01:00', |
870 | 856 |
'dateStart': '2021-01-01T00:00:00+01:00', |
871 | 857 |
'mtt': 1500.33, |
... | ... | |
878 | 864 |
'dateEnd': '2022-12-31T00:00:00+01:00', |
879 | 865 |
'dateStart': '2022-01-01T00:00:00+01:00', |
880 | 866 |
'mtt': 1500.44, |
881 | 867 |
'yearRev': 2021, |
882 | 868 |
}, |
883 | 869 |
], |
884 | 870 |
'subscribeActivityList': [], |
885 | 871 |
} |
872 |
assert sorted(resp.json['data']['RL1']['indicatorList'], key=lambda x: x['code']) == [ |
|
873 |
{ |
|
874 |
'choice': None, |
|
875 |
'code': 'AVL', |
|
876 |
'code_text': 'Auxiliaire de Vie loisirs', |
|
877 |
'label': 'Auxiliaire de Vie loisirs', |
|
878 |
'note': None, |
|
879 |
}, |
|
880 |
{ |
|
881 |
'choice': None, |
|
882 |
'code': 'ETABSPEC', |
|
883 |
'code_text': 'Etablissement spécialisé', |
|
884 |
'label': 'Etablissement spécialisé', |
|
885 |
'note': 'SNPP', |
|
886 |
}, |
|
887 |
] |
|
888 |
assert resp.json['data']['RL1']['indicators'] == { |
|
889 |
'AVL': { |
|
890 |
'code': 'AVL', |
|
891 |
'id': 'AVL', |
|
892 |
'isActive': True, |
|
893 |
'label': 'Auxiliaire de Vie loisirs', |
|
894 |
'text': 'Auxiliaire de Vie loisirs', |
|
895 |
'typeDesc': 'NONE', |
|
896 |
}, |
|
897 |
'AVS': { |
|
898 |
'code': 'AVS', |
|
899 |
'id': 'AVS', |
|
900 |
'isActive': False, |
|
901 |
'label': 'Auxiliaire de Vie scolaire ', |
|
902 |
'text': 'Auxiliaire de Vie scolaire', |
|
903 |
'typeDesc': 'NONE', |
|
904 |
}, |
|
905 |
'ETABSPEC': { |
|
906 |
'code': 'ETABSPEC', |
|
907 |
'id': 'ETABSPEC', |
|
908 |
'isActive': True, |
|
909 |
'label': 'Etablissement spécialisé', |
|
910 |
'text': 'Etablissement spécialisé', |
|
911 |
'typeDesc': 'NOTE', |
|
912 |
}, |
|
913 |
'MDPH': { |
|
914 |
'code': 'MDPH', |
|
915 |
'id': 'MDPH', |
|
916 |
'isActive': False, |
|
917 |
'label': 'Notification MDPH', |
|
918 |
'text': 'Notification MDPH', |
|
919 |
'typeDesc': 'NONE', |
|
920 |
}, |
|
921 |
} |
|
886 | 922 |
data = resp.json['data']['childList'][0] |
887 | 923 |
del data['medicalRecord'] |
888 | 924 |
del data['authorizedPersonList'] |
889 | 925 |
del data['paiInfoBean'] |
890 | 926 |
del data['indicatorList'] |
927 |
del data['indicators'] |
|
891 | 928 |
assert data == { |
892 | 929 |
'num': '613880', |
893 | 930 |
'lastname': 'DOE', |
894 | 931 |
'firstname': 'JANNIS', |
895 | 932 |
'sexe': 'F', |
896 | 933 |
'sexe_text': 'Féminin', |
897 | 934 |
'birth': { |
898 | 935 |
'dateBirth': '1943-01-19T00:00:00+01:00', |
... | ... | |
983 | 1020 |
'contact': {'phone': '0123456789', 'mobile': '0623456789', 'mail': 'abent@example.org'}, |
984 | 1021 |
}, |
985 | 1022 |
'personQuality': { |
986 | 1023 |
'code': 'T', |
987 | 1024 |
'code_text': 'TANTE', |
988 | 1025 |
'libelle': 'TANTE', |
989 | 1026 |
}, |
990 | 1027 |
} |
991 |
assert resp.json['data']['childList'][0]['indicatorList'] == [
|
|
1028 |
assert sorted(resp.json['data']['childList'][0]['indicatorList'], key=lambda x: x['code']) == [
|
|
992 | 1029 |
{'choice': None, 'code': 'AUTRE', 'code_text': 'Autre', 'label': 'Autre', 'note': 'rebellious'}, |
993 | 1030 |
{ |
994 | 1031 |
'choice': None, |
995 | 1032 |
'code': 'LUNETTE', |
996 | 1033 |
'code_text': 'Port de lunettes', |
997 | 1034 |
'label': 'Port de lunettes', |
998 | 1035 |
'note': None, |
999 | 1036 |
}, |
1000 | 1037 |
] |
1038 |
indicators = resp.json['data']['childList'][0]['indicators'] |
|
1039 |
assert len(indicators) == 8 |
|
1040 |
assert len([x for x in indicators.values() if x['isActive']]) == 2 |
|
1001 | 1041 | |
1002 | 1042 | |
1003 | 1043 |
def test_read_family_not_linked_error(con, app): |
1004 | 1044 |
url = get_endpoint('read-family') |
1005 | 1045 | |
1006 | 1046 |
resp = app.get(url + '?NameID=') |
1007 | 1047 |
assert resp.json['err'] == 'not-linked' |
1008 | 1048 |
assert resp.json['err_desc'] == 'User not linked to family' |
... | ... | |
1087 | 1127 |
'number': '789', |
1088 | 1128 |
'organ': 'A10007752822', |
1089 | 1129 |
'organ_text': 'LA COLLE SUR LOUP', |
1090 | 1130 |
}, |
1091 | 1131 |
'civility_text': 'Madame', |
1092 | 1132 |
'quality_text': 'MERE', |
1093 | 1133 |
'quotientList': [], |
1094 | 1134 |
'indicatorList': [], |
1135 |
'indicators': { |
|
1136 |
'AVL': { |
|
1137 |
'code': 'AVL', |
|
1138 |
'id': 'AVL', |
|
1139 |
'isActive': False, |
|
1140 |
'label': 'Auxiliaire de Vie loisirs', |
|
1141 |
'text': 'Auxiliaire de Vie loisirs', |
|
1142 |
'typeDesc': 'NONE', |
|
1143 |
}, |
|
1144 |
'AVS': { |
|
1145 |
'code': 'AVS', |
|
1146 |
'id': 'AVS', |
|
1147 |
'isActive': False, |
|
1148 |
'label': 'Auxiliaire de Vie scolaire ', |
|
1149 |
'text': 'Auxiliaire de Vie scolaire', |
|
1150 |
'typeDesc': 'NONE', |
|
1151 |
}, |
|
1152 |
'ETABSPEC': { |
|
1153 |
'code': 'ETABSPEC', |
|
1154 |
'id': 'ETABSPEC', |
|
1155 |
'isActive': False, |
|
1156 |
'label': 'Etablissement spécialisé', |
|
1157 |
'text': 'Etablissement spécialisé', |
|
1158 |
'typeDesc': 'NOTE', |
|
1159 |
}, |
|
1160 |
'MDPH': { |
|
1161 |
'code': 'MDPH', |
|
1162 |
'id': 'MDPH', |
|
1163 |
'isActive': False, |
|
1164 |
'label': 'Notification MDPH', |
|
1165 |
'text': 'Notification MDPH', |
|
1166 |
'typeDesc': 'NONE', |
|
1167 |
}, |
|
1168 |
}, |
|
1095 | 1169 |
'subscribeActivityList': [], |
1096 | 1170 |
} |
1097 | 1171 | |
1098 | 1172 | |
1099 | 1173 |
def test_read_rl_not_linked_error(con, app): |
1100 | 1174 |
url = get_endpoint('read-rl') |
1101 | 1175 | |
1102 | 1176 |
resp = app.get(url + '?NameID=local&rl_id=613879') |
1103 |
- |