Improve tests for trades_proxy

This commit is contained in:
Matthias
2021-03-13 15:46:20 +01:00
parent d1acc8092c
commit 0320c8dc92
3 changed files with 27 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
# pragma pylint: disable=missing-docstring, C0103
import logging
from datetime import datetime, timedelta, timezone
from types import FunctionType
from unittest.mock import MagicMock
@@ -1044,6 +1045,7 @@ def test_fee_updated(fee):
def test_total_open_trades_stakes(fee, use_db):
Trade.use_db = use_db
Trade.reset_trades()
res = Trade.total_open_trades_stakes()
assert res == 0
create_mock_trades(fee, use_db)
@@ -1053,6 +1055,26 @@ def test_total_open_trades_stakes(fee, use_db):
Trade.use_db = True
@pytest.mark.usefixtures("init_persistence")
@pytest.mark.parametrize('use_db', [True, False])
def test_get_trades_proxy(fee, use_db):
Trade.use_db = use_db
Trade.reset_trades()
create_mock_trades(fee, use_db)
trades = Trade.get_trades_proxy()
assert len(trades) == 6
assert isinstance(trades[0], Trade)
assert len(Trade.get_trades_proxy(is_open=True)) == 4
assert len(Trade.get_trades_proxy(is_open=False)) == 2
opendate = datetime.now(tz=timezone.utc) - timedelta(minutes=15)
assert len(Trade.get_trades_proxy(open_date=opendate)) == 3
Trade.use_db = True
@pytest.mark.usefixtures("init_persistence")
def test_get_overall_performance(fee):