Projet

Général

Profil

0001-toulouse_maelis-add-more-referentials-67788.patch

Nicolas Roche, 28 juillet 2022 15:53

Télécharger (29,4 ko)

Voir les différences:

Subject: [PATCH] toulouse_maelis: add more referentials (#67788)

 passerelle/contrib/toulouse_maelis/models.py  |  59 ++-
 .../toulouse_maelis/R_read_dietcode_list.xml  |  39 ++
 .../toulouse_maelis/R_read_organ_list.xml     | 376 ++++++++++++++++++
 .../data/toulouse_maelis/R_read_pai_list.xml  |  23 ++
 .../toulouse_maelis/R_read_quotient_list.xml  |  31 ++
 .../toulouse_maelis/R_read_vaccin_list.xml    |  87 ++++
 tests/test_toulouse_maelis.py                 | 100 +++++
 7 files changed, 711 insertions(+), 4 deletions(-)
 create mode 100644 tests/data/toulouse_maelis/R_read_dietcode_list.xml
 create mode 100644 tests/data/toulouse_maelis/R_read_organ_list.xml
 create mode 100644 tests/data/toulouse_maelis/R_read_pai_list.xml
 create mode 100644 tests/data/toulouse_maelis/R_read_quotient_list.xml
 create mode 100644 tests/data/toulouse_maelis/R_read_vaccin_list.xml
passerelle/contrib/toulouse_maelis/models.py
84 84
            ]
85 85
            return {'list': response, 'dict': {x['id']: x['text'] for x in response}}
86 86

  
87 87
        # remote referentials
88 88
        cache_key = 'maelis-%s-%s' % (self.pk, referential_name)
89 89
        data = cache.get(cache_key)
90 90
        if data is None:
91 91
            response = self.call('Family', 'read' + referential_name + 'List')
92
            data = {
93
                'list': [{'id': x.code, 'text': x.libelle} for x in response],
94
                'dict': {x.code: x.libelle for x in response},
95
            }
92
            if referential_name == 'Organ':
93
                data = {
94
                    'list': [{'id': x.id, 'text': x.code} for x in response],
95
                    'dict': {x.id: x.code for x in response},
96
                }
97
            else:
98
                data = {
99
                    'list': [{'id': x.code, 'text': x.libelle} for x in response],
100
                    'dict': {x.code: x.libelle for x in response},
101
                }
96 102
            # put in cache for two hours
97 103
            cache.set(cache_key, data, 3600 * 2)
98 104
        return data
99 105

  
100 106
    def get_referential_value(self, referential_name, key):
101 107
        try:
102 108
            return self.get_referential(referential_name)['dict'][key]
103 109
        except KeyError:
......
200 206
        uniq_data = []
201 207
        for item in data:
202 208
            item['text'] = item['text'].strip()
203 209
            if item['text'] not in uniq_text:
204 210
                uniq_data.append(item)
205 211
                uniq_text.add(item['text'])
206 212
        return {'data': uniq_data}
207 213

  
214
    @endpoint(
215
        display_category='Famille',
216
        description='Liste des régimes alimentaires',
217
        name='read-dietcode-list',
218
        perm='can_access',
219
    )
220
    def read_dietcode_list(self, request):
221
        return {'data': self.get_referential('DietCode')['list']}
222

  
223
    @endpoint(
224
        display_category='Famille',
225
        description='Liste des organismes (CAF)',
226
        name='read-organ-list',
227
        perm='can_access',
228
    )
229
    def read_organ_list(self, request):
230
        return {'data': self.get_referential('Organ')['list']}
231

  
232
    @endpoint(
233
        display_category='Famille',
234
        description="Liste des projet d'accueil individualisés",
235
        name='read-pai-list',
236
        perm='can_access',
237
    )
238
    def read_pai_list(self, request):
239
        return {'data': self.get_referential('PAI')['list']}
240

  
208 241
    @endpoint(
209 242
        display_category='Famille',
210 243
        description='liste des qualités du référenciel',
211 244
        name='read-quality-list',
212 245
        perm='can_access',
213 246
    )
214 247
    def read_quality_list(self, request):
215 248
        return {'data': self.get_referential('Quality')['list']}
216 249

  
250
    @endpoint(
251
        display_category='Famille',
252
        description='Liste des quotients',
253
        name='read-quotient-list',
254
        perm='can_access',
255
    )
256
    def read_quotient_list(self, request):
