Fix most tests to have trade as default argument
This commit is contained in:
parent
db3b974479
commit
e8106f3792
@ -25,27 +25,27 @@ def test_parse_args_defaults() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def test_parse_args_config() -> None:
|
def test_parse_args_config() -> None:
|
||||||
args = Arguments(['-c', '/dev/null']).get_parsed_arg()
|
args = Arguments(['trade', '-c', '/dev/null']).get_parsed_arg()
|
||||||
assert args["config"] == ['/dev/null']
|
assert args["config"] == ['/dev/null']
|
||||||
|
|
||||||
args = Arguments(['--config', '/dev/null']).get_parsed_arg()
|
args = Arguments(['trade', '--config', '/dev/null']).get_parsed_arg()
|
||||||
assert args["config"] == ['/dev/null']
|
assert args["config"] == ['/dev/null']
|
||||||
|
|
||||||
args = Arguments(['--config', '/dev/null',
|
args = Arguments(['trade', '--config', '/dev/null',
|
||||||
'--config', '/dev/zero'],).get_parsed_arg()
|
'--config', '/dev/zero'],).get_parsed_arg()
|
||||||
assert args["config"] == ['/dev/null', '/dev/zero']
|
assert args["config"] == ['/dev/null', '/dev/zero']
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_db_url() -> None:
|
def test_parse_args_db_url() -> None:
|
||||||
args = Arguments(['--db-url', 'sqlite:///test.sqlite']).get_parsed_arg()
|
args = Arguments(['trade', '--db-url', 'sqlite:///test.sqlite']).get_parsed_arg()
|
||||||
assert args["db_url"] == 'sqlite:///test.sqlite'
|
assert args["db_url"] == 'sqlite:///test.sqlite'
|
||||||
|
|
||||||
|
|
||||||
def test_parse_args_verbose() -> None:
|
def test_parse_args_verbose() -> None:
|
||||||
args = Arguments(['-v']).get_parsed_arg()
|
args = Arguments(['trade', '-v']).get_parsed_arg()
|
||||||
assert args["verbosity"] == 1
|
assert args["verbosity"] == 1
|
||||||
|
|
||||||
args = Arguments(['--verbose']).get_parsed_arg()
|
args = Arguments(['trade', '--verbose']).get_parsed_arg()
|
||||||
assert args["verbosity"] == 1
|
assert args["verbosity"] == 1
|
||||||
|
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ def test_parse_args_invalid() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def test_parse_args_strategy() -> None:
|
def test_parse_args_strategy() -> None:
|
||||||
args = Arguments(['--strategy', 'SomeStrategy']).get_parsed_arg()
|
args = Arguments(['trade', '--strategy', 'SomeStrategy']).get_parsed_arg()
|
||||||
assert args["strategy"] == 'SomeStrategy'
|
assert args["strategy"] == 'SomeStrategy'
|
||||||
|
|
||||||
|
|
||||||
@ -77,7 +77,7 @@ def test_parse_args_strategy_invalid() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def test_parse_args_strategy_path() -> None:
|
def test_parse_args_strategy_path() -> None:
|
||||||
args = Arguments(['--strategy-path', '/some/path']).get_parsed_arg()
|
args = Arguments(['trade', '--strategy-path', '/some/path']).get_parsed_arg()
|
||||||
assert args["strategy_path"] == '/some/path'
|
assert args["strategy_path"] == '/some/path'
|
||||||
|
|
||||||
|
|
||||||
@ -96,8 +96,8 @@ def test_parse_args_backtesting_invalid() -> None:
|
|||||||
|
|
||||||
def test_parse_args_backtesting_custom() -> None:
|
def test_parse_args_backtesting_custom() -> None:
|
||||||
args = [
|
args = [
|
||||||
'-c', 'test_conf.json',
|
|
||||||
'backtesting',
|
'backtesting',
|
||||||
|
'-c', 'test_conf.json',
|
||||||
'--ticker-interval', '1m',
|
'--ticker-interval', '1m',
|
||||||
'--strategy-list',
|
'--strategy-list',
|
||||||
'DefaultStrategy',
|
'DefaultStrategy',
|
||||||
@ -115,8 +115,8 @@ def test_parse_args_backtesting_custom() -> None:
|
|||||||
|
|
||||||
def test_parse_args_hyperopt_custom() -> None:
|
def test_parse_args_hyperopt_custom() -> None:
|
||||||
args = [
|
args = [
|
||||||
'-c', 'test_conf.json',
|
|
||||||
'hyperopt',
|
'hyperopt',
|
||||||
|
'-c', 'test_conf.json',
|
||||||
'--epochs', '20',
|
'--epochs', '20',
|
||||||
'--spaces', 'buy'
|
'--spaces', 'buy'
|
||||||
]
|
]
|
||||||
@ -132,8 +132,8 @@ def test_parse_args_hyperopt_custom() -> None:
|
|||||||
|
|
||||||
def test_download_data_options() -> None:
|
def test_download_data_options() -> None:
|
||||||
args = [
|
args = [
|
||||||
'--datadir', 'datadir/directory',
|
|
||||||
'download-data',
|
'download-data',
|
||||||
|
'--datadir', 'datadir/directory',
|
||||||
'--pairs-file', 'file_with_pairs',
|
'--pairs-file', 'file_with_pairs',
|
||||||
'--days', '30',
|
'--days', '30',
|
||||||
'--exchange', 'binance'
|
'--exchange', 'binance'
|
||||||
|
@ -65,7 +65,7 @@ def test_load_config_file(default_conf, mocker, caplog) -> None:
|
|||||||
|
|
||||||
def test__args_to_config(caplog):
|
def test__args_to_config(caplog):
|
||||||
|
|
||||||
arg_list = ['--strategy-path', 'TestTest']
|
arg_list = ['trade', '--strategy-path', 'TestTest']
|
||||||
args = Arguments(arg_list).get_parsed_arg()
|
args = Arguments(arg_list).get_parsed_arg()
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
config = {}
|
config = {}
|
||||||
@ -93,7 +93,7 @@ def test_load_config_max_open_trades_zero(default_conf, mocker, caplog) -> None:
|
|||||||
default_conf['max_open_trades'] = 0
|
default_conf['max_open_trades'] = 0
|
||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
args = Arguments([]).get_parsed_arg()
|
args = Arguments(['trade']).get_parsed_arg()
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
validated_conf = configuration.load_config()
|
validated_conf = configuration.load_config()
|
||||||
|
|
||||||
@ -118,7 +118,7 @@ def test_load_config_combine_dicts(default_conf, mocker, caplog) -> None:
|
|||||||
configsmock
|
configsmock
|
||||||
)
|
)
|
||||||
|
|
||||||
arg_list = ['-c', 'test_conf.json', '--config', 'test2_conf.json', ]
|
arg_list = ['trade', '-c', 'test_conf.json', '--config', 'test2_conf.json', ]
|
||||||
args = Arguments(arg_list).get_parsed_arg()
|
args = Arguments(arg_list).get_parsed_arg()
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
validated_conf = configuration.load_config()
|
validated_conf = configuration.load_config()
|
||||||
@ -184,7 +184,7 @@ def test_load_config_max_open_trades_minus_one(default_conf, mocker, caplog) ->
|
|||||||
default_conf['max_open_trades'] = -1
|
default_conf['max_open_trades'] = -1
|
||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
args = Arguments([]).get_parsed_arg()
|
args = Arguments(['trade']).get_parsed_arg()
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
validated_conf = configuration.load_config()
|
validated_conf = configuration.load_config()
|
||||||
|
|
||||||
@ -208,7 +208,7 @@ def test_load_config_file_exception(mocker) -> None:
|
|||||||
def test_load_config(default_conf, mocker) -> None:
|
def test_load_config(default_conf, mocker) -> None:
|
||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
args = Arguments([]).get_parsed_arg()
|
args = Arguments(['trade']).get_parsed_arg()
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
validated_conf = configuration.load_config()
|
validated_conf = configuration.load_config()
|
||||||
|
|
||||||
@ -221,6 +221,7 @@ def test_load_config_with_params(default_conf, mocker) -> None:
|
|||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
|
'trade',
|
||||||
'--strategy', 'TestStrategy',
|
'--strategy', 'TestStrategy',
|
||||||
'--strategy-path', '/some/path',
|
'--strategy-path', '/some/path',
|
||||||
'--db-url', 'sqlite:///someurl',
|
'--db-url', 'sqlite:///someurl',
|
||||||
@ -240,6 +241,7 @@ def test_load_config_with_params(default_conf, mocker) -> None:
|
|||||||
patched_configuration_load_config_file(mocker, conf)
|
patched_configuration_load_config_file(mocker, conf)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
|
'trade',
|
||||||
'--strategy', 'TestStrategy',
|
'--strategy', 'TestStrategy',
|
||||||
'--strategy-path', '/some/path'
|
'--strategy-path', '/some/path'
|
||||||
]
|
]
|
||||||
@ -256,6 +258,7 @@ def test_load_config_with_params(default_conf, mocker) -> None:
|
|||||||
patched_configuration_load_config_file(mocker, conf)
|
patched_configuration_load_config_file(mocker, conf)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
|
'trade',
|
||||||
'--strategy', 'TestStrategy',
|
'--strategy', 'TestStrategy',
|
||||||
'--strategy-path', '/some/path'
|
'--strategy-path', '/some/path'
|
||||||
]
|
]
|
||||||
@ -272,6 +275,7 @@ def test_load_config_with_params(default_conf, mocker) -> None:
|
|||||||
patched_configuration_load_config_file(mocker, conf)
|
patched_configuration_load_config_file(mocker, conf)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
|
'trade',
|
||||||
'--strategy', 'TestStrategy',
|
'--strategy', 'TestStrategy',
|
||||||
'--strategy-path', '/some/path'
|
'--strategy-path', '/some/path'
|
||||||
]
|
]
|
||||||
@ -290,6 +294,7 @@ def test_load_config_with_params(default_conf, mocker) -> None:
|
|||||||
patched_configuration_load_config_file(mocker, conf)
|
patched_configuration_load_config_file(mocker, conf)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
|
'trade',
|
||||||
'--strategy', 'TestStrategy',
|
'--strategy', 'TestStrategy',
|
||||||
'--strategy-path', '/some/path'
|
'--strategy-path', '/some/path'
|
||||||
]
|
]
|
||||||
@ -307,7 +312,7 @@ def test_load_custom_strategy(default_conf, mocker) -> None:
|
|||||||
})
|
})
|
||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
args = Arguments([]).get_parsed_arg()
|
args = Arguments(['trade']).get_parsed_arg()
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
validated_conf = configuration.load_config()
|
validated_conf = configuration.load_config()
|
||||||
|
|
||||||
@ -319,6 +324,7 @@ def test_show_info(default_conf, mocker, caplog) -> None:
|
|||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
|
'trade',
|
||||||
'--strategy', 'TestStrategy',
|
'--strategy', 'TestStrategy',
|
||||||
'--db-url', 'sqlite:///tmp/testdb',
|
'--db-url', 'sqlite:///tmp/testdb',
|
||||||
]
|
]
|
||||||
@ -335,9 +341,9 @@ def test_setup_configuration_without_arguments(mocker, default_conf, caplog) ->
|
|||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
|
'backtesting',
|
||||||
'--config', 'config.json',
|
'--config', 'config.json',
|
||||||
'--strategy', 'DefaultStrategy',
|
'--strategy', 'DefaultStrategy',
|
||||||
'backtesting'
|
|
||||||
]
|
]
|
||||||
|
|
||||||
args = Arguments(arglist).get_parsed_arg()
|
args = Arguments(arglist).get_parsed_arg()
|
||||||
@ -373,11 +379,11 @@ def test_setup_configuration_with_arguments(mocker, default_conf, caplog) -> Non
|
|||||||
lambda x, *args, **kwargs: Path(x)
|
lambda x, *args, **kwargs: Path(x)
|
||||||
)
|
)
|
||||||
arglist = [
|
arglist = [
|
||||||
|
'backtesting',
|
||||||
'--config', 'config.json',
|
'--config', 'config.json',
|
||||||
'--strategy', 'DefaultStrategy',
|
'--strategy', 'DefaultStrategy',
|
||||||
'--datadir', '/foo/bar',
|
'--datadir', '/foo/bar',
|
||||||
'--userdir', "/tmp/freqtrade",
|
'--userdir', "/tmp/freqtrade",
|
||||||
'backtesting',
|
|
||||||
'--ticker-interval', '1m',
|
'--ticker-interval', '1m',
|
||||||
'--enable-position-stacking',
|
'--enable-position-stacking',
|
||||||
'--disable-max-market-positions',
|
'--disable-max-market-positions',
|
||||||
@ -424,8 +430,8 @@ def test_setup_configuration_with_stratlist(mocker, default_conf, caplog) -> Non
|
|||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
'--config', 'config.json',
|
|
||||||
'backtesting',
|
'backtesting',
|
||||||
|
'--config', 'config.json',
|
||||||
'--ticker-interval', '1m',
|
'--ticker-interval', '1m',
|
||||||
'--export', '/bar/foo',
|
'--export', '/bar/foo',
|
||||||
'--strategy-list',
|
'--strategy-list',
|
||||||
@ -552,7 +558,7 @@ def test_cli_verbose_with_params(default_conf, mocker, caplog) -> None:
|
|||||||
|
|
||||||
# Prevent setting loggers
|
# Prevent setting loggers
|
||||||
mocker.patch('freqtrade.loggers._set_loggers', MagicMock)
|
mocker.patch('freqtrade.loggers._set_loggers', MagicMock)
|
||||||
arglist = ['-vvv']
|
arglist = ['trade', '-vvv']
|
||||||
args = Arguments(arglist).get_parsed_arg()
|
args = Arguments(arglist).get_parsed_arg()
|
||||||
|
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
@ -604,7 +610,7 @@ def test_set_logfile(default_conf, mocker):
|
|||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
arglist = [
|
arglist = [
|
||||||
'--logfile', 'test_file.log',
|
'trade', '--logfile', 'test_file.log',
|
||||||
]
|
]
|
||||||
args = Arguments(arglist).get_parsed_arg()
|
args = Arguments(arglist).get_parsed_arg()
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
@ -620,7 +626,7 @@ def test_load_config_warn_forcebuy(default_conf, mocker, caplog) -> None:
|
|||||||
default_conf['forcebuy_enable'] = True
|
default_conf['forcebuy_enable'] = True
|
||||||
patched_configuration_load_config_file(mocker, default_conf)
|
patched_configuration_load_config_file(mocker, default_conf)
|
||||||
|
|
||||||
args = Arguments([]).get_parsed_arg()
|
args = Arguments(['trade']).get_parsed_arg()
|
||||||
configuration = Configuration(args)
|
configuration = Configuration(args)
|
||||||
validated_conf = configuration.load_config()
|
validated_conf = configuration.load_config()
|
||||||
|
|
||||||
|
@ -281,8 +281,8 @@ def test_generate_profit_graph(testdatadir):
|
|||||||
def test_start_plot_dataframe(mocker):
|
def test_start_plot_dataframe(mocker):
|
||||||
aup = mocker.patch("freqtrade.plot.plotting.load_and_plot_trades", MagicMock())
|
aup = mocker.patch("freqtrade.plot.plotting.load_and_plot_trades", MagicMock())
|
||||||
args = [
|
args = [
|
||||||
"--config", "config.json.example",
|
|
||||||
"plot-dataframe",
|
"plot-dataframe",
|
||||||
|
"--config", "config.json.example",
|
||||||
"--pairs", "ETH/BTC"
|
"--pairs", "ETH/BTC"
|
||||||
]
|
]
|
||||||
start_plot_dataframe(get_args(args))
|
start_plot_dataframe(get_args(args))
|
||||||
@ -323,8 +323,8 @@ def test_load_and_plot_trades(default_conf, mocker, caplog, testdatadir):
|
|||||||
def test_start_plot_profit(mocker):
|
def test_start_plot_profit(mocker):
|
||||||
aup = mocker.patch("freqtrade.plot.plotting.plot_profit", MagicMock())
|
aup = mocker.patch("freqtrade.plot.plotting.plot_profit", MagicMock())
|
||||||
args = [
|
args = [
|
||||||
"--config", "config.json.example",
|
|
||||||
"plot-profit",
|
"plot-profit",
|
||||||
|
"--config", "config.json.example",
|
||||||
"--pairs", "ETH/BTC"
|
"--pairs", "ETH/BTC"
|
||||||
]
|
]
|
||||||
start_plot_profit(get_args(args))
|
start_plot_profit(get_args(args))
|
||||||
|
Loading…
Reference in New Issue
Block a user