move backtesting to freqtrade.optimize.backtesting
This commit is contained in:
@@ -1,15 +1,13 @@
|
||||
# pragma pylint: disable=missing-docstring,C0103
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
from argparse import Namespace
|
||||
from copy import deepcopy
|
||||
from unittest.mock import MagicMock
|
||||
|
||||
import pytest
|
||||
from jsonschema import ValidationError
|
||||
|
||||
from freqtrade.misc import throttle, parse_args, start_backtesting, load_config
|
||||
from freqtrade.misc import throttle, parse_args, load_config
|
||||
|
||||
|
||||
def test_throttle():
|
||||
@@ -64,7 +62,7 @@ def test_parse_args_dynamic_whitelist():
|
||||
|
||||
|
||||
def test_parse_args_backtesting(mocker):
|
||||
backtesting_mock = mocker.patch('freqtrade.misc.start_backtesting', MagicMock())
|
||||
backtesting_mock = mocker.patch('freqtrade.optimize.backtesting.start', MagicMock())
|
||||
args = parse_args(['backtesting'])
|
||||
assert args is None
|
||||
assert backtesting_mock.call_count == 1
|
||||
@@ -87,7 +85,7 @@ def test_parse_args_backtesting_invalid():
|
||||
|
||||
|
||||
def test_parse_args_backtesting_custom(mocker):
|
||||
backtesting_mock = mocker.patch('freqtrade.misc.start_backtesting', MagicMock())
|
||||
backtesting_mock = mocker.patch('freqtrade.optimize.backtesting.start', MagicMock())
|
||||
args = parse_args(['-c', 'test_conf.json', 'backtesting', '--live', '--ticker-interval', '1'])
|
||||
assert args is None
|
||||
assert backtesting_mock.call_count == 1
|
||||
@@ -101,31 +99,6 @@ def test_parse_args_backtesting_custom(mocker):
|
||||
assert call_args.ticker_interval == 1
|
||||
|
||||
|
||||
def test_start_backtesting(mocker):
|
||||
pytest_mock = mocker.patch('pytest.main', MagicMock())
|
||||
env_mock = mocker.patch('os.environ', {})
|
||||
args = Namespace(
|
||||
config='config.json',
|
||||
live=True,
|
||||
loglevel=20,
|
||||
ticker_interval=1,
|
||||
realistic_simulation=True,
|
||||
)
|
||||
start_backtesting(args)
|
||||
assert env_mock == {
|
||||
'BACKTEST': 'true',
|
||||
'BACKTEST_LIVE': 'true',
|
||||
'BACKTEST_CONFIG': 'config.json',
|
||||
'BACKTEST_TICKER_INTERVAL': '1',
|
||||
'BACKTEST_REALISTIC_SIMULATION': 'true',
|
||||
}
|
||||
assert pytest_mock.call_count == 1
|
||||
|
||||
main_call_args = pytest_mock.call_args[0][0]
|
||||
assert main_call_args[0] == '-s'
|
||||
assert main_call_args[1].endswith(os.path.join('freqtrade', 'tests', 'test_backtesting.py'))
|
||||
|
||||
|
||||
def test_load_config(default_conf, mocker):
|
||||
file_mock = mocker.patch('freqtrade.misc.open', mocker.mock_open(
|
||||
read_data=json.dumps(default_conf)
|
||||
|
||||
Reference in New Issue
Block a user