Projet

Général

Profil

0003-toulouse-maelis-vaccin-code-and-date-are-required-71.patch

Nicolas Roche, 24 novembre 2022 11:14

Télécharger (7,5 ko)

Voir les différences:

Subject: [PATCH 3/6] toulouse-maelis: vaccin code and date are required
 (#71641)

 passerelle/contrib/toulouse_maelis/schemas.py  | 3 ++-
 tests/data/toulouse_maelis/Q_create_family.xml | 1 +
 tests/data/toulouse_maelis/Q_update_family.xml | 1 +
 tests/test_toulouse_maelis.py                  | 7 ++++++-
 4 files changed, 10 insertions(+), 2 deletions(-)
passerelle/contrib/toulouse_maelis/schemas.py
285 285
    },
286 286
}
287 287

  
288 288
VACCIN_SCHEMA = {
289 289
    '$schema': 'http://json-schema.org/draft-04/schema#',
290 290
    'title': 'Vaccin',
291 291
    'description': "Informations sur le vaccin",
292 292
    'type': 'object',
293
    'required': ['code', 'vaccinationDate'],
293 294
    'properties': {
294 295
        'code': {
295 296
            'description': 'Code du vaccin (depuis référentiel)',
296
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
297
            'type': 'string',
297 298
        },
298 299
        'label': {
299 300
            'description': 'Nom du vaccin',
300 301
            'oneOf': [{'type': 'string'}, {'type': 'null'}],
301 302
        },
302 303
        'vaccinationDate': {
303 304
            'description': 'Date du vaccin',
304 305
            'type': 'string',
tests/data/toulouse_maelis/Q_create_family.xml
35 35
        <firstname>Robert</firstname>
36 36
        <lastname>Zimmerman</lastname>
37 37
        <sexe>M</sexe>
38 38
        <dateBirth>1941-05-24</dateBirth>
39 39
        <dietcode>RSV</dietcode>
40 40
        <medicalRecord>
41 41
          <vaccinList>
42 42
            <code>DTC</code>
43
            <vaccinationDate>1940-07-26</vaccinationDate>
43 44
          </vaccinList>
44 45
        </medicalRecord>
45 46
      </childList>
46 47
    </ns0:createFamily>
47 48
  </soap-env:Body>
48 49
</soap-env:Envelope>
tests/data/toulouse_maelis/Q_update_family.xml
39 39
        <birth>
40 40
          <dateBirth>1941-05-24</dateBirth>
41 41
          <place>Duluth</place>
42 42
        </birth>
43 43
        <dietcode>RSV</dietcode>
44 44
        <medicalRecord>
45 45
          <vaccinList>
46 46
            <code>DTC</code>
47
            <vaccinationDate>1940-07-26</vaccinationDate>
47 48
          </vaccinList>
48 49
        </medicalRecord>
49 50
        <paiInfoBean>
50 51
          <code>PAIALI</code>
51 52
        </paiInfoBean>
52 53
      </childList>
53 54
      <emergencyPersonList>
54 55
        <personList>
tests/test_toulouse_maelis.py
1041 1041
        'rl1/profession/codeCSP': 'ART',
1042 1042
        'rl1/CAFInfo/organ': 'A10007752822',
1043 1043
        'childList/0/lastname': 'Zimmerman',
1044 1044
        'childList/0/firstname': 'Robert',
1045 1045
        'childList/0/sexe': 'M',
1046 1046
        'childList/0/dateBirth': '1941-05-24',
1047 1047
        'childList/0/dietcode': 'RSV',
1048 1048
        'childList/0/medicalRecord/vaccinList/0/code': 'DTC',
1049
        'childList/0/medicalRecord/vaccinList/0/vaccinationDate': '1940-07-26',
1049 1050
    }
1050 1051

  
1051 1052
    resp = app.post_json(url + '?NameID=local', params=params)
1052 1053
    assert_sent_payload(mocked_post, 'Q_create_family.xml')
1053 1054
    assert resp.json['err'] == 0
1054 1055
    assert resp.json['data'] == {
1055 1056
        'number': 196545,
1056 1057
        'password': '394634V2',
......
1161 1162
        'rl1/profession/codeCSP': 'ART',
1162 1163
        'rl1/CAFInfo/organ': 'A10007752822',
1163 1164
        'childList/0/lastname': 'Zimmerman',
1164 1165
        'childList/0/firstname': 'Robert',
1165 1166
        'childList/0/sexe': 'M',
1166 1167
        'childList/0/dateBirth': '1941-05-24',
1167 1168
        'childList/0/dietcode': 'RSV',
1168 1169
        'childList/0/medicalRecord/vaccinList/0/code': 'plop',
1170
        'childList/0/medicalRecord/vaccinList/0/vaccinationDate': '1940-07-26',
1169 1171
    }
1170 1172

  
1171 1173
    resp = app.post_json(url + '?NameID=local', params=params)
1172 1174
    assert resp.json['err'] == 'wrong-key'
1173 1175
    assert (
1174 1176
        resp.json['err_desc']
1175 1177
        == "childList/0/medicalRecord/vaccinList/0/code key value 'plop' do not belong to 'Vaccin' referential"
1176 1178
    )
......
1216 1218
        'childList/0/lastname': 'Zimmerman',
1217 1219
        'childList/0/firstname': 'Robert',
1218 1220
        'childList/0/sexe': 'M',
1219 1221
        'childList/0/birth/dateBirth': '1941-05-24',
1220 1222
        'childList/0/birth/place': 'Duluth',
1221 1223
        'childList/0/dietcode': 'RSV',
1222 1224
        'childList/0/paiInfoBean/code': 'PAIALI',
1223 1225
        'childList/0/medicalRecord/vaccinList/0/code': 'DTC',
1226
        'childList/0/medicalRecord/vaccinList/0/vaccinationDate': '1940-07-26',
1224 1227
    }
1225 1228

  
1226 1229
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1227 1230
    resp = app.post_json(url + '?NameID=local', params=params)
1228 1231
    assert_sent_payload(mocked_post, 'Q_update_family.xml')
1229 1232
    assert resp.json['err'] == 0
1230 1233
    assert resp.json['data']['number'] == 196544
1231 1234
    assert not resp.json['data']['childErrorList']
......
1342 1345
        'childList/0/lastname': 'Zimmerman',
1343 1346
        'childList/0/firstname': 'Robert',
1344 1347
        'childList/0/sexe': 'M',
1345 1348
        'childList/0/birth/dateBirth': '1941-05-24',
1346 1349
        'childList/0/birth/place': 'Duluth',
1347 1350
        'childList/0/dietcode': 'RSV',
1348 1351
        'childList/0/paiInfoBean/code': 'PAIALI',
1349 1352
        'childList/0/medicalRecord/vaccinList/0/code': 'plop',
1353
        'childList/0/medicalRecord/vaccinList/0/vaccinationDate': '1940-07-26',
1350 1354
    }
