toulouse-maelis: refuse empty string on required referencial field (#70075)
This commit is contained in:
parent
ba3ed38816
commit
016fe427b4
|
@ -78,7 +78,7 @@ ADDRESS_SCHEMA = {
|
|||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
},
|
||||
'numComp': {
|
||||
'description': 'Complément du numéro (B, T ou Q)',
|
||||
'description': 'Complément du numéro (depuis référentiel)',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
},
|
||||
'street1': {
|
||||
|
@ -178,7 +178,7 @@ PROFESSION_SCHEMA = {
|
|||
'type': 'object',
|
||||
'properties': {
|
||||
'codeCSP': {
|
||||
'description': 'Catégorie socio-professionnelle',
|
||||
'description': 'Catégorie socio-professionnelle (depuis référentiel)',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
},
|
||||
'profession': {
|
||||
|
@ -213,7 +213,7 @@ CAFINFO_SCHEMA = {
|
|||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
},
|
||||
'organ': {
|
||||
'description': "Nom de l'organisme",
|
||||
'description': "Nom de l'organisme (depuis référentiel)",
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
},
|
||||
},
|
||||
|
@ -229,12 +229,14 @@ RLINFO_SCHEMA = {
|
|||
'required': ['firstname', 'lastname', 'civility', 'quality', 'dateBirth', 'adresse'],
|
||||
'properties': {
|
||||
'civility': {
|
||||
'description': 'civilité (depuis référenciel)',
|
||||
'description': 'civilité (depuis référentiel)',
|
||||
'type': 'string',
|
||||
'pattern': '.+',
|
||||
},
|
||||
'quality': {
|
||||
'description': 'Qualité',
|
||||
'description': 'Qualité (depuis référentiel)',
|
||||
'type': 'string',
|
||||
'pattern': '.+',
|
||||
},
|
||||
'adresse': ADDRESS_SCHEMA,
|
||||
'contact': CONTACT_SCHEMA,
|
||||
|
@ -412,7 +414,7 @@ VACCIN_SCHEMA = {
|
|||
'type': 'object',
|
||||
'properties': {
|
||||
'code': {
|
||||
'description': 'Code du vaccin',
|
||||
'description': 'Code du vaccin (depuis référentiel)',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
},
|
||||
'label': {
|
||||
|
@ -464,8 +466,9 @@ PAIINFO_SCHEMA = {
|
|||
'required': ['code'],
|
||||
'properties': {
|
||||
'code': {
|
||||
'description': 'Code',
|
||||
'description': 'Code (depuis référentiel)',
|
||||
'type': 'string',
|
||||
'pattern': '.+',
|
||||
},
|
||||
'dateDeb': {
|
||||
'description': 'Date de début',
|
||||
|
@ -499,12 +502,13 @@ CHILD_SCHEMA = {
|
|||
],
|
||||
'properties': {
|
||||
'sexe': {
|
||||
'description': 'Sexe',
|
||||
'description': 'Sexe (depuis référentiel)',
|
||||
'type': 'string',
|
||||
'pattern': '.+',
|
||||
},
|
||||
'birth': CHILDBIRTH_SCHEMA,
|
||||
'dietcode': {
|
||||
'description': 'Code de régime alimentaire',
|
||||
'description': 'Code de régime alimentaire (depuis référentiel)',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
},
|
||||
'bPhoto': {
|
||||
|
@ -557,7 +561,7 @@ FAMILYPERSON_SCHEMA = {
|
|||
'required': ['firstname', 'lastname', 'dateBirth', 'quality'],
|
||||
'properties': {
|
||||
'civility': {
|
||||
'description': 'civilité (depuis référenciel)',
|
||||
'description': 'civilité (depuis référentiel)',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
},
|
||||
'quality': {
|
||||
|
@ -566,7 +570,7 @@ FAMILYPERSON_SCHEMA = {
|
|||
'pattern': '.+',
|
||||
},
|
||||
'sexe': {
|
||||
'description': 'Sexe',
|
||||
'description': 'Sexe (depuis référentiel)',
|
||||
'oneOf': [{'type': 'null'}, {'type': 'string'}],
|
||||
},
|
||||
'contact': CONTACTLIGHT_SCHEMA,
|
||||
|
@ -602,12 +606,14 @@ UPDATE_FAMILY_SCHEMA = {
|
|||
'required': ['categorie', 'situation'],
|
||||
'properties': {
|
||||
'categorie': {
|
||||
'description': 'Categorie (depuis référenciel)',
|
||||
'description': 'Categorie (depuis référentiel)',
|
||||
'type': 'string',
|
||||
'pattern': '.+',
|
||||
},
|
||||
'situation': {
|
||||
'description': 'Situation familiale (depuis référenciel)',
|
||||
'description': 'Situation familiale (depuis référentiel)',
|
||||
'type': 'string',
|
||||
'pattern': '.+',
|
||||
},
|
||||
'flagCom': {
|
||||
'description': 'Hors commune',
|
||||
|
@ -728,8 +734,9 @@ PERSONQUALITY_SCHEMA = {
|
|||
'required': ['code'],
|
||||
'properties': {
|
||||
'code': {
|
||||
'description': 'Le code',
|
||||
'description': 'Le code (depuis référentiel)',
|
||||
'type': 'string',
|
||||
'pattern': '.+',
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1064,6 +1064,26 @@ def test_create_family(mocked_post, mocked_get, con, app):
|
|||
assert Link.objects.get(resource=con, family_id='196545', name_id='local')
|
||||
|
||||
|
||||
def test_create_family_empty_referential_key_error(con, app):
|
||||
url = get_endpoint('create-family')
|
||||
params = {
|
||||
'categorie': '',
|
||||
'situation': '',
|
||||
'rl1/civility': 'M.',
|
||||
'rl1/firstname': 'Jhon',
|
||||
'rl1/lastname': 'Doe',
|
||||
'rl1/quality': 'AU',
|
||||
'rl1/dateBirth': '1938-07-26',
|
||||
'rl1/adresse/street1': 'Chateau',
|
||||
'rl1/adresse/town': 'Paris',
|
||||
'rl1/adresse/zipcode': '75014',
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?NameID=local', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == "categorie: '' does not match '.+'"
|
||||
|
||||
|
||||
def test_create_family_already_linked_error(con, app):
|
||||
url = get_endpoint('create-family')
|
||||
params = {
|
||||
|
@ -1228,6 +1248,26 @@ def test_create_rl1(mocked_post, mocked_get, con, app):
|
|||
assert Link.objects.get(resource=con, family_id='196545', name_id='local')
|
||||
|
||||
|
||||
def test_create_rl1_empty_referential_key_error(con, app):
|
||||
url = get_endpoint('create-rl1')
|
||||
params = {
|
||||
'categorie': 'ACCEUI',
|
||||
'situation': 'C',
|
||||
'rl1/civility': '',
|
||||
'rl1/firstname': 'Jhon',
|
||||
'rl1/lastname': 'Doe',
|
||||
'rl1/quality': '',
|
||||
'rl1/dateBirth': '1938-07-26',
|
||||
'rl1/adresse/street1': 'Chateau',
|
||||
'rl1/adresse/town': 'Paris',
|
||||
'rl1/adresse/zipcode': '75014',
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?NameID=local', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == "rl1/civility: '' does not match '.+'"
|
||||
|
||||
|
||||
def test_create_rl1_already_linked_error(con, app):
|
||||
url = get_endpoint('create-rl1')
|
||||
params = {
|
||||
|
@ -1516,6 +1556,21 @@ def test_create_child(mocked_post, mocked_get, con, app):
|
|||
assert resp.json['data'] == {'child_id': 613880}
|
||||
|
||||
|
||||
def test_create_child_empty_referential_key_error(con, app):
|
||||
url = get_endpoint('create-child')
|
||||
params = {
|
||||
'lastname': 'DOE',
|
||||
'firstname': 'JANNIS',
|
||||
'sexe': '',
|
||||
'birth/dateBirth': '1943-01-19',
|
||||
'birth/place': 'Port Arthur',
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?NameID=local', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == "sexe: '' does not match '.+'"
|
||||
|
||||
|
||||
def test_create_child_not_linked_error(con, app):
|
||||
url = get_endpoint('create-child')
|
||||
params = {
|
||||
|
@ -1737,7 +1792,7 @@ def test_create_person_required_field_error(mocked_post, mocked_get, con, app):
|
|||
assert resp.json['err_desc'] == "'quality' is a required property"
|
||||
|
||||
|
||||
def test_create_person_with_empty_string_on_required_referencial_error(con, app):
|
||||
def test_create_person_empty_referential_key_error(con, app):
|
||||
url = get_endpoint('create-person')
|
||||
params = {
|
||||
'civility': None,
|
||||
|
@ -1899,6 +1954,25 @@ def test_create_child_person(mocked_post, mocked_get, con, app):
|
|||
assert resp.json['err'] == 0
|
||||
|
||||
|
||||
def test_create_child_person_empty_referential_key_error(con, app):
|
||||
url = get_endpoint('create-child-person')
|
||||
params = {
|
||||
'personInfo/civility': 'MME',
|
||||
'personInfo/firstname': 'Diana',
|
||||
'personInfo/lastname': 'Ross',
|
||||
'personInfo/sexe': 'F',
|
||||
'personInfo/dateBirth': '1944-03-26',
|
||||
'personInfo/contact/phone': '01999999999',
|
||||
'personInfo/contact/mobile': '0723456789',
|
||||
'personInfo/contact/mail': 'dross@example.org',
|
||||
'personQuality/code': '',
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613880', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == "personQuality/code: '' does not match '.+'"
|
||||
|
||||
|
||||
def test_create_child_person_not_linked_error(con, app):
|
||||
url = get_endpoint('create-child-person')
|
||||
params = {
|
||||
|
@ -2119,6 +2193,20 @@ def test_update_child_pai(mocked_post, mocked_get, con, app):
|
|||
assert resp.json['data'] == 'ok'
|
||||
|
||||
|
||||
def test_update_child_pai_empty_referential_key_error(con, app):
|
||||
url = get_endpoint('update-child-pai')
|
||||
params = {
|
||||
'code': '',
|
||||
'dateDeb': '2022-01-01',
|
||||
'dateFin': '',
|
||||
'description': 'some text',
|
||||
}
|
||||
|
||||
resp = app.post_json(url + '?NameID=local&child_id=613878', params=params, status=400)
|
||||
assert resp.json['err'] == 1
|
||||
assert resp.json['err_desc'] == "code: '' does not match '.+'"
|
||||
|
||||
|
||||
def test_update_child_pai_not_linked_error(con, app):
|
||||
url = get_endpoint('update-child-pai')
|
||||
params = {
|
||||
|
|
Loading…
Reference in New Issue