Project

General

Profile

0003-toulouse-maelis-allow-to-send-an-empty-vaccin-list-7.patch

Nicolas Roche, 24 November 2022 11:47 AM

Download (3.58 KB)

View differences:

Subject: [PATCH 3/4] toulouse-maelis: allow to send an empty vaccin list
 (#71643)

 passerelle/contrib/toulouse_maelis/models.py |  2 +-
 tests/test_toulouse_maelis.py                | 28 ++++++++++++++++++++
 2 files changed, 29 insertions(+), 1 deletion(-)
passerelle/contrib/toulouse_maelis/models.py
258 258
        self.assert_key_in_referential(referential_name, key_value, '/'.join(str(x) for x in keys), required)
259 259

  
260 260
    def assert_child_medical_record_payload_in_referential(self, post_data, parent_keys=None):
261 261
        keys = parent_keys or []
262 262
        data = post_data
263 263
        for key in keys:
264 264
            data = data[key]
265 265

  
266
        for i in range(0, len(data['vaccinList']) or []):
266
        for i in range(0, len(data.get('vaccinList', []))):
267 267
            self.assert_post_data_in_referential(
268 268
                'Vaccin', post_data, keys + ['vaccinList', i, 'code'], required=False
269 269
            )
270 270

  
271 271
    def assert_child_pai_payoad_in_referential(self, post_data, parent_keys=None):
272 272
        keys = parent_keys or []
273 273
        self.assert_post_data_in_referential('PAI', post_data, keys + ['code'])
274 274

  
tests/test_toulouse_maelis.py
2748 2748

  
2749 2749
    Link.objects.create(resource=con, family_id='1312', name_id='local')
2750 2750
    resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
2751 2751
    assert_sent_payload(mocked_post, 'Q_update_child_medical_record.xml')
2752 2752
    assert resp.json['err'] == 0
2753 2753
    assert resp.json['data'] == 'ok'
2754 2754

  
2755 2755

  
2756
@mock.patch('passerelle.utils.Request.get')
2757
@mock.patch('passerelle.utils.Request.post')
2758
def test_update_child_medical_record_with_empty_vaccin_list(mocked_post, mocked_get, con, app):
2759
    mocked_get.return_value = FAMILY_SERVICE_WSDL
2760
    mocked_post.side_effect = [READ_VACCIN, UPDATE_MEDICAL]
2761
    url = get_endpoint('update-child-medical-record')
2762
    params = {
2763
        'familyDoctor/name': 'Dre',
2764
        'familyDoctor/phone': '0612341234',
2765
        'familyDoctor/address/street1': 'Alameda',
2766
        'familyDoctor/address/zipcode': '90220',
2767
        'familyDoctor/address/town': 'Compton',
2768
        'allergy1': 'butterscotch, imitation butterscotch, glow-in-the-dark monster make-up, and shrimp',
2769
        'allergy2': 'cauliflower',
2770
        'comment1': "the shrimp allergy isn't fully identified",
2771
        'comment2': None,
2772
        'observ1': 'Ay Caramba!',
2773
        'observ2': None,
2774
        'isAuthHospital': True,
2775
        'hospital': 'Springfield General Hospital',
2776
    }
2777

  
2778
    Link.objects.create(resource=con, family_id='1312', name_id='local')
2779
    resp = app.post_json(url + '?NameID=local&child_id=613878', params=params)
2780
    assert resp.json['err'] == 0
2781
    assert resp.json['data'] == 'ok'
2782

  
2783

  
2756 2784
def test_update_child_medical_record_not_linked_error(con, app):
2757 2785
    url = get_endpoint('update-child-medical-record')
2758 2786

  
2759 2787
    resp = app.post_json(url + '?NameID=local&child_id=613878', params={})
2760 2788
    assert resp.json['err'] == 'not-linked'
2761 2789
    assert resp.json['err_desc'] == 'User not linked to family'
2762 2790

  
2763 2791

  
2764
-