datasource: fix get_id_by_option_text with None result (#67409)
gitea-wip/wcs/pipeline/head Build started... Details

This commit is contained in:
Lauréline Guérin 2022-07-28 09:20:25 +02:00
parent 4932d67265
commit 00326aca67
No known key found for this signature in database
GPG Key ID: 1FAB9B9B4F93D473
2 changed files with 10 additions and 1 deletions

View File

@ -12,6 +12,7 @@ from wcs.blocks import BlockDef
from wcs.carddef import CardDef
from wcs.data_sources import NamedDataSource
from wcs.formdef import FormDef
from wcs.qommon import misc
from wcs.wf.form import WorkflowFormFieldsFormDef
from wcs.workflows import Workflow
@ -1182,6 +1183,14 @@ def test_field_live_item_datasource_prefill_with_request_with_q(urlopen, pub):
# check it has ?q=
assert urlopen.call_args[0][0] == 'http://remote.example.net/json?plop=&q=deux'
urlopen.side_effect = misc.ConnectionError('...')
# no error
app.post(
'/foo/live?modified_field_id=init&prefilled_1=on&prefilled_2=on',
params=resp.form.submit_fields(),
status=200,
)
def test_field_live_block_string_prefill(pub, http_requests):
FormDef.wipe()

View File

@ -217,7 +217,7 @@ def get_id_by_option_text(data_source, text_value):
items = get_structured_items(data_source.extended_data_source, include_disabled=False)
# fallback to iterating on all options
for option in items:
for option in items or []:
# get raw value from display value
if option['text'] == text_value:
return str(option['id'])