external_workflow: do not record error on missing target (#56832)
This commit is contained in:
parent
e27f5b7e66
commit
59a4fcb485
|
@ -6630,8 +6630,6 @@ def test_create_carddata_user_association(two_pubs):
|
|||
def test_call_external_workflow_with_evolution_linked_object(two_pubs):
|
||||
FormDef.wipe()
|
||||
CardDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
|
||||
external_wf = Workflow(name='External Workflow')
|
||||
st1 = external_wf.add_status(name='New')
|
||||
|
@ -6704,26 +6702,14 @@ def test_call_external_workflow_with_evolution_linked_object(two_pubs):
|
|||
|
||||
assert external_formdef.data_class().count() == 1
|
||||
assert external_carddef.data_class().count() == 1
|
||||
external_formdata = external_formdef.data_class().select()[0]
|
||||
|
||||
# remove external formdata
|
||||
perform_items([action], formdata)
|
||||
if two_pubs.is_using_postgresql():
|
||||
assert two_pubs.loggederror_class.count() == 0
|
||||
assert external_formdef.data_class().count() == 0
|
||||
assert external_carddef.data_class().count() == 1
|
||||
|
||||
# formdata is already deleted: cannot find it again
|
||||
# formdata is already deleted: cannot find it again, no problem
|
||||
perform_items([action], formdata)
|
||||
if two_pubs.is_using_postgresql():
|
||||
assert two_pubs.loggederror_class.count() == 1
|
||||
logged_error = two_pubs.loggederror_class.select()[0]
|
||||
assert (
|
||||
logged_error.summary
|
||||
== 'Could not find linked "External Form" object by id %s' % external_formdata.id
|
||||
)
|
||||
assert logged_error.exception_class == 'KeyError'
|
||||
assert logged_error.status_item_id == action.id
|
||||
|
||||
# try remove an unexisting carddef: do nothing
|
||||
unused_carddef = CardDef()
|
||||
|
@ -6731,21 +6717,15 @@ def test_call_external_workflow_with_evolution_linked_object(two_pubs):
|
|||
unused_carddef.fields = []
|
||||
unused_carddef.workflow = external_wf
|
||||
unused_carddef.store()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
action.slug = 'carddef:%s' % unused_carddef.url_name
|
||||
wf.store()
|
||||
perform_items([action], formdata)
|
||||
if two_pubs.is_using_postgresql():
|
||||
assert two_pubs.loggederror_class.count() == 0
|
||||
assert external_formdef.data_class().count() == 0
|
||||
assert external_carddef.data_class().count() == 1
|
||||
# remove the right carddef
|
||||
action.slug = 'carddef:%s' % external_carddef.url_name
|
||||
wf.store()
|
||||
perform_items([action], formdata)
|
||||
if two_pubs.is_using_postgresql():
|
||||
assert two_pubs.loggederror_class.count() == 0
|
||||
assert external_formdef.data_class().count() == 0
|
||||
assert external_carddef.data_class().count() == 0
|
||||
|
||||
|
@ -6753,8 +6733,6 @@ def test_call_external_workflow_with_evolution_linked_object(two_pubs):
|
|||
def test_call_external_workflow_with_data_sourced_object(two_pubs):
|
||||
FormDef.wipe()
|
||||
CardDef.wipe()
|
||||
if two_pubs.is_using_postgresql():
|
||||
two_pubs.loggederror_class.wipe()
|
||||
|
||||
carddef_wf = Workflow(name='Carddef Workflow')
|
||||
carddef_wf.backoffice_fields_formdef = WorkflowBackofficeFieldsFormDef(carddef_wf)
|
||||
|
@ -6811,8 +6789,6 @@ def test_call_external_workflow_with_data_sourced_object(two_pubs):
|
|||
formdef.workflow = wf
|
||||
formdef.store()
|
||||
|
||||
if two_pubs.is_using_postgresql():
|
||||
assert two_pubs.loggederror_class.count() == 0
|
||||
assert carddef.data_class().count() == 1
|
||||
|
||||
formdata = formdef.data_class()()
|
||||
|
@ -6822,8 +6798,6 @@ def test_call_external_workflow_with_data_sourced_object(two_pubs):
|
|||
formdata.perform_workflow()
|
||||
|
||||
perform_items([update_action], formdata)
|
||||
if two_pubs.is_using_postgresql():
|
||||
assert two_pubs.loggederror_class.count() == 0
|
||||
assert carddef.data_class().count() == 1
|
||||
data = carddef.data_class().select()[0]
|
||||
assert data.data['bo0'] == '1'
|
||||
|
@ -6833,16 +6807,10 @@ def test_call_external_workflow_with_data_sourced_object(two_pubs):
|
|||
assert data.data['bo0'] == '2'
|
||||
|
||||
perform_items([delete_action], formdata)
|
||||
if two_pubs.is_using_postgresql():
|
||||
assert two_pubs.loggederror_class.count() == 0
|
||||
assert carddef.data_class().count() == 0
|
||||
|
||||
# linked object is removed: no problem
|
||||
perform_items([delete_action], formdata)
|
||||
if two_pubs.is_using_postgresql():
|
||||
assert two_pubs.loggederror_class.count() == 1
|
||||
logged_error = two_pubs.loggederror_class.select()[0]
|
||||
assert logged_error.summary == 'Could not find linked "Data" object by id %s' % carddata.id
|
||||
assert logged_error.exception_class == 'KeyError'
|
||||
|
||||
|
||||
def test_call_external_workflow_with_parent_object(pub):
|
||||
|
|
|
@ -1392,15 +1392,9 @@ class FormData(StorableObject):
|
|||
# workflow action
|
||||
try:
|
||||
yield objectdef.data_class().get(target_id)
|
||||
except KeyError as e:
|
||||
# use custom error message depending on target type
|
||||
get_publisher().record_error(
|
||||
_('Could not find linked "%(object_name)s" object by id %(object_id)s')
|
||||
% {'object_name': objectdef.name, 'object_id': target_id},
|
||||
formdata=self,
|
||||
status_item=status_item,
|
||||
exception=e,
|
||||
)
|
||||
except KeyError:
|
||||
# linked object may be missing
|
||||
pass
|
||||
else:
|
||||
# inspect page
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue