Projet

Général

Profil

0004-toulouse-maelis-add-indicators-referentials-71858.patch

Nicolas Roche, 01 décembre 2022 18:54

Télécharger (16,4 ko)

Voir les différences:

Subject: [PATCH 4/4] toulouse-maelis: add indicators referentials (#71858)

 .../data/test_read_child-indicator_list.json  | 66 +++++++++++++++++++
 .../data/test_read_rl-indicator_list.json     | 34 ++++++++++
 functests/toulouse_maelis/test_family.py      |  2 +
 passerelle/contrib/toulouse_maelis/models.py  | 24 +++++++
 .../R_read_child_indicator_list.xml           | 46 +++++++++++++
 .../R_read_rl_indicator_list.xml              | 26 ++++++++
 tests/test_toulouse_maelis.py                 | 62 +++++++++++++++++
 7 files changed, 260 insertions(+)
 create mode 100644 functests/toulouse_maelis/data/test_read_child-indicator_list.json
 create mode 100644 functests/toulouse_maelis/data/test_read_rl-indicator_list.json
 create mode 100644 tests/data/toulouse_maelis/R_read_child_indicator_list.xml
 create mode 100644 tests/data/toulouse_maelis/R_read_rl_indicator_list.xml
functests/toulouse_maelis/data/test_read_child-indicator_list.json
1
[
2
  {
3
    "code": "APPDENTAIRE",
4
    "label": "Port appareil dentaire",
5
    "typeDesc": "NONE",
6
    "choiceList": [],
7
    "id": "APPDENTAIRE",
8
    "text": "Port appareil dentaire"
9
  },
10
  {
11
    "code": "AUTRE",
12
    "label": "Autre",
13
    "typeDesc": "NOTE",
14
    "choiceList": [],
15
    "id": "AUTRE",
16
    "text": "Autre"
17
  },
18
  {
19
    "code": "AVL",
20
    "label": "Auxiliaire de Vie loisirs",
21
    "typeDesc": "NONE",
22
    "choiceList": [],
23
    "id": "AVL",
24
    "text": "Auxiliaire de Vie loisirs"
25
  },
26
  {
27
    "code": "AVS",
28
    "label": "Auxiliaire de Vie scolaire ",
29
    "typeDesc": "NONE",
30
    "choiceList": [],
31
    "id": "AVS",
32
    "text": "Auxiliaire de Vie scolaire"
33
  },
34
  {
35
    "code": "ETABSPEC",
36
    "label": "Etablissement sp\u00e9cialis\u00e9",
37
    "typeDesc": "NOTE",
38
    "choiceList": [],
39
    "id": "ETABSPEC",
40
    "text": "Etablissement sp\u00e9cialis\u00e9"
41
  },
42
  {
43
    "code": "LENTILLE",
44
    "label": "Port lentilles de contact",
45
    "typeDesc": "NONE",
46
    "choiceList": [],
47
    "id": "LENTILLE",
48
    "text": "Port lentilles de contact"
49
  },
50
  {
51
    "code": "LUNETTE",
52
    "label": "Port de lunettes",
53
    "typeDesc": "NONE",
54
    "choiceList": [],
55
    "id": "LUNETTE",
56
    "text": "Port de lunettes"
57
  },
58
  {
59
    "code": "MDPH",
60
    "label": "Notification MDPH",
61
    "typeDesc": "NONE",
62
    "choiceList": [],
63
    "id": "MDPH",
64
    "text": "Notification MDPH"
65
  }
66
]
functests/toulouse_maelis/data/test_read_rl-indicator_list.json
1
[
2
  {
3
    "code": "AVL",
4
    "label": "Auxiliaire de Vie loisirs",
5
    "typeDesc": "NONE",
6
    "choiceList": [],
7
    "id": "AVL",
8
    "text": "Auxiliaire de Vie loisirs"
9
  },
10
  {
11
    "code": "AVS",
12
    "label": "Auxiliaire de Vie scolaire ",
13
    "typeDesc": "NONE",
14
    "choiceList": [],
15
    "id": "AVS",
16
    "text": "Auxiliaire de Vie scolaire"
17
  },
18
  {
19
    "code": "ETABSPEC",
20
    "label": "Etablissement sp\u00e9cialis\u00e9",
21
    "typeDesc": "NOTE",
22
    "choiceList": [],
23
    "id": "ETABSPEC",
24
    "text": "Etablissement sp\u00e9cialis\u00e9"
25
  },
26
  {
27
    "code": "MDPH",
28
    "label": "Notification MDPH",
29
    "typeDesc": "NONE",
30
    "choiceList": [],
31
    "id": "MDPH",
32
    "text": "Notification MDPH"
33
  }
34
]
functests/toulouse_maelis/test_family.py
128 128
}
129 129

  
130 130

  
131 131
# @pytest.mark.xfail(run=False)
132 132
@pytest.mark.parametrize(
133 133
    "ref",
134 134
    [
135 135
        'category',
136
        'child-indicator',
136 137
        'civility',
137 138
        'country',
138 139
        'csp',
139 140
        'dietcode',
140 141
        'organ',
141 142
        'pai',
142 143
        'quality',
143 144
        'quotient',
145
        'rl-indicator',
144 146
        'situation',
145 147
        'street',
146 148
        'vaccin',
147 149
    ],
148 150
)
149 151
def test_referentials(conn, ref):
150 152
    url = conn + '/read-%s-list' % ref