1351 1355

  
1352 1356
    Link.objects.create(resource=con, family_id='1312', name_id='local')
1353 1357
    resp = app.post_json(url + '?NameID=local', params=params)
1354 1358
    assert resp.json['err'] == 'wrong-key'
1355 1359
    assert (
1356 1360
        resp.json['err_desc']
1357 1361
        == "childList/0/medicalRecord/vaccinList/0/code key value 'plop' do not belong to 'Vaccin' referential"
......
2661 2665
    assert resp.json['err'] == 'not-linked'
2662 2666
    assert resp.json['err_desc'] == 'User not linked to family'
2663 2667

  
2664 2668

  
2665 2669
@mock.patch('passerelle.utils.Request.get')
2666 2670
@mock.patch('passerelle.utils.Request.post')
2667 2671
def test_update_child_medical_record_soap_error(mocked_post, mocked_get, con, app):
2668 2672
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2669
    mocked_post.side_effect = [UPDATE_MEDICAL_500]
2673
    mocked_post.side_effect = [READ_VACCIN, UPDATE_MEDICAL_500]
2670 2674
    url = get_endpoint('update-child-medical-record')
2671 2675
    params = {
2676
        'vaccinList/0/code': 'DTC',
2672 2677
        'vaccinList/0/vaccinationDate': '2022-02-31',
2673 2678
    }
2674 2679

  
2675 2680
    Link.objects.create(resource=con, family_id='1312', name_id='local')
2676 2681
    resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
2677 2682
    assert resp.json['err'] == 'Family-updateChildMedicalRecord-soap:Client'
2678 2683
    assert 'Unmarshalling Error' in resp.json['err_desc']
2679 2684
    assert 'pas une valeur de calendrier grégorien' in resp.json['err_desc']
2680
-