0001-misc-add-get_base64_content-to-get-file-content-as-b.patch
tests/test_workflows.py | ||
---|---|---|
1 |
import base64 |
|
1 | 2 |
import json |
2 | 3 |
import datetime |
3 | 4 |
import os |
... | ... | |
3665 | 3666 |
assert formdata.data['bo1'].base_filename == 'test.jpeg' |
3666 | 3667 |
assert formdata.data['bo1'].content_type == 'image/jpeg' |
3667 | 3668 |
assert formdata.data['bo1'].get_content() == open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb').read() |
3669 |
assert formdata.data['bo1'].get_base64_content() == base64.encodestring( |
|
3670 |
open(os.path.join(os.path.dirname(__file__), 'image-with-gps-data.jpeg'), 'rb').read()) |
|
3668 | 3671 | |
3669 | 3672 |
# same test with PicklableUpload wcs.qommon.form |
3670 | 3673 |
from wcs.qommon.form import PicklableUpload as PicklableUpload2 |
wcs/qommon/form.py | ||
---|---|---|
872 | 872 |
return open(filename, 'rb').read() |
873 | 873 |
return None |
874 | 874 | |
875 |
def get_base64_content(self): |
|
876 |
content = self.get_content() |
|
877 |
if content: |
|
878 |
return base64.encodestring(content) |
|
879 |
return None |
|
880 | ||
875 | 881 | |
876 | 882 |
class EmailWidget(StringWidget): |
877 | 883 |
HTML_TYPE = 'email' |
878 |
- |