257
        return {'data': self.get_referential('Quotient')['list']}
258

  
217 259
    @endpoint(
218 260
        display_category='Famille',
219 261
        description='Liste des sexes',
220 262
        name='read-sex-list',
221 263
        perm='can_access',
222 264
    )
223 265
    def read_sex_list(self, request):
224 266
        return {'data': self.get_referential('Sex')['list']}
......
227 269
        display_category='Famille',
228 270
        description='liste des situations',
229 271
        name='read-situation-list',
230 272
        perm='can_access',
231 273
    )
232 274
    def read_situation_list(self, request):
233 275
        return {'data': self.get_referential('Situation')['list']}
234 276

  
277
    @endpoint(
278
        display_category='Famille',
279
        description='Liste des vaccins',
280
        name='read-vaccin-list',
281
        perm='can_access',
282
    )
283
    def read_vaccin_list(self, request):
284
        return {'data': self.get_referential('Vaccin')['list']}
285

  
235 286
    @endpoint(
236 287
        display_category='Famille',
237 288
        description='Lier un compte usager à une famille',
238 289
        perm='can_access',
239 290
        parameters={'NameID': {'description': 'Publik NameID'}},
240 291
        post={'request_body': {'schema': {'application/json': schemas.LINK_SCHEMA}}},
241 292
    )
242 293
    def link(self, request, NameID, post_data):
tests/data/toulouse_maelis/R_read_dietcode_list.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
  <soap:Body>
4
    <ns2:readDietCodeListResponse xmlns:ns2="family.ws.maelis.sigec.com">
5
      <itemList>
6
        <code>BB</code>
7
        <libelle>REPAS BEBE</libelle>
8
      </itemList>
9
      <itemList>
10
        <code>MSP</code>
11
        <libelle>REPAS MOYEN SANS PORC</libelle>
12
      </itemList>
13
      <itemList>
14
        <code>MSV</code>
15
        <libelle>REPAS MOYEN SANS VIANDE</libelle>
16
      </itemList>
17
      <itemList>
18
        <code>MST</code>
19
        <libelle>REPAS MOYEN STANDARD</libelle>
20
      </itemList>
21
      <itemList>
22
        <code>STD</code>
23
        <libelle>1- REPAS STANDARD</libelle>
24
      </itemList>
25
      <itemList>
26
        <code>RSP</code>
27
        <libelle>2- RÉGIME SANS PORC</libelle>
28
      </itemList>
29
      <itemList>
30
        <code>RSV</code>
31
        <libelle>3- RÉGIME SANS VIANDE</libelle>
32
      </itemList>
33
      <itemList>
34
        <code>PAI</code>
35
        <libelle>4- PROTOCOLE D'ACCUEIL INDIVIDUALISÉ</libelle>
36
      </itemList>
37
    </ns2:readDietCodeListResponse>
38
  </soap:Body>
39
</soap:Envelope>
tests/data/toulouse_maelis/R_read_organ_list.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
  <soap:Body>
4
    <ns2:readOrganListResponse xmlns:ns2="family.ws.maelis.sigec.com">
5
      <organList>
6
        <code>LEVENS</code>
7
        <id>A10004460232</id>
8
      </organList>
9
      <organList>
10
        <code>LA COLLE SUR LOUP</code>
11
        <id>A10007752822</id>
12
      </organList>
13
      <organList>
14
        <code>ASSIM</code>
15
        <id>A10001133770</id>
16
      </organList>
17
      <organList>
18
        <code>EZE</code>
19
        <id>A10007751483</id>
20
      </organList>
21
      <organList>
22
        <code>LUCERAM</code>
23
        <id>A10008152785</id>
24
      </organList>
25
      <organList>
26
        <code>SAINT ANDRE LE MANOIR</code>
27
        <id>A10008170056</id>
28
      </organList>
29
      <organList>
30
        <code>LA TRINITE ENFANTS PLACES</code>
31
        <id>A10008425613</id>
32
      </organList>
33
      <organList>
34
        <code>MONTJOYE</code>
35
        <id>A10001496896</id>
36
      </organList>
37
      <organList>
38
        <code>FOYER DE L'ENFANCE DES AM</code>
39
        <id>A10001715627</id>
40
      </organList>
41
      <organList>
42
        <code>LA TRINITE</code>
43
        <id>A10007182676</id>
44
      </organList>
45
      <organList>
46
        <code>PUGET SUR ARGENS</code>
47
        <id>A10010030250</id>
