Add --fmt-jsonnums option.
This commit is contained in:
parent
a3e19f9bcf
commit
aabce7fe6f
6 changed files with 58 additions and 3 deletions
|
@ -125,3 +125,44 @@ def test_format_custom(json_out, series, mocker):
|
|||
).strip()
|
||||
+ "\n"
|
||||
)
|
||||
|
||||
|
||||
def test_format_numbers(json_out, series, mocker):
|
||||
source = mocker.MagicMock()
|
||||
source.id = mocker.MagicMock(return_value="sourceid")
|
||||
fmt = Format(jsonnums=True)
|
||||
result = json_out.format(series, source, fmt)
|
||||
assert (
|
||||
result
|
||||
== dedent(
|
||||
"""
|
||||
[
|
||||
{
|
||||
"date": "2021-01-01",
|
||||
"base": "BTC",
|
||||
"quote": "EUR",
|
||||
"amount": 24139.4648,
|
||||
"source": "sourceid",
|
||||
"type": "close"
|
||||
},
|
||||
{
|
||||
"date": "2021-01-02",
|
||||
"base": "BTC",
|
||||
"quote": "EUR",
|
||||
"amount": 26533.576,
|
||||
"source": "sourceid",
|
||||
"type": "close"
|
||||
},
|
||||
{
|
||||
"date": "2021-01-03",
|
||||
"base": "BTC",
|
||||
"quote": "EUR",
|
||||
"amount": 27001.2846,
|
||||
"source": "sourceid",
|
||||
"type": "close"
|
||||
}
|
||||
]
|
||||
"""
|
||||
).strip()
|
||||
+ "\n"
|
||||
)
|
||||
|
|
|
@ -14,6 +14,7 @@ def test_fromargs():
|
|||
"formatdatesep": None,
|
||||
"formatcsvdelim": None,
|
||||
"formatbase": None,
|
||||
"formatjsonnums": None,
|
||||
}
|
||||
args = namedtuple("args", arg_values.keys())(**arg_values)
|
||||
fmt = Format.fromargs(args)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue