portfolio: add details on push error (#63141)
This commit is contained in:
parent
e1d33d582b
commit
d8a7db2f12
|
@ -821,13 +821,14 @@ def test_formdata_generated_document_odt_to_pdf_download_push_to_portfolio(
|
|||
|
||||
resp = login(get_app(pub), username='foo', password='foo').get(form_location)
|
||||
with mock.patch('wcs.portfolio.http_post_request') as http_post_request:
|
||||
http_post_request.return_value = None, 400, 'null', None # fail
|
||||
http_post_request.return_value = None, 400, '{"code": "document-exists"}', None # fail
|
||||
resp = resp.form.submit('button_export_to')
|
||||
assert http_post_request.call_count == 1
|
||||
if pub.is_using_postgresql():
|
||||
assert pub.loggederror_class.select()[0].summary.startswith(
|
||||
"file 'template.pdf' failed to be pushed to portfolio of 'Foo"
|
||||
)
|
||||
error = pub.loggederror_class.select()[0]
|
||||
assert error.summary.startswith("file 'template.pdf' failed to be pushed to portfolio of 'Foo")
|
||||
assert 'status: 400' in error.summary
|
||||
assert "payload: {'code': 'document-exists'}" in error.summary
|
||||
|
||||
# failed to push to portfolio, but document is here
|
||||
resp = resp.follow() # $form/$id/create_doc
|
||||
|
|
|
@ -77,11 +77,18 @@ def push_document(user, filename, stream):
|
|||
|
||||
def afterjob(job):
|
||||
status = 0
|
||||
status = async_post()[0]
|
||||
status, payload = async_post()
|
||||
if status != 200:
|
||||
publisher.record_error(
|
||||
_('file %(filename)r failed to be pushed to portfolio of %(display_name)r')
|
||||
% {'filename': filename, 'display_name': user.display_name}
|
||||
_(
|
||||
'file %(filename)r failed to be pushed to portfolio of %(display_name)r [status: %(status)d, payload: %(payload)r]'
|
||||
)
|
||||
% {
|
||||
'filename': filename,
|
||||
'display_name': user.display_name,
|
||||
'status': status,
|
||||
'payload': payload,
|
||||
}
|
||||
)
|
||||
|
||||
if get_response():
|
||||
|
|
Loading…
Reference in New Issue