48
      </organList>
49
      <organList>
50
        <code>BEAUSOLEIL</code>
51
        <id>A10001481849</id>
52
      </organList>
53
      <organList>
54
        <code>SAINT JEAN CAP FERRAT</code>
55
        <id>A10000980674</id>
56
      </organList>
57
      <organList>
58
        <code>BERRE LES ALPES</code>
59
        <id>A10000980692</id>
60
      </organList>
61
      <organList>
62
        <code>VILLE DE NICE</code>
63
        <id>A10001314895</id>
64
      </organList>
65
      <organList>
66
        <code>PEP 06 - CORNICHE</code>
67
        <id>A10001474792</id>
68
      </organList>
69
      <organList>
70
        <code>PEP 06 MADELEINE</code>
71
        <id>A10001474782</id>
72
      </organList>
73
      <organList>
74
        <code>VALBONNE SOPHIA ANTIPOLIS</code>
75
        <id>A10007182941</id>
76
      </organList>
77
      <organList>
78
        <code>GATTIERES</code>
79
        <id>A10007182961</id>
80
      </organList>
81
      <organList>
82
        <code>FONDATION DE NICE</code>
83
        <id>A10010601009</id>
84
        <libelle>PATRONAGE ST PIERRE ACTES</libelle>
85
      </organList>
86
      <organList>
87
        <code>CANNES</code>
88
        <id>A10001427675</id>
89
      </organList>
90
      <organList>
91
        <code>VILLEFRANCHE SUR MER</code>
92
        <id>A10000802907</id>
93
      </organList>
94
      <organList>
95
        <code>SAINT ANDRE DE LA ROCHE</code>
96
        <id>A10000802910</id>
97
      </organList>
98
      <organList>
99
        <code>SAINT LAURENT DU VAR</code>
100
        <id>A10007751693</id>
101
      </organList>
102
      <organList>
103
        <code>LA TOUR</code>
104
        <id>A10007751913</id>
105
      </organList>
106
      <organList>
107
        <code>IME CORNICHE FLEURIE</code>
108
        <id>A10001039676</id>
109
      </organList>
110
      <organList>
111
        <code>VENCE</code>
112
        <id>A10001612084</id>
113
      </organList>
114
      <organList>
115
        <code>ANTIBES</code>
116
        <id>A10000980566</id>
117
      </organList>
118
      <organList>
119
        <code>ASPREMONT</code>
120
        <id>A10000980567</id>
121
      </organList>
122
      <organList>
123
        <code>CAGNES SUR MER</code>
124
        <id>A10000980568</id>
125
      </organList>
126
      <organList>
127
        <code>CASTAGNIERS</code>
128
        <id>A10000980569</id>
129
      </organList>
130
      <organList>
131
        <code>CONTES</code>
132
        <id>A10000980570</id>
133
      </organList>
134
      <organList>
135
        <code>FALICON</code>
136
        <id>A10000980571</id>
137
      </organList>
138
      <organList>
139
        <code>GILETTE</code>
140
        <id>A10000980572</id>
141
      </organList>
142
      <organList>
143
        <code>TOUET DE L ESCARENE</code>
144
        <id>A10000980573</id>
145
      </organList>
146
      <organList>
147
        <code>CAP D AIL</code>
148
        <id>A10001715572</id>
149
      </organList>
150
      <organList>
151
        <code>MENTON</code>
152
        <id>A10000980575</id>
153
      </organList>
154
      <organList>
155
        <code>ROQUEBRUNE CAP MARTIN</code>
156
        <id>A10000980577</id>
157
      </organList>
158
      <organList>
159
        <code>VALLAURIS</code>
160
        <id>A10000980584</id>
161
      </organList>
162
      <organList>
163
        <code>TOURRETTE LEVENS</code>
164
        <id>A10001715581</id>
165
      </organList>
166
      <organList>
167
        <code>ASSOCIATION LOU MERILHOUN LEVENS</code>
168
        <id>A10004071438</id>
169
      </organList>
170
      <organList>
171
        <code>BEAULIEU SUR MER</code>
172
        <id>A10007179260</id>
173
      </organList>
174
      <organList>
175
        <code>APAJH</code>
176
        <id>A10000980388</id>
177
      </organList>
178
      <organList>
179
        <code>CARROS</code>
180
        <id>A10007751440</id>
181
      </organList>
182
      <organList>
183
        <code>BLAUSASC</code>
184
        <id>A10007751441</id>
185
      </organList>
186
      <organList>
187
        <code>ATIAM</code>
188
        <id>A10000979354</id>
189
      </organList>
190
      <organList>
191
        <code>UDAF</code>
192
        <id>A10000979370</id>
193
      </organList>
194
      <organList>
195
        <code>ALVA 06</code>
196
        <id>A10000979372</id>
197
      </organList>
198
      <organList>
199
        <code>IES CLEMENT ADER</code>
200
        <id>A10000979373</id>
201
      </organList>
202
      <organList>
203
        <code>ALC L OLIVIER</code>
204
        <id>A10000979374</id>
205
      </organList>
206
      <organList>
207
        <code>IESEDA LES CHANTERELLES</code>
208
        <id>A10000979375</id>
209
      </organList>
210
      <organList>
211
        <code>IME TERRASSES</code>
212
        <id>A10000979376</id>
213
      </organList>
214
      <organList>
215
        <code>SAINT PAUL DE VENCE</code>
216
        <id>A10007751879</id>
217
      </organList>
218
      <organList>
219
        <code>VILLENEUVE LOUBET</code>
220
        <id>A10007753594</id>
221
      </organList>
222
      <organList>
223
        <code>TOURETTES-SUR-LOUP</code>
224
        <id>A10013129309</id>
225
      </organList>
226
      <organList>
227
        <code>COLOMARS</code>
228
        <id>A10013447888</id>
229
      </organList>
230
      <organList>
231
        <code>BREIL SUR ROYA</code>
232
        <id>A10015115495</id>
233
      </organList>
234
      <organList>
235
        <code>GRASSE</code>
236
        <id>A10015255908</id>
237
      </organList>
238
      <organList>
239
        <code>SAINT BLAISE</code>
240
        <id>A10016957436</id>
241
      </organList>
242
      <organList>
243
        <code>BONSON</code>
244
        <id>A10013128210</id>
245
      </organList>
246
      <organList>
247
        <code>CANTARON</code>
248
        <id>A10013128217</id>
249
      </organList>
250
      <organList>
251
        <code>MANDELIEU</code>
252
        <id>A10015126217</id>
253
      </organList>
254
      <organList>
255
        <code>THEOULE SUR MER</code>
256
        <id>A10015528233</id>
257
      </organList>
258
      <organList>
259
        <code>ASCROS</code>
260
        <id>A10016401771</id>
261
      </organList>
262
      <organList>
263
        <code>CANNES LA BOCCA</code>
264
        <id>A10016990309</id>
265
      </organList>
266
      <organList>
267
        <code>LA GAUDE</code>
268
        <id>A10012498607</id>
269
      </organList>
270
      <organList>
271
        <code>DRAP</code>
272
        <id>A10013123067</id>
273
      </organList>
274
      <organList>
275
        <code>MALAUSSENE</code>
276
        <id>A10014621894</id>
277
      </organList>
278
      <organList>
279
        <code>ROQUEFORT LES PINS</code>
280
        <id>A10014922597</id>
281
      </organList>
282
      <organList>
283
        <code>L ESCARENE</code>
284
        <id>A10014927854</id>
285
      </organList>
286
      <organList>
287
        <code>MOUGINS</code>
288
        <id>A10014938988</id>
289
      </organList>
290
      <organList>
291
        <code>SOSPEL</code>
292
        <id>A10013129048</id>
293
      </organList>
294
      <organList>
295
        <code>LE CANNET</code>
296
        <id>A10013459160</id>
297
      </organList>
298
      <organList>
299
        <code>SAINT MARTIN DU VAR</code>
300
        <id>A10015677583</id>
301
      </organList>
302
      <organList>
303
        <code>BIOT</code>
304
        <id>A10017265908</id>
305
      </organList>
306
      <organList>
307
        <code>PEILLON</code>
308
        <id>A10000980576</id>
309
      </organList>
310
      <organList>
311
        <code>LES ARCS</code>
312
        <id>A10024933344</id>
313
      </organList>
314
      <organList>
315
        <code>LA TURBIE</code>
316
        <id>A10024933368</id>
317
      </organList>
318
      <organList>
319
        <code>SAINT JULIEN</code>
320
        <id>A10024933442</id>
321
      </organList>
322
      <organList>
323
        <code>SAINT JEANNET</code>
324
        <id>A10021971554</id>
325
      </organList>
326
      <organList>
327
        <code>PEILLE</code>
