greco: send an empty string when a param is missing (#77681)
gitea/passerelle/pipeline/head This commit looks good Details

This commit is contained in:
Emmanuel Cazenave 2023-05-16 18:14:35 +02:00
parent 9a4f57612e
commit 31efc19163
2 changed files with 11 additions and 7 deletions

View File

@ -117,13 +117,15 @@ class FormData:
self.fields[fieldname] = value self.fields[fieldname] = value
if isinstance(value, datetime): if isinstance(value, datetime):
value = value.strftime('%Y-%m-%dT%H:%M:%S') value = value.strftime('%Y-%m-%dT%H:%M:%S')
if '_' not in fieldname: else:
self.json[fieldname] = value value = ''
continue if '_' not in fieldname:
key, subkey = fieldname.split('_') self.json[fieldname] = value
if key not in self.json: continue
self.json[key] = {} key, subkey = fieldname.split('_')
self.json[key][subkey] = value if key not in self.json:
self.json[key] = {}
self.json[key][subkey] = value
# https://dev.entrouvert.org/issues/75259 # https://dev.entrouvert.org/issues/75259
danger = self.json.get('danger', '') danger = self.json.get('danger', '')

View File

@ -246,6 +246,8 @@ def test_greco_rest_create_ok(app, rest_conn):
assert json_part.headers[b'Content-Type'] == b'application/json' assert json_part.headers[b'Content-Type'] == b'application/json'
demande_creation = json.loads(json_part.content) demande_creation = json.loads(json_part.content)
assert demande_creation['application'] == '69999' assert demande_creation['application'] == '69999'
assert demande_creation['beneficiaire']['fax'] == ''
assert demande_creation['beneficiaire']['numerovoie'] == ''
assert demande_creation['localisation']['xgeoloc'] == '50.89491' assert demande_creation['localisation']['xgeoloc'] == '50.89491'
assert demande_creation['localisation']['ygeoloc'] == '4.34151' assert demande_creation['localisation']['ygeoloc'] == '4.34151'
assert demande_creation['transmetteur']['nom'] == 'Vertommen' assert demande_creation['transmetteur']['nom'] == 'Vertommen'