From 261a593ba56ae9ecb8d82ab438f6d824f7c9f163 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 31 Jul 2023 18:04:25 +0200 Subject: [PATCH] Update tests for new output format (string-formatted dates are not relevant). --- freqtrade/rpc/api_server/api_schemas.py | 6 +++--- tests/rpc/test_rpc_apiserver.py | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/freqtrade/rpc/api_server/api_schemas.py b/freqtrade/rpc/api_server/api_schemas.py index bd405d22b..4c674e05e 100644 --- a/freqtrade/rpc/api_server/api_schemas.py +++ b/freqtrade/rpc/api_server/api_schemas.py @@ -1,7 +1,7 @@ from datetime import date, datetime from typing import Any, Dict, List, Optional, Union -from pydantic import BaseModel +from pydantic import BaseModel, SerializeAsAny from freqtrade.constants import DATETIME_PRINT_FORMAT, IntOrInf from freqtrade.enums import MarginMode, OrderTypeValues, SignalDirection, TradingMode @@ -470,7 +470,7 @@ class PairHistory(BaseModel): timeframe: str timeframe_ms: int columns: List[str] - data: List[Any] + data: SerializeAsAny[List[Any]] length: int buy_signals: int sell_signals: int @@ -517,7 +517,7 @@ class BacktestResponse(BaseModel): progress: float trade_count: Optional[float] # TODO: Properly type backtestresult... - backtest_result: Optional[Dict[str, Any]] + backtest_result: SerializeAsAny[Optional[Dict[str, Any]]] = None # TODO: This is a copy of BacktestHistoryEntryType diff --git a/tests/rpc/test_rpc_apiserver.py b/tests/rpc/test_rpc_apiserver.py index abbaa421e..131606aab 100644 --- a/tests/rpc/test_rpc_apiserver.py +++ b/tests/rpc/test_rpc_apiserver.py @@ -1418,12 +1418,12 @@ def test_api_pair_candles(botclient, ohlcv_history): assert len(rc.json()['data']) == amount assert (rc.json()['data'] == - [['2017-11-26 08:50:00', 8.794e-05, 8.948e-05, 8.794e-05, 8.88e-05, 0.0877869, + [['2017-11-26T08:50:00Z', 8.794e-05, 8.948e-05, 8.794e-05, 8.88e-05, 0.0877869, None, 0, 0, 0, 0, 1511686200000, None, None, None, None], - ['2017-11-26 08:55:00', 8.88e-05, 8.942e-05, 8.88e-05, + ['2017-11-26T08:55:00Z', 8.88e-05, 8.942e-05, 8.88e-05, 8.893e-05, 0.05874751, 8.886500000000001e-05, 1, 0, 0, 0, 1511686500000, 8.893e-05, None, None, None], - ['2017-11-26 09:00:00', 8.891e-05, 8.893e-05, 8.875e-05, 8.877e-05, + ['2017-11-26T09:00:00Z', 8.891e-05, 8.893e-05, 8.875e-05, 8.877e-05, 0.7039405, 8.885e-05, 0, 0, 0, 0, 1511686800000, None, None, None, None] ]) @@ -1437,13 +1437,13 @@ def test_api_pair_candles(botclient, ohlcv_history): f"{BASE_URI}/pair_candles?limit={amount}&pair=XRP%2FBTC&timeframe={timeframe}") assert_response(rc) assert (rc.json()['data'] == - [['2017-11-26 08:50:00', 8.794e-05, 8.948e-05, 8.794e-05, 8.88e-05, 0.0877869, + [['2017-11-26T08:50:00Z', 8.794e-05, 8.948e-05, 8.794e-05, 8.88e-05, 0.0877869, None, 0, None, 0, 0, None, 1511686200000, None, None, None, None], - ['2017-11-26 08:55:00', 8.88e-05, 8.942e-05, 8.88e-05, - 8.893e-05, 0.05874751, 8.886500000000001e-05, 1, 0.0, 0, 0, '2017-11-26 08:55:00', + ['2017-11-26T08:55:00Z', 8.88e-05, 8.942e-05, 8.88e-05, + 8.893e-05, 0.05874751, 8.886500000000001e-05, 1, 0.0, 0, 0, '2017-11-26T08:55:00Z', 1511686500000, 8.893e-05, None, None, None], - ['2017-11-26 09:00:00', 8.891e-05, 8.893e-05, 8.875e-05, 8.877e-05, - 0.7039405, 8.885e-05, 0, 0.0, 0, 0, '2017-11-26 09:00:00', 1511686800000, + ['2017-11-26T09:00:00Z', 8.891e-05, 8.893e-05, 8.875e-05, 8.877e-05, + 0.7039405, 8.885e-05, 0, 0.0, 0, 0, '2017-11-26T09:00:00Z', 1511686800000, None, None, None, None] ]) @@ -1500,7 +1500,7 @@ def test_api_pair_history(botclient, mocker): date_col_idx = [idx for idx, c in enumerate(result['columns']) if c == 'date'][0] rsi_col_idx = [idx for idx, c in enumerate(result['columns']) if c == 'rsi'][0] - assert data[0][date_col_idx] == '2018-01-11 00:00:00' + assert data[0][date_col_idx] == '2018-01-11T00:00:00Z' assert data[0][rsi_col_idx] is not None assert data[0][rsi_col_idx] > 0 assert lfm.call_count == 1