328
        <id>A10019717953</id>
329
      </organList>
330
      <organList>
331
        <code>REGIME GENERAL</code>
332
        <id>g</id>
333
      </organList>
334
      <organList>
335
        <code>REGIMES AUTRES</code>
336
        <id>a</id>
337
      </organList>
338
      <organList>
339
        <code>REGIME MSA</code>
340
        <id>a11003995450</id>
341
      </organList>
342
      <organList>
343
        <code>REGIME SNCF</code>
344
        <id>a11013011612</id>
345
      </organList>
346
      <organList>
347
        <code>REGIME GENERAL MONACO</code>
348
        <id>a11017891473</id>
349
      </organList>
350
      <organList>
351
        <code>REGIME EDF/GDF - TITULAIRE</code>
352
        <id>a11015961838</id>
353
      </organList>
354
      <organList>
355
        <code>REGIME MONACO</code>
356
        <id>a11015961839</id>
357
      </organList>
358
      <organList>
359
        <code>TRIBUNAL DE GRANDE INSTANCE DE NICE</code>
360
        <id>a11025419517</id>
361
      </organList>
362
      <organList>
363
        <code>LA ROQUETTE SUR VAR</code>
364
        <id>A10026769374</id>
365
      </organList>
366
      <organList>
367
        <code>BAR-SUR-LOUP</code>
368
        <id>A10027856948</id>
369
      </organList>
370
      <organList>
371
        <code>TOUET SUR VAR</code>
372
        <id>A10029519260</id>
373
      </organList>
374
    </ns2:readOrganListResponse>
375
  </soap:Body>
376
</soap:Envelope>
tests/data/toulouse_maelis/R_read_pai_list.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
  <soap:Body>
4
    <ns2:readPAIListResponse xmlns:ns2="family.ws.maelis.sigec.com">
5
      <itemList>
6
        <code>PAIALI</code>
7
        <libelle>ALIMENTAIRE</libelle>
8
      </itemList>
9
      <itemList>
10
        <code>PAIO</code>
11
        <libelle>AUTRE</libelle>
12
      </itemList>
13
      <itemList>
14
        <code>PAIMED</code>
15
        <libelle>MEDICAL</libelle>
16
      </itemList>
17
      <itemList>
18
        <code>PAI2</code>
19
        <libelle>MEDICAL ET ALIMENTAIRE</libelle>
20
      </itemList>
21
    </ns2:readPAIListResponse>
22
  </soap:Body>
23
</soap:Envelope>
tests/data/toulouse_maelis/R_read_quotient_list.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
  <soap:Body>
4
    <ns2:readQuotientListResponse xmlns:ns2="family.ws.maelis.sigec.com">
5
      <itemList>
6
        <code>QF</code>
7
        <libelle>GRILLE DE QUOTIENT</libelle>
8
      </itemList>
9
      <itemList>
10
        <code>QCLSH</code>
11
        <libelle>QUOTIENT CENTRE AERE</libelle>
12
      </itemList>
13
      <itemList>
14
        <code>QJEU</code>
15
        <libelle>QUOTIENT JEUNESSE</libelle>
16
      </itemList>
17
      <itemList>
18
        <code>QS</code>
19
        <libelle>QUOTIENT SCOLAIRE</libelle>
20
      </itemList>
21
      <itemList>
22
        <code>QSPORT</code>
23
        <libelle>QUOTIENT SPORT</libelle>
24
      </itemList>
25
      <itemList>
26
        <code>MOY ECO</code>
27
        <libelle>REVENU MOYEN ( MENSUEL OU ANNUEL)</libelle>
28
      </itemList>
29
    </ns2:readQuotientListResponse>
30
  </soap:Body>
31
</soap:Envelope>
tests/data/toulouse_maelis/R_read_vaccin_list.xml
1
<?xml version="1.0" encoding="utf-8"?>
2
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
3
  <soap:Body>
4
    <ns2:readVaccinListResponse xmlns:ns2="family.ws.maelis.sigec.com">
5
      <itemList>
6
        <code>BCG</code>
7
        <libelle>BCG</libelle>
8
      </itemList>
9
      <itemList>
10
        <code>CIB</code>
11
        <libelle>CONTRE-INDICATION  TEMPORAIRE AU BCG</libelle>
12
      </itemList>
13
      <itemList>
14
        <code>MONO</code>
15
        <libelle>CONTROLE DU BCG (+)</libelle>
16
      </itemList>
17
      <itemList>