151 153
    resp = requests.get(url)
passerelle/contrib/toulouse_maelis/models.py
92 92
        data = cache.get(cache_key)
93 93
        if data is None:
94 94
            response = self.call('Family', 'read' + referential_name + 'List')
95 95
            data_list = []
96 96
            if referential_name == 'Organ':
97 97
                data_list = [{'id': x.id, 'text': x.code} for x in response]
98 98
            elif referential_name == 'Street':
99 99
                data_list = [{'id': x.idStreet, 'text': x.libelleStreet} for x in response]
100
            elif 'Indicator' in referential_name:
101
                data_list = []
102
                for item in serialize_object(response):
103
                    item['id'] = item['code']
104
                    item['text'] = item['label']
105
                    data_list.append(item)
100 106
            else:
101 107
                data_list = [{'id': x.code, 'text': x.libelle} for x in response]
102 108

  
103 109
            # remove redundant codes from list
104 110
            uniq_text = set()
105 111
            uniq_data = []
106 112
            for item in data_list:
107 113
                item['text'] = item['text'].strip()
......
360 366
        display_category='Famille',
361 367
        description='Liste des catégories',
362 368
        name='read-category-list',
363 369
        perm='can_access',
364 370
    )
365 371
    def read_category_list(self, request):
366 372
        return {'data': self.get_referential('Category')['list']}
367 373

  
374
    @endpoint(
375
        display_category='Famille',
376
        description='Liste des indicateurs sur le enfants',
377
        name='read-child-indicator-list',
378
        perm='can_access',
379
    )
380
    def read_child_indicator_list(self, request):
381
        return {'data': self.get_referential('ChildIndicator')['list']}
382

  
368 383
    @endpoint(
369 384
        display_category='Famille',
370 385
        description='Liste des civilités',
371 386
        name='read-civility-list',
372 387
        perm='can_access',
373 388
    )
374 389
    def read_civility_list(self, request):
375 390
        return {'data': self.get_referential('Civility')['list']}
......
441 456
        display_category='Famille',
442 457
        description='Liste des quotients',
443 458
        name='read-quotient-list',
444 459
        perm='can_access',
445 460
    )
446 461
    def read_quotient_list(self, request):
447 462
        return {'data': self.get_referential('Quotient')['list']}
448 463

  
464
    @endpoint(
465
        display_category='Famille',
466
        description='Liste des indicateurs sur les responables légaux',
467
        name='read-rl-indicator-list',
468
        perm='can_access',
469
    )
470
    def read_rl_indicator_list(self, request):
471
        return {'data': self.get_referential('RLIndicator')['list']}
472

  
449 473
    @endpoint(
450 474
        display_category='Famille',
451 475
        description='Liste des sexes',
452 476
        name='read-sex-list',
453 477
        perm='can_access',
454 478
    )
455 479
    def read_sex_list(self, request):
456 480
        return {'data': self.get_referential('Sex')['list']}
tests/data/toulouse_maelis/R_read_child_indicator_list.xml
1
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
2
  <soap:Body>
3
    <ns2:readChildIndicatorListResponse xmlns:ns2="family.ws.maelis.sigec.com">
4
      <childIndicatorList>
5
        <code>APPDENTAIRE</code>
6
        <label>Port appareil dentaire</label>
7
        <typeDesc>NONE</typeDesc>
8
      </childIndicatorList>
9
      <childIndicatorList>
10
        <code>AUTRE</code>
11
        <label>Autre</label>
12
        <typeDesc>NOTE</typeDesc>
13
      </childIndicatorList>
14
      <childIndicatorList>
15
        <code>AVL</code>
16
        <label>Auxiliaire de Vie loisirs</label>
17
        <typeDesc>NONE</typeDesc>
18
      </childIndicatorList>
19
      <childIndicatorList>
20
        <code>AVS</code>
