wscall: returns computed url and query on call_webservices
This commit is contained in:
parent
f790982b96
commit
56ad5ff96b
|
@ -107,7 +107,7 @@ def test_form_file_field_upload_storage(wscall, pub):
|
|||
assert formdef.fields[1].storage == 'remote'
|
||||
|
||||
wscall.return_value = None, 200, json.dumps(
|
||||
{"err": 0, "data": {"redirect_url": "https://crypto.example.net/"}})
|
||||
{"err": 0, "data": {"redirect_url": "https://crypto.example.net/"}}), None, None
|
||||
|
||||
image_content = open(os.path.join(os.path.dirname(__file__),
|
||||
'image-with-gps-data.jpeg'), 'rb').read()
|
||||
|
@ -140,7 +140,7 @@ def test_form_file_field_upload_storage(wscall, pub):
|
|||
"redirect_url": "https://crypto.example.net/",
|
||||
"backoffice_redirect_url": None,
|
||||
"frontoffice_redirect_url": None,
|
||||
}})
|
||||
}}), None, None
|
||||
resp = get_app(pub).get('/test/')
|
||||
resp.forms[0]['f0$file'] = upload_0
|
||||
resp.forms[0]['f1$file'] = upload_1
|
||||
|
@ -164,7 +164,7 @@ def test_form_file_field_upload_storage(wscall, pub):
|
|||
formdef.fields[1].storage = 'remote-bo'
|
||||
formdef.store()
|
||||
wscall.return_value = None, 200, json.dumps(
|
||||
{"err": 0, "data": {"redirect_url": "https://crypto.example.net/"}})
|
||||
{"err": 0, "data": {"redirect_url": "https://crypto.example.net/"}}), None, None
|
||||
resp = get_app(pub).get('/test/')
|
||||
resp.forms[0]['f0$file'] = upload_0
|
||||
resp.forms[0]['f1$file'] = upload_1
|
||||
|
@ -187,7 +187,7 @@ def test_form_file_field_upload_storage(wscall, pub):
|
|||
formdef.fields[1].max_file_size = '1ko'
|
||||
formdef.store()
|
||||
wscall.return_value = None, 200, json.dumps(
|
||||
{"err": 0, "data": {"redirect_url": "https://crypto.example.net/"}})
|
||||
{"err": 0, "data": {"redirect_url": "https://crypto.example.net/"}}), None, None
|
||||
resp = get_app(pub).get('/test/')
|
||||
resp.forms[0]['f0$file'] = upload_0
|
||||
resp.forms[0]['f1$file'] = upload_1
|
||||
|
@ -233,7 +233,7 @@ def test_remoteopaque_in_attachmentevolutionpart(wscall, pub):
|
|||
formdef.data_class().wipe()
|
||||
|
||||
wscall.return_value = None, 200, json.dumps(
|
||||
{"err": 0, "data": {"redirect_url": "https://crypto.example.net/"}})
|
||||
{"err": 0, "data": {"redirect_url": "https://crypto.example.net/"}}), None, None
|
||||
|
||||
image_content = open(os.path.join(os.path.dirname(__file__),
|
||||
'image-with-gps-data.jpeg'), 'rb').read()
|
||||
|
|
|
@ -222,7 +222,7 @@ class PasserelleSMS(object):
|
|||
'to': destinations,
|
||||
}
|
||||
|
||||
response, status, data = call_webservice(self.url, method='POST',
|
||||
response, status, data, url, payload = call_webservice(self.url, method='POST',
|
||||
post_data=payload)
|
||||
get_logger().debug('sms %r sent using passerelle to %r, result: %r',
|
||||
text, destinations, data)
|
||||
|
|
|
@ -185,7 +185,7 @@ class RemoteOpaqueUploadStorage(object):
|
|||
}
|
||||
try:
|
||||
from wcs.wscalls import call_webservice
|
||||
response, status, data = call_webservice(self.ws, method='POST', post_data=post_data)
|
||||
response, status, data, url, payload = call_webservice(self.ws, method='POST', post_data=post_data)
|
||||
except ConnectionError as e:
|
||||
raise UploadStorageError('remote storage connection error (%r)' % e)
|
||||
if status not in (200, 201):
|
||||
|
|
|
@ -329,7 +329,7 @@ class WebserviceCallStatusItem(WorkflowStatusItem):
|
|||
workflow_data['%s_time' % self.varname] = datetime.datetime.now().isoformat()
|
||||
|
||||
try:
|
||||
response, status, data = call_webservice(
|
||||
response, status, data, url, payload = call_webservice(
|
||||
url=self.url,
|
||||
qs_data=self.qs_data,
|
||||
request_signature_key=self.request_signature_key,
|
||||
|
|
|
@ -100,7 +100,7 @@ def call_webservice(
|
|||
if method == 'GET' and cache is True: # check cache
|
||||
request = get_request()
|
||||
if hasattr(request, 'wscalls_cache') and unsigned_url in request.wscalls_cache:
|
||||
return (None,) + request.wscalls_cache[unsigned_url]
|
||||
return (None,) + request.wscalls_cache[unsigned_url] + (None, None)
|
||||
|
||||
if request_signature_key:
|
||||
signature_key = str(WorkflowStatusItem.compute(request_signature_key))
|
||||
|
@ -157,7 +157,8 @@ def call_webservice(
|
|||
get_publisher().notify_of_exception(
|
||||
exc_info, context='[WSCALL]', notify=notify_on_errors, record=record_on_errors)
|
||||
|
||||
return (response, status, data)
|
||||
# return response data + request computed URL and payload
|
||||
return (response, status, data, unsigned_url, payload)
|
||||
|
||||
|
||||
class NamedWsCall(XmlStorableObject):
|
||||
|
@ -250,7 +251,7 @@ class NamedWsCall(XmlStorableObject):
|
|||
return {'webservice': WsCallsSubstitutionProxy()}
|
||||
|
||||
def call(self):
|
||||
(response, status, data) = call_webservice(
|
||||
(response, status, data, url, payload) = call_webservice(
|
||||
cache=True,
|
||||
notify_on_errors=self.notify_on_errors,
|
||||
record_on_errors=self.record_on_errors,
|
||||
|
|
Loading…
Reference in New Issue