18
        <code>MONON</code>
19
        <libelle>CONTROLE DU BCG (-)</libelle>
20
      </itemList>
21
      <itemList>
22
        <code>DTC</code>
23
        <libelle>DIPHTERIE TETANOS COQUELUCHE</libelle>
24
      </itemList>
25
      <itemList>
26
        <code>DTCP</code>
27
        <libelle>DIPHTERIE-TETANOS-COQUELUCHE-POLIO</libelle>
28
      </itemList>
29
      <itemList>
30
        <code>DTP</code>
31
        <libelle>DIPHTERIE-TETANOS-POLIO</libelle>
32
      </itemList>
33
      <itemList>
34
        <code>HEP</code>
35
        <libelle>HEPATITE</libelle>
36
      </itemList>
37
      <itemList>
38
        <code>HEPA B</code>
39
        <libelle>HEPATITE B</libelle>
40
      </itemList>
41
      <itemList>
42
        <code>IN</code>
43
        <libelle>INFANRIX</libelle>
44
      </itemList>
45
      <itemList>
46
        <code>HIB</code>
47
        <libelle>MENINGITE</libelle>
48
      </itemList>
49
      <itemList>
50
        <code>PENT</code>
51
        <libelle>PENTACOQ</libelle>
52
      </itemList>
53
      <itemList>
54
        <code>PENTH</code>
55
        <libelle>PENT'HIBEST</libelle>
56
      </itemList>
57
      <itemList>
58
        <code>P</code>
59
        <libelle>POLIO</libelle>
60
      </itemList>
61
      <itemList>
62
        <code>ROR</code>
63
        <libelle>ROUGEOLE-OREILLONS-RUBEOLE</libelle>
64
      </itemList>
65
      <itemList>
66
        <code>ROUX</code>
67
        <libelle>ROUVAX</libelle>
68
      </itemList>
69
      <itemList>
70
        <code>TETANOS</code>
71
        <libelle>TETANOS</libelle>
72
      </itemList>
73
      <itemList>
74
        <code>TPOLIO</code>
75
        <libelle>TETANOS POLIO</libelle>
76
      </itemList>
77
      <itemList>
78
        <code>TETR</code>
79
        <libelle>TETRACOQ</libelle>
80
      </itemList>
81
      <itemList>
82
        <code>T.POLIO</code>
83
        <libelle>T.POLIO</libelle>
84
      </itemList>
85
    </ns2:readVaccinListResponse>
86
  </soap:Body>
87
</soap:Envelope>
tests/test_toulouse_maelis.py
40 40
ACTIVITY_SERVICE_WSDL = FakedResponse(content=get_xml_file('ActivityService.wsdl'), status_code=200)
41 41
FAILED_AUTH = FakedResponse(content=get_xml_file('R_failed_authentication.xml'), status_code=500)
42 42
ISWSRUNNING_TRUE = FakedResponse(content=get_xml_file('R_is_ws_running.xml') % b'true', status_code=200)
43 43
ISWSRUNNING_FALSE = FakedResponse(content=get_xml_file('R_is_ws_running.xml') % b'false', status_code=200)
44 44
READ_FAMILY = FakedResponse(content=get_xml_file('R_read_family.xml'), status_code=200)
45 45
READ_CATEGORIES = FakedResponse(content=get_xml_file('R_read_category_list.xml'), status_code=200)
46 46
READ_CIVILITIES = FakedResponse(content=get_xml_file('R_read_civility_list.xml'), status_code=200)
47 47
READ_CSP = FakedResponse(content=get_xml_file('R_read_csp_list.xml'), status_code=200)
48
READ_DIETCODE = FakedResponse(content=get_xml_file('R_read_dietcode_list.xml'), status_code=200)
49
READ_ORGAN = FakedResponse(content=get_xml_file('R_read_organ_list.xml'), status_code=200)
50
READ_PAI = FakedResponse(content=get_xml_file('R_read_pai_list.xml'), status_code=200)
48 51
READ_QUALITIES = FakedResponse(content=get_xml_file('R_read_quality_list.xml'), status_code=200)
52
READ_QUOTIENT = FakedResponse(content=get_xml_file('R_read_quotient_list.xml'), status_code=200)
49 53
READ_SITUATIONS = FakedResponse(content=get_xml_file('R_read_situation_list.xml'), status_code=200)
54
READ_VACCIN = FakedResponse(content=get_xml_file('R_read_vaccin_list.xml'), status_code=200)
50 55
IS_RL_EXISTS_TRUE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'true', status_code=200)
51 56
IS_RL_EXISTS_FALSE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'false', status_code=200)
52 57
IS_CHILD_EXISTS_TRUE = FakedResponse(content=get_xml_file('R_is_child_exists.xml') % b'true', status_code=200)
53 58
IS_CHILD_EXISTS_FALSE = FakedResponse(
54 59
    content=get_xml_file('R_is_child_exists.xml') % b'false', status_code=200
55 60
)
56 61
CREATE_FAMILY = FakedResponse(content=get_xml_file('R_create_family.xml'), status_code=200)
57 62
CREATE_FAMILY_ERR = FakedResponse(content=get_xml_file('R_create_family_error.xml'), status_code=200)
......
326 331
        {'id': '9', 'text': 'PROFESSION LIBERALE'},