21
        <label>Auxiliaire de Vie scolaire </label>
22
        <typeDesc>NONE</typeDesc>
23
      </childIndicatorList>
24
      <childIndicatorList>
25
        <code>ETABSPEC</code>
26
        <label>Etablissement sp&#233;cialis&#233;</label>
27
        <typeDesc>NOTE</typeDesc>
28
      </childIndicatorList>
29
      <childIndicatorList>
30
        <code>LENTILLE</code>
31
        <label>Port lentilles de contact</label>
32
        <typeDesc>NONE</typeDesc>
33
      </childIndicatorList>
34
      <childIndicatorList>
35
        <code>LUNETTE</code>
36
        <label>Port de lunettes</label>
37
        <typeDesc>NONE</typeDesc>
38
      </childIndicatorList>
39
      <childIndicatorList>
40
        <code>MDPH</code>
41
        <label>Notification MDPH</label>
42
        <typeDesc>NONE</typeDesc>
43
      </childIndicatorList>
44
    </ns2:readChildIndicatorListResponse>
45
  </soap:Body>
46
</soap:Envelope>
tests/data/toulouse_maelis/R_read_rl_indicator_list.xml
1
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
2
  <soap:Body>
3
    <ns2:readRLIndicatorListResponse xmlns:ns2="family.ws.maelis.sigec.com">
4
      <rlIndicatorList>
5
        <code>AVL</code>
6
        <label>Auxiliaire de Vie loisirs</label>
7
        <typeDesc>NONE</typeDesc>
8
      </rlIndicatorList>
9
      <rlIndicatorList>
10
        <code>AVS</code>
11
        <label>Auxiliaire de Vie scolaire </label>
12
        <typeDesc>NONE</typeDesc>
13
      </rlIndicatorList>
14
      <rlIndicatorList>
15
        <code>ETABSPEC</code>
16
        <label>Etablissement sp&#233;cialis&#233;</label>
17
        <typeDesc>NOTE</typeDesc>
18
      </rlIndicatorList>
19
      <rlIndicatorList>
20
        <code>MDPH</code>
21
        <label>Notification MDPH</label>
22
        <typeDesc>NONE</typeDesc>
23
      </rlIndicatorList>
24
    </ns2:readRLIndicatorListResponse>
25
  </soap:Body>
26
</soap:Envelope>
tests/test_toulouse_maelis.py
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_FAMILY_LAX = FakedResponse(content=get_xml_file('R_read_family_relax.xml'), status_code=200)
46 46
READ_FAMILY_ORD = FakedResponse(content=get_xml_file('R_read_family_reordered.xml'), status_code=200)
47 47
READ_RL1_FAMILY = FakedResponse(content=get_xml_file('R_read_family_with_only_rl1.xml'), status_code=200)
48 48
READ_CATEGORIES = FakedResponse(content=get_xml_file('R_read_category_list.xml'), status_code=200)
49
READ_CHILD_INDICATOR = FakedResponse(content=get_xml_file('R_read_child_indicator_list.xml'), status_code=200)
49 50
READ_CIVILITIES = FakedResponse(content=get_xml_file('R_read_civility_list.xml'), status_code=200)
50 51
READ_COUNTRY = FakedResponse(content=get_xml_file('R_read_country_list.xml'), status_code=200)
51 52
READ_CSP = FakedResponse(content=get_xml_file('R_read_csp_list.xml'), status_code=200)
52 53
READ_DIETCODE = FakedResponse(content=get_xml_file('R_read_dietcode_list.xml'), status_code=200)
53 54
READ_ORGAN = FakedResponse(content=get_xml_file('R_read_organ_list.xml'), status_code=200)
54 55
READ_PAI = FakedResponse(content=get_xml_file('R_read_pai_list.xml'), status_code=200)
55 56
READ_QUALITIES = FakedResponse(content=get_xml_file('R_read_quality_list.xml'), status_code=200)
56 57
READ_QUOTIENT = FakedResponse(content=get_xml_file('R_read_quotient_list.xml'), status_code=200)
58
READ_RL_INDICATOR = FakedResponse(content=get_xml_file('R_read_rl_indicator_list.xml'), status_code=200)
57 59
READ_SITUATIONS = FakedResponse(content=get_xml_file('R_read_situation_list.xml'), status_code=200)
58 60
READ_STREET = FakedResponse(content=get_xml_file('R_read_street_list.xml'), status_code=200)
59 61
READ_VACCIN = FakedResponse(content=get_xml_file('R_read_vaccin_list.xml'), status_code=200)
60 62
IS_RL_EXISTS_TRUE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'true', status_code=200)
61 63
IS_RL_EXISTS_FALSE = FakedResponse(content=get_xml_file('R_is_rl_exists.xml') % b'false', status_code=200)
62 64
IS_CHILD_EXISTS_TRUE = FakedResponse(content=get_xml_file('R_is_child_exists.xml') % b'true', status_code=200)
63 65
IS_CHILD_EXISTS_FALSE = FakedResponse(
64 66
    content=get_xml_file('R_is_child_exists.xml') % b'false', status_code=200
......
327 329
    assert len(resp.json['data']) == 3
328 330
    assert resp.json['data'] == [
329 331
        {'id': '212', 'text': 'AFGHANISTAN'},
330 332
        {'id': '99303', 'text': 'AFRIQUE DU SUD'},
331 333
        {'id': '99125', 'text': 'ALBANIE'},
332 334
    ]
333 335

  
334 336

  
337
@mock.patch('passerelle.utils.Request.get')
338
@mock.patch('passerelle.utils.Request.post')
339
def test_read_child_indicator_list(mocked_post, mocked_get, con, app):
340
    mocked_get.return_value = FAMILY_SERVICE_WSDL
341
    mocked_post.return_value = READ_CHILD_INDICATOR
342
    url = get_endpoint('read-child-indicator-list')
343

  
344
    resp = app.get(url)
345
    assert resp.json['err'] == 0
346
    assert len(resp.json['data']) == 8
347
    assert resp.json['data'][0:2] == [
348
        {
349
            'id': 'APPDENTAIRE',
350
            'text': 'Port appareil dentaire',
351
            'choiceList': [],
352
            'code': 'APPDENTAIRE',
353
            'label': 'Port appareil dentaire',
354
            'typeDesc': 'NONE',
355
        },
356
        {
357
            'id': 'AUTRE',
358
            'text': 'Autre',
359
            'choiceList': [],
360
            'code': 'AUTRE',
361
            'label': 'Autre',
362
            'typeDesc': 'NOTE',
363
        },
364
    ]
365

  
366

  
335 367
@mock.patch('passerelle.utils.Request.get')
336 368
@mock.patch('passerelle.utils.Request.post')
337 369
def test_read_civility_list(mocked_post, mocked_get, con, app):
338 370
    mocked_get.return_value = FAMILY_SERVICE_WSDL
339 371
    mocked_post.return_value = READ_CIVILITIES
340 372
    url = get_endpoint('read-civility-list')
341 373

  
342 374
    resp = app.get(url)
......
500 532
        {'id': 'QCLSH', 'text': 'QUOTIENT CENTRE AERE'},
501 533
        {'id': 'QJEU', 'text': 'QUOTIENT JEUNESSE'},
502 534
        {'id': 'QS', 'text': 'QUOTIENT SCOLAIRE'},
503 535
        {'id': 'QSPORT', 'text': 'QUOTIENT SPORT'},
504 536
        {'id': 'MOY ECO', 'text': 'REVENU MOYEN ( MENSUEL OU ANNUEL)'},
505 537
    ]
506 538

  
507 539

  
540
@mock.patch('passerelle.utils.Request.get')
541
@mock.patch('passerelle.utils.Request.post')
542
def test_read_rl_indicator_list(mocked_post, mocked_get, con, app):
543
    mocked_get.return_value = FAMILY_SERVICE_WSDL
544
    mocked_post.return_value = READ_RL_INDICATOR
545
    url = get_endpoint('read-rl-indicator-list')
546

  
547
    resp = app.get(url)
548
    assert resp.json['err'] == 0
549
    assert len(resp.json['data']) == 4
550
    assert resp.json['data'][1:3] == [
551
        {
552
            'id': 'AVS',
553
            'text': 'Auxiliaire de Vie scolaire',
554
            'choiceList': [],
555
            'code': 'AVS',
556
            'label': 'Auxiliaire de Vie scolaire ',
557
            'typeDesc': 'NONE',
558
        },
559
        {
560
            'id': 'ETABSPEC',
561
            'text': 'Etablissement spécialisé',
562
            'choiceList': [],
563
            'code': 'ETABSPEC',
564
            'label': 'Etablissement spécialisé',
565
            'typeDesc': 'NOTE',
566
        },
567
    ]
568

  
569

  
508 570
def test_read_sex_list(con, app):
509 571
    url = get_endpoint('read-sex-list')
510 572

  
511 573
    resp = app.get(url)
512 574
    assert resp.json['err'] == 0
513 575
    assert resp.json['data'] == [
514 576
        {'id': 'M', 'text': 'Masculin'},
515 577
        {'id': 'F', 'text': 'Féminin'},
516
-