From 8300eb59d4b448b4f04da34b80efd603a32a6002 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 23 Jul 2020 07:49:44 +0200 Subject: [PATCH] Extend create_mock_trades to create 4 trades 2 closed, and 2 open trades --- tests/commands/test_commands.py | 2 +- tests/conftest.py | 14 ++++++++++++++ tests/data/test_btanalysis.py | 2 +- tests/test_freqtradebot.py | 2 +- tests/test_persistence.py | 6 +++--- 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/tests/commands/test_commands.py b/tests/commands/test_commands.py index ffced956d..3ec7e4798 100644 --- a/tests/commands/test_commands.py +++ b/tests/commands/test_commands.py @@ -1089,7 +1089,7 @@ def test_show_trades(mocker, fee, capsys, caplog): pargs = get_args(args) pargs['config'] = None start_show_trades(pargs) - assert log_has("Printing 3 Trades: ", caplog) + assert log_has("Printing 4 Trades: ", caplog) captured = capsys.readouterr() assert "Trade(id=1" in captured.out assert "Trade(id=2" in captured.out diff --git a/tests/conftest.py b/tests/conftest.py index 43dc8ca78..fe8d54480 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -199,6 +199,20 @@ def create_mock_trades(fee): ) Trade.session.add(trade) + trade = Trade( + pair='XRP/BTC', + stake_amount=0.001, + amount=123.0, + fee_open=fee.return_value, + fee_close=fee.return_value, + open_rate=0.05, + close_rate=0.06, + close_profit=0.01, + exchange='bittrex', + is_open=False, + ) + Trade.session.add(trade) + # Simulate prod entry trade = Trade( pair='ETC/BTC', diff --git a/tests/data/test_btanalysis.py b/tests/data/test_btanalysis.py index b65db7fd8..718c02f05 100644 --- a/tests/data/test_btanalysis.py +++ b/tests/data/test_btanalysis.py @@ -43,7 +43,7 @@ def test_load_trades_from_db(default_conf, fee, mocker): trades = load_trades_from_db(db_url=default_conf['db_url']) assert init_mock.call_count == 1 - assert len(trades) == 3 + assert len(trades) == 4 assert isinstance(trades, DataFrame) assert "pair" in trades.columns assert "open_time" in trades.columns diff --git a/tests/test_freqtradebot.py b/tests/test_freqtradebot.py index ada0d87fd..54e33be4d 100644 --- a/tests/test_freqtradebot.py +++ b/tests/test_freqtradebot.py @@ -4090,7 +4090,7 @@ def test_cancel_all_open_orders(mocker, default_conf, fee, limit_buy_order, limi freqtrade = get_patched_freqtradebot(mocker, default_conf) create_mock_trades(fee) trades = Trade.query.all() - assert len(trades) == 3 + assert len(trades) == 4 freqtrade.cancel_all_open_orders() assert buy_mock.call_count == 1 assert sell_mock.call_count == 1 diff --git a/tests/test_persistence.py b/tests/test_persistence.py index 8dd27e53a..ab23243a5 100644 --- a/tests/test_persistence.py +++ b/tests/test_persistence.py @@ -989,7 +989,7 @@ def test_get_overall_performance(fee): create_mock_trades(fee) res = Trade.get_overall_performance() - assert len(res) == 1 + assert len(res) == 2 assert 'pair' in res[0] assert 'profit' in res[0] assert 'count' in res[0] @@ -1004,5 +1004,5 @@ def test_get_best_pair(fee): create_mock_trades(fee) res = Trade.get_best_pair() assert len(res) == 2 - assert res[0] == 'ETC/BTC' - assert res[1] == 0.005 + assert res[0] == 'XRP/BTC' + assert res[1] == 0.01