327 332
        {'id': '12', 'text': 'RETRAITE'},
328 333
        {'id': 'RMI', 'text': "REVENU MINIMUM D'INSERTION"},
329 334
        {'id': '16', 'text': 'SANS PROFESSION'},
330 335
        {'id': 'SEC', 'text': 'SECRETAIRE'},
331 336
    ]
332 337

  
333 338

  
339
@mock.patch('passerelle.utils.Request.get')
340
@mock.patch('passerelle.utils.Request.post')
341
def test_read_dietcode_list(mocked_post, mocked_get, con, app):
342
    mocked_get.return_value = FAMILY_SERVICE_WSDL
343
    mocked_post.return_value = READ_DIETCODE
344
    url = get_endpoint('read-dietcode-list')
345

  
346
    resp = app.get(url)
347
    assert resp.json['err'] == 0
348
    assert resp.json['data'] == [
349
        {'id': 'BB', 'text': 'REPAS BEBE'},
350
        {'id': 'MSP', 'text': 'REPAS MOYEN SANS PORC'},
351
        {'id': 'MSV', 'text': 'REPAS MOYEN SANS VIANDE'},
352
        {'id': 'MST', 'text': 'REPAS MOYEN STANDARD'},
353
        {'id': 'STD', 'text': '1- REPAS STANDARD'},
354
        {'id': 'RSP', 'text': '2- RÉGIME SANS PORC'},
355
        {'id': 'RSV', 'text': '3- RÉGIME SANS VIANDE'},
356
        {'id': 'PAI', 'text': "4- PROTOCOLE D'ACCUEIL INDIVIDUALISÉ"},
357
    ]
358

  
359

  
360
@mock.patch('passerelle.utils.Request.get')
361
@mock.patch('passerelle.utils.Request.post')
362
def test_read_organ_list(mocked_post, mocked_get, con, app):
363
    mocked_get.return_value = FAMILY_SERVICE_WSDL
364
    mocked_post.return_value = READ_ORGAN
365
    url = get_endpoint('read-organ-list')
366

  
367
    resp = app.get(url)
368
    assert resp.json['err'] == 0
369
    assert len(resp.json['data']) == 92
370
    assert resp.json['data'][:5] == [
371
        {'id': 'A10004460232', 'text': 'LEVENS'},
372
        {'id': 'A10007752822', 'text': 'LA COLLE SUR LOUP'},
373
        {'id': 'A10001133770', 'text': 'ASSIM'},
374
        {'id': 'A10007751483', 'text': 'EZE'},
375
        {'id': 'A10008152785', 'text': 'LUCERAM'},
376
    ]
377

  
378

  
379
@mock.patch('passerelle.utils.Request.get')
380
@mock.patch('passerelle.utils.Request.post')
381
def test_read_pai_list(mocked_post, mocked_get, con, app):
382
    mocked_get.return_value = FAMILY_SERVICE_WSDL
383
    mocked_post.return_value = READ_PAI
384
    url = get_endpoint('read-pai-list')
385

  
386
    resp = app.get(url)
387
    assert resp.json['err'] == 0
388
    assert resp.json['data'] == [
389
        {'id': 'PAIALI', 'text': 'ALIMENTAIRE'},
390
        {'id': 'PAIO', 'text': 'AUTRE'},
391
        {'id': 'PAIMED', 'text': 'MEDICAL'},
392
        {'id': 'PAI2', 'text': 'MEDICAL ET ALIMENTAIRE'},
393
    ]
