0001-misc-fix-serialization-of-PicklableUpload-imported-f.patch
tests/test_api.py | ||
---|---|---|
874 | 874 | |
875 | 875 |
upload = PicklableUpload('test.txt', 'text/plain', 'ascii') |
876 | 876 |
upload.receive(['test']) |
877 |
formdata.workflow_data = {'blah': upload, 'xxx': 23} |
|
877 |
from qommon.form import PicklableUpload as PicklableUpload2 |
|
878 |
upload2 = PicklableUpload2('test.txt', 'text/plain', 'ascii') |
|
879 |
upload2.receive(['test']) |
|
880 |
formdata.workflow_data = {'blah': upload, 'blah2': upload2, 'xxx': 23} |
|
878 | 881 |
formdata.store() |
879 | 882 | |
880 | 883 |
resp = get_app(pub).get( |
... | ... | |
883 | 886 |
assert resp.json['workflow']['data']['blah']['filename'] == 'test.txt' |
884 | 887 |
assert resp.json['workflow']['data']['blah']['content_type'] == 'text/plain' |
885 | 888 |
assert base64.decodestring(resp.json['workflow']['data']['blah']['content']) == 'test' |
889 |
assert base64.decodestring(resp.json['workflow']['data']['blah2']['content']) == 'test' |
|
886 | 890 | |
887 | 891 |
def test_user_by_nameid(pub, local_user): |
888 | 892 |
resp = get_app(pub).get(sign_uri('/api/users/xyz/', user=local_user), |
wcs/qommon/misc.py | ||
---|---|---|
428 | 428 |
if isinstance(obj, time.struct_time): |
429 | 429 |
return datetime.datetime.utcfromtimestamp(time.mktime(obj)).isoformat() + 'Z' |
430 | 430 | |
431 |
from .form import PicklableUpload |
|
432 |
if isinstance(obj, PicklableUpload): |
|
431 |
# PicklableUpload may be known as qommon.form.PicklableUpload or |
|
432 |
# wcs.qommon.form.PicklableUpload and considered different classes |
|
433 |
# by Python. It shouldn't have to be that way but workaround that |
|
434 |
# and check for both classes. |
|
435 |
from qommon.form import PicklableUpload |
|
436 |
from wcs.qommon.form import PicklableUpload as PicklableUpload2 |
|
437 |
if isinstance(obj, PicklableUpload) or isinstance(obj, PicklableUpload2): |
|
433 | 438 |
return { |
434 | 439 |
'filename': obj.base_filename, |
435 | 440 |
'content_type': obj.content_type or 'application/octet-stream', |
436 |
- |