0001-misc-let-Decimal-be-encoded-in-json-as-strings-11001.patch
tests/test_workflows.py | ||
---|---|---|
620 | 620 | |
621 | 621 |
item = WebserviceCallStatusItem() |
622 | 622 |
item.url = 'http://remote.example.net' |
623 |
item.post_data = {'str': 'abcd', 'one': '=1', |
|
623 |
item.post_data = {'str': 'abcd', 'one': '=1', 'decimal': '=Decimal(2)',
|
|
624 | 624 |
'evalme': '=form_number', 'error':'=1=3'} |
625 | 625 |
pub.substitutions.feed(formdata) |
626 | 626 |
item.perform(formdata) |
627 | 627 |
assert http_requests.get_last('url') == 'http://remote.example.net' |
628 | 628 |
assert http_requests.get_last('method') == 'POST' |
629 | 629 |
payload = json.loads(http_requests.get_last('body')) |
630 |
assert payload['extra'] == {'one': 1, 'str': 'abcd', 'evalme': formdata.get_display_id()} |
|
630 |
assert payload['extra'] == {'one': 1, 'str': 'abcd', |
|
631 |
'decimal': '2', 'evalme': formdata.get_display_id()} |
|
631 | 632 |
assert payload['url'] == 'http://example.net/baz/%s/' % formdata.id |
632 | 633 |
assert payload['display_id'] == formdata.get_display_id() |
633 | 634 |
wcs/qommon/misc.py | ||
---|---|---|
15 | 15 |
# along with this program; if not, see <http://www.gnu.org/licenses/>. |
16 | 16 | |
17 | 17 |
import datetime |
18 |
import decimal |
|
18 | 19 |
import calendar |
19 | 20 |
import re |
20 | 21 |
import os |
... | ... | |
428 | 429 |
if isinstance(obj, time.struct_time): |
429 | 430 |
return datetime.datetime.utcfromtimestamp(time.mktime(obj)).isoformat() + 'Z' |
430 | 431 | |
432 |
if isinstance(obj, decimal.Decimal): |
|
433 |
return str(obj) |
|
434 | ||
431 | 435 |
# PicklableUpload may be known as qommon.form.PicklableUpload or |
432 | 436 |
# wcs.qommon.form.PicklableUpload and considered different classes |
433 | 437 |
# by Python. It shouldn't have to be that way but workaround that |
434 |
- |