394

  
395

  
334 396
@mock.patch('passerelle.utils.Request.get')
335 397
@mock.patch('passerelle.utils.Request.post')
336 398
def test_read_quality_list(mocked_post, mocked_get, con, app):
337 399
    mocked_get.return_value = FAMILY_SERVICE_WSDL
338 400
    mocked_post.return_value = READ_QUALITIES
339 401
    url = get_endpoint('read-quality-list')
340 402

  
341 403
    resp = app.get(url)
......
356 418
        {'id': 'O', 'text': 'ONCLE'},
357 419
        {'id': 'OS', 'text': 'ORGANISME SOCIAL'},
358 420
        {'id': 'PERE', 'text': 'PERE'},
359 421
        {'id': 'T', 'text': 'TANTE'},
360 422
        {'id': 'TUTEUR', 'text': 'TUTEUR'},
361 423
    ]
362 424

  
363 425

  
426
@mock.patch('passerelle.utils.Request.get')
427
@mock.patch('passerelle.utils.Request.post')
428
def test_read_quotient_list(mocked_post, mocked_get, con, app):
429
    mocked_get.return_value = FAMILY_SERVICE_WSDL
430
    mocked_post.return_value = READ_QUOTIENT
431
    url = get_endpoint('read-quotient-list')
432

  
433
    resp = app.get(url)
434
    assert resp.json['err'] == 0
435
    assert resp.json['data'] == [
436
        {'id': 'QF', 'text': 'GRILLE DE QUOTIENT'},
437
        {'id': 'QCLSH', 'text': 'QUOTIENT CENTRE AERE'},
438
        {'id': 'QJEU', 'text': 'QUOTIENT JEUNESSE'},
439
        {'id': 'QS', 'text': 'QUOTIENT SCOLAIRE'},
440
        {'id': 'QSPORT', 'text': 'QUOTIENT SPORT'},
441
        {'id': 'MOY ECO', 'text': 'REVENU MOYEN ( MENSUEL OU ANNUEL)'},
442
    ]
443

  
444

  
364 445
def test_read_sex_list(con, app):
365 446
    url = get_endpoint('read-sex-list')
366 447

  
367 448
    resp = app.get(url)
368 449
    assert resp.json['err'] == 0
369 450
    assert resp.json['data'] == [
370 451
        {'id': 'M', 'text': 'Masculin'},
371 452
        {'id': 'F', 'text': 'Féminin'},
......
389 470
        {'id': 'P', 'text': 'Pacsé (e)'},
390 471
        {'id': 'S', 'text': 'Séparé (e)'},
391 472
        {'id': 'UL', 'text': 'UNION LIBRE'},
392 473
        {'id': 'V', 'text': 'Veuf (ve)'},
393 474
        {'id': 'VM', 'text': 'Vivant maritalement'},
394 475
    ]
395 476

  
396 477

  
478
@mock.patch('passerelle.utils.Request.get')
479
@mock.patch('passerelle.utils.Request.post')
480
def test_read_vaccin_list(mocked_post, mocked_get, con, app):
481
    mocked_get.return_value = FAMILY_SERVICE_WSDL
482
    mocked_post.return_value = READ_VACCIN
483
    url = get_endpoint('read-vaccin-list')
484

  
485
    resp = app.get(url)
486
    assert resp.json['err'] == 0
487
    assert len(resp.json['data']) == 20
488
    assert resp.json['data'][:5] == [
489
        {'id': 'BCG', 'text': 'BCG'},
490
        {'id': 'CIB', 'text': 'CONTRE-INDICATION  TEMPORAIRE AU BCG'},
491
        {'id': 'MONO', 'text': 'CONTROLE DU BCG (+)'},
492
        {'id': 'MONON', 'text': 'CONTROLE DU BCG (-)'},
493
        {'id': 'DTC', 'text': 'DIPHTERIE TETANOS COQUELUCHE'},
494
    ]
495

  
496

  
397 497
@mock.patch('passerelle.utils.Request.get')
398 498
@mock.patch('passerelle.utils.Request.post')
399 499
def test_read_family(mocked_post, mocked_get, con, app):
400 500
    mocked_get.return_value = FAMILY_SERVICE_WSDL
401 501
    mocked_post.side_effect = [READ_FAMILY, READ_CATEGORIES, READ_SITUATIONS, READ_CIVILITIES, READ_QUALITIES]
402 502
    url = get_endpoint('read-family')
403 503
    Link.objects.create(resource=con, family_id='1312', name_id='local')
404 504

  
405
-