refactor: tests - update timezone.utc to UTC
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
from copy import deepcopy
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from unittest.mock import ANY, MagicMock, PropertyMock
|
||||
|
||||
import pytest
|
||||
@@ -347,7 +347,7 @@ def test__rpc_timeunit_profit(
|
||||
assert day["starting_balance"] in (pytest.approx(1062.37), pytest.approx(1066.46))
|
||||
assert day["fiat_value"] in (0.0,)
|
||||
# ensure first day is current date
|
||||
assert str(days["data"][0]["date"]) == str(datetime.now(timezone.utc).date())
|
||||
assert str(days["data"][0]["date"]) == str(datetime.now(UTC).date())
|
||||
|
||||
# Try invalid data
|
||||
with pytest.raises(RPCException, match=r".*must be an integer greater than 0*"):
|
||||
@@ -1296,9 +1296,9 @@ def test_rpc_add_and_delete_lock(mocker, default_conf):
|
||||
rpc = RPC(freqtradebot)
|
||||
pair = "ETH/BTC"
|
||||
|
||||
rpc._rpc_add_lock(pair, datetime.now(timezone.utc) + timedelta(minutes=4), "", "*")
|
||||
rpc._rpc_add_lock(pair, datetime.now(timezone.utc) + timedelta(minutes=5), "", "*")
|
||||
rpc._rpc_add_lock(pair, datetime.now(timezone.utc) + timedelta(minutes=10), "", "*")
|
||||
rpc._rpc_add_lock(pair, datetime.now(UTC) + timedelta(minutes=4), "", "*")
|
||||
rpc._rpc_add_lock(pair, datetime.now(UTC) + timedelta(minutes=5), "", "*")
|
||||
rpc._rpc_add_lock(pair, datetime.now(UTC) + timedelta(minutes=10), "", "*")
|
||||
|
||||
locks = rpc._rpc_locks()
|
||||
assert locks["lock_count"] == 3
|
||||
|
||||
@@ -5,7 +5,7 @@ Unit test file for rpc/api_server.py
|
||||
import asyncio
|
||||
import logging
|
||||
import time
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from pathlib import Path
|
||||
from unittest.mock import ANY, MagicMock, PropertyMock
|
||||
|
||||
@@ -637,12 +637,12 @@ def test_api_locks(botclient):
|
||||
[
|
||||
{
|
||||
"pair": "ETH/BTC",
|
||||
"until": f"{format_date(datetime.now(timezone.utc) + timedelta(minutes=4))}Z",
|
||||
"until": f"{format_date(datetime.now(UTC) + timedelta(minutes=4))}Z",
|
||||
"reason": "randreason",
|
||||
},
|
||||
{
|
||||
"pair": "XRP/BTC",
|
||||
"until": f"{format_date(datetime.now(timezone.utc) + timedelta(minutes=20))}Z",
|
||||
"until": f"{format_date(datetime.now(UTC) + timedelta(minutes=20))}Z",
|
||||
"reason": "deadbeef",
|
||||
},
|
||||
],
|
||||
@@ -711,7 +711,7 @@ def test_api_daily(botclient, mocker, ticker, fee, markets):
|
||||
assert len(response["data"]) == 7
|
||||
assert response["stake_currency"] == "BTC"
|
||||
assert response["fiat_display_currency"] == "USD"
|
||||
assert response["data"][0]["date"] == str(datetime.now(timezone.utc).date())
|
||||
assert response["data"][0]["date"] == str(datetime.now(UTC).date())
|
||||
|
||||
|
||||
def test_api_weekly(botclient, mocker, ticker, fee, markets, time_machine):
|
||||
@@ -1695,7 +1695,7 @@ def test_api_force_entry(botclient, mocker, fee, endpoint):
|
||||
exchange="binance",
|
||||
stake_amount=1,
|
||||
open_rate=0.245441,
|
||||
open_date=datetime.now(timezone.utc),
|
||||
open_date=datetime.now(UTC),
|
||||
is_open=False,
|
||||
is_short=False,
|
||||
fee_close=fee.return_value,
|
||||
|
||||
@@ -4,7 +4,7 @@ Unit test file for rpc/external_message_consumer.py
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
from datetime import datetime, timezone
|
||||
from datetime import UTC, datetime
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
@@ -99,7 +99,7 @@ def test_emc_handle_producer_message(patched_emc, caplog, ohlcv_history):
|
||||
"data": {
|
||||
"key": ("BTC/USDT", "5m", "spot"),
|
||||
"df": ohlcv_history,
|
||||
"la": datetime.now(timezone.utc),
|
||||
"la": datetime.now(UTC),
|
||||
},
|
||||
}
|
||||
patched_emc.handle_producer_message(test_producer, df_message)
|
||||
@@ -123,7 +123,7 @@ def test_emc_handle_producer_message(patched_emc, caplog, ohlcv_history):
|
||||
|
||||
malformed_message = {
|
||||
"type": "analyzed_df",
|
||||
"data": {"key": "BTC/USDT", "df": ohlcv_history, "la": datetime.now(timezone.utc)},
|
||||
"data": {"key": "BTC/USDT", "df": ohlcv_history, "la": datetime.now(UTC)},
|
||||
}
|
||||
patched_emc.handle_producer_message(test_producer, malformed_message)
|
||||
|
||||
@@ -137,7 +137,7 @@ def test_emc_handle_producer_message(patched_emc, caplog, ohlcv_history):
|
||||
"data": {
|
||||
"key": ("BTC/USDT", "5m", "spot"),
|
||||
"df": ohlcv_history.loc[ohlcv_history["open"] < 0],
|
||||
"la": datetime.now(timezone.utc),
|
||||
"la": datetime.now(UTC),
|
||||
},
|
||||
}
|
||||
patched_emc.handle_producer_message(test_producer, malformed_message)
|
||||
|
||||
Reference in New Issue
Block a user