Fix test_dataframe when ran standalone (#546)
* Fix dataframe test when ran standalone * Fix standalone tests in hyperopt and optimize tests
This commit is contained in:
parent
480d3876b8
commit
e907c48438
@ -7,7 +7,7 @@ import pandas as pd
|
||||
|
||||
from freqtrade.optimize.hyperopt import calculate_loss, TARGET_TRADES, EXPECTED_MAX_PROFIT, start, \
|
||||
log_results, save_trials, read_trials, generate_roi_table, has_space
|
||||
|
||||
from freqtrade.strategy.strategy import Strategy
|
||||
import freqtrade.optimize.hyperopt as hyperopt
|
||||
|
||||
|
||||
@ -72,6 +72,7 @@ def test_start_calls_fmin(mocker):
|
||||
|
||||
args = mocker.Mock(epochs=1, config='config.json.example', mongodb=False,
|
||||
timerange=None, spaces='all')
|
||||
Strategy().init({'strategy': 'default_strategy'})
|
||||
start(args)
|
||||
|
||||
mock_fmin.assert_called_once()
|
||||
@ -86,6 +87,7 @@ def test_start_uses_mongotrials(mocker):
|
||||
|
||||
args = mocker.Mock(epochs=1, config='config.json.example', mongodb=True,
|
||||
timerange=None, spaces='all')
|
||||
Strategy().init({'strategy': 'default_strategy'})
|
||||
start(args)
|
||||
|
||||
mock_mongotrials.assert_called_once()
|
||||
@ -149,6 +151,7 @@ def test_fmin_best_results(mocker, caplog):
|
||||
|
||||
args = mocker.Mock(epochs=1, config='config.json.example',
|
||||
timerange=None, spaces='all')
|
||||
Strategy().init({'strategy': 'default_strategy'})
|
||||
start(args)
|
||||
|
||||
exists = [
|
||||
@ -166,6 +169,7 @@ def test_fmin_best_results(mocker, caplog):
|
||||
|
||||
def test_fmin_throw_value_error(mocker, caplog):
|
||||
caplog.set_level(logging.INFO)
|
||||
Strategy().init({'strategy': 'default_strategy'})
|
||||
mocker.patch('freqtrade.optimize.hyperopt.MongoTrials', return_value=create_trials(mocker))
|
||||
mocker.patch('freqtrade.optimize.tickerdata_to_dataframe')
|
||||
mocker.patch('freqtrade.optimize.load_data')
|
||||
@ -173,6 +177,7 @@ def test_fmin_throw_value_error(mocker, caplog):
|
||||
|
||||
args = mocker.Mock(epochs=1, config='config.json.example',
|
||||
timerange=None, spaces='all')
|
||||
Strategy().init({'strategy': 'default_strategy'})
|
||||
start(args)
|
||||
|
||||
exists = [
|
||||
@ -209,7 +214,7 @@ def test_resuming_previous_hyperopt_results_succeeds(mocker):
|
||||
mongodb=False,
|
||||
timerange=None,
|
||||
spaces='all')
|
||||
|
||||
Strategy().init({'strategy': 'default_strategy'})
|
||||
start(args)
|
||||
|
||||
mock_read.assert_called_once()
|
||||
|
@ -10,6 +10,7 @@ from freqtrade.exchange import Bittrex
|
||||
from freqtrade.optimize.__init__ import make_testdata_path, download_pairs,\
|
||||
download_backtesting_testdata, load_tickerdata_file, trim_tickerlist, file_dump_json
|
||||
from freqtrade.tests.conftest import log_has
|
||||
from freqtrade.strategy.strategy import Strategy
|
||||
|
||||
# Change this if modifying BTC_UNITEST testdatafile
|
||||
_BTC_UNITTEST_LENGTH = 13681
|
||||
@ -218,6 +219,7 @@ def test_init(default_conf, mocker):
|
||||
|
||||
|
||||
def test_tickerdata_to_dataframe():
|
||||
Strategy().init({'strategy': 'default_strategy'})
|
||||
timerange = ((None, 'line'), None, -100)
|
||||
tick = load_tickerdata_file(None, 'BTC_UNITEST', 1, timerange=timerange)
|
||||
tickerlist = {'BTC_UNITEST': tick}
|
||||
|
@ -3,6 +3,7 @@
|
||||
import pandas
|
||||
import freqtrade.optimize
|
||||
from freqtrade import analyze
|
||||
from freqtrade.strategy.strategy import Strategy
|
||||
|
||||
_pairs = ['BTC_ETH']
|
||||
|
||||
@ -17,11 +18,13 @@ def load_dataframe_pair(pairs):
|
||||
|
||||
|
||||
def test_dataframe_load():
|
||||
Strategy().init({'strategy': 'default_strategy'})
|
||||
dataframe = load_dataframe_pair(_pairs)
|
||||
assert isinstance(dataframe, pandas.core.frame.DataFrame)
|
||||
|
||||
|
||||
def test_dataframe_columns_exists():
|
||||
Strategy().init({'strategy': 'default_strategy'})
|
||||
dataframe = load_dataframe_pair(_pairs)
|
||||
assert 'high' in dataframe.columns
|
||||
assert 'low' in dataframe.columns
|
||||
|
Loading…
Reference in New Issue
Block a user