From 573502d97226bdaea5ebb1d8eb92cdb078ad748d Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 27 Jun 2020 09:59:23 +0200 Subject: [PATCH] Update test for load_trades_from_db --- tests/conftest.py | 9 ++++++--- tests/data/test_btanalysis.py | 9 +++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index f2143e60e..62810bd6e 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -180,7 +180,8 @@ def create_mock_trades(fee): fee_close=fee.return_value, open_rate=0.123, exchange='bittrex', - open_order_id='dry_run_buy_12345' + open_order_id='dry_run_buy_12345', + strategy='DefaultStrategy', ) Trade.session.add(trade) @@ -195,7 +196,8 @@ def create_mock_trades(fee): close_profit=0.005, exchange='bittrex', is_open=False, - open_order_id='dry_run_sell_12345' + open_order_id='dry_run_sell_12345', + strategy='DefaultStrategy', ) Trade.session.add(trade) @@ -208,7 +210,8 @@ def create_mock_trades(fee): fee_close=fee.return_value, open_rate=0.123, exchange='bittrex', - open_order_id='prod_buy_12345' + open_order_id='prod_buy_12345', + strategy='DefaultStrategy', ) Trade.session.add(trade) diff --git a/tests/data/test_btanalysis.py b/tests/data/test_btanalysis.py index fd3783bf2..32e476b6b 100644 --- a/tests/data/test_btanalysis.py +++ b/tests/data/test_btanalysis.py @@ -43,7 +43,7 @@ def test_load_backtest_data(testdatadir): filename = testdatadir / "backtest-result_test.json" bt_data = load_backtest_data(filename) assert isinstance(bt_data, DataFrame) - assert list(bt_data.columns) == BT_DATA_COLUMNS + ["profit"] + assert list(bt_data.columns) == BT_DATA_COLUMNS + ["profit_abs"] assert len(bt_data) == 179 # Test loading from string (must yield same result) @@ -72,6 +72,10 @@ def test_load_trades_from_db(default_conf, fee, mocker): for col in BT_DATA_COLUMNS: if col not in ['index', 'open_at_end']: assert col in trades.columns + trades = load_trades_from_db(db_url=default_conf['db_url'], strategy='DefaultStrategy') + assert len(trades) == 3 + trades = load_trades_from_db(db_url=default_conf['db_url'], strategy='NoneStrategy') + assert len(trades) == 0 def test_extract_trades_of_period(testdatadir): @@ -125,7 +129,8 @@ def test_load_trades(default_conf, mocker): load_trades("DB", db_url=default_conf.get('db_url'), exportfilename=default_conf.get('exportfilename'), - no_trades=False + no_trades=False, + strategy="DefaultStrategy", ) assert db_mock.call_count == 1