workflows: correctly pass over wscall connection errors (#15239)
This commit is contained in:
parent
53527eb0c1
commit
6b2ce5c750
|
@ -1176,6 +1176,15 @@ def test_webservice_call_error_handling(pub):
|
|||
item.perform(formdata)
|
||||
formdata.workflow_data = None
|
||||
|
||||
# connection error
|
||||
item = WebserviceCallStatusItem()
|
||||
item.url = 'http://remote.example.net/connection-error'
|
||||
item.post = False
|
||||
item.record_errors = True
|
||||
item.action_on_network_errors = ':pass'
|
||||
item.perform(formdata)
|
||||
assert formdata.evolution[-1].parts[-1].summary == 'ConnectionError: error\n'
|
||||
|
||||
def test_timeout(pub):
|
||||
workflow = Workflow(name='timeout')
|
||||
st1 = workflow.add_status('Status1', 'st1')
|
||||
|
|
|
@ -22,6 +22,7 @@ from wcs.users import User
|
|||
from wcs.tracking_code import TrackingCode
|
||||
import wcs.qommon.sms
|
||||
import qommon.sms
|
||||
from qommon.errors import ConnectionError
|
||||
|
||||
class QWIP:
|
||||
# copy of quixote original QWIP code, adapted to use our own HTTPRequest
|
||||
|
@ -263,6 +264,7 @@ class HttpRequestsMocking(object):
|
|||
{'content-type': 'text/xml'}),
|
||||
'http://remote.example.net/xml-errheader': (200, '<?xml version="1.0"><foo/>',
|
||||
{'content-type': 'text/xml', 'x-error-code': '1'}),
|
||||
'http://remote.example.net/connection-error': (None, None, None),
|
||||
}.get(base_url, (200, '', {}))
|
||||
|
||||
class FakeResponse(object):
|
||||
|
@ -276,6 +278,8 @@ class HttpRequestsMocking(object):
|
|||
def getheader(self, header):
|
||||
return self.headers.get(header, None)
|
||||
|
||||
if status is None:
|
||||
raise ConnectionError('error')
|
||||
return FakeResponse(status, data, headers), status, data, None
|
||||
|
||||
def get_last(self, attribute):
|
||||
|
|
|
@ -258,6 +258,7 @@ class WebserviceCallStatusItem(WorkflowStatusItem):
|
|||
status = 0
|
||||
self.action_on_error(self.action_on_network_errors, formdata,
|
||||
exc_info=sys.exc_info())
|
||||
return
|
||||
|
||||
app_error_code = 0
|
||||
app_error_code_header = response.getheader('x-error-code')
|
||||
|
|
Loading…
Reference in New Issue