Add simple test for recursive loading
This commit is contained in:
parent
1ea49ce864
commit
3427df0653
@ -182,6 +182,7 @@
|
||||
"disable_dataframe_checks": false,
|
||||
"strategy": "SampleStrategy",
|
||||
"strategy_path": "user_data/strategies/",
|
||||
"files": [],
|
||||
"dataformat_ohlcv": "json",
|
||||
"dataformat_trades": "jsongz"
|
||||
}
|
||||
|
@ -91,15 +91,14 @@ SUPPORTED_FIAT = [
|
||||
]
|
||||
|
||||
MINIMAL_CONFIG = {
|
||||
'stake_currency': '',
|
||||
'dry_run': True,
|
||||
'exchange': {
|
||||
'name': '',
|
||||
'key': '',
|
||||
'secret': '',
|
||||
'pair_whitelist': [],
|
||||
'ccxt_async_config': {
|
||||
'enableRateLimit': True,
|
||||
"stake_currency": "",
|
||||
"dry_run": True,
|
||||
"exchange": {
|
||||
"name": "",
|
||||
"key": "",
|
||||
"secret": "",
|
||||
"pair_whitelist": [],
|
||||
"ccxt_async_config": {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,8 @@ from freqtrade.configuration.deprecated_settings import (check_conflicting_setti
|
||||
process_removed_setting,
|
||||
process_temporary_deprecated_settings)
|
||||
from freqtrade.configuration.environment_vars import flat_vars_to_nested_dict
|
||||
from freqtrade.configuration.load_config import load_config_file, load_file, log_config_error_range
|
||||
from freqtrade.configuration.load_config import (load_config_file, load_file, load_from_files,
|
||||
log_config_error_range)
|
||||
from freqtrade.constants import DEFAULT_DB_DRYRUN_URL, DEFAULT_DB_PROD_URL, ENV_VAR_PREFIX
|
||||
from freqtrade.enums import RunMode
|
||||
from freqtrade.exceptions import OperationalException
|
||||
@ -206,6 +207,26 @@ def test_from_config(default_conf, mocker, caplog) -> None:
|
||||
assert isinstance(validated_conf['user_data_dir'], Path)
|
||||
|
||||
|
||||
def test_from_recursive_files(testdatadir) -> None:
|
||||
files = testdatadir / "testconfigs/testconfig.json"
|
||||
|
||||
conf = Configuration.from_files([files])
|
||||
|
||||
assert conf
|
||||
# Exchange comes from "the first config"
|
||||
assert conf['exchange']
|
||||
# Pricing comes from the 2nd config
|
||||
assert conf['entry_pricing']
|
||||
assert conf['entry_pricing']['price_side'] == "same"
|
||||
assert conf['exit_pricing']
|
||||
# The other key comes from pricing2, which is imported by pricing.json
|
||||
assert conf['exit_pricing']['price_side'] == "other"
|
||||
|
||||
files = testdatadir / "testconfigs/recursive.json"
|
||||
with pytest.raises(OperationalException, match="Config loop detected."):
|
||||
load_from_files([files])
|
||||
|
||||
|
||||
def test_print_config(default_conf, mocker, caplog) -> None:
|
||||
conf1 = deepcopy(default_conf)
|
||||
# Delete non-json elements from default_conf
|
||||
|
12
tests/testdata/testconfigs/base_config.json
vendored
Normal file
12
tests/testdata/testconfigs/base_config.json
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"stake_currency": "",
|
||||
"dry_run": true,
|
||||
"exchange": {
|
||||
"name": "",
|
||||
"key": "",
|
||||
"secret": "",
|
||||
"pair_whitelist": [],
|
||||
"ccxt_async_config": {
|
||||
}
|
||||
}
|
||||
}
|
21
tests/testdata/testconfigs/pricing.json
vendored
Normal file
21
tests/testdata/testconfigs/pricing.json
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"entry_pricing": {
|
||||
"price_side": "same",
|
||||
"use_order_book": true,
|
||||
"order_book_top": 1,
|
||||
"price_last_balance": 0.0,
|
||||
"check_depth_of_market": {
|
||||
"enabled": false,
|
||||
"bids_to_ask_delta": 1
|
||||
}
|
||||
},
|
||||
"exit_pricing":{
|
||||
"price_side": "same",
|
||||
"use_order_book": true,
|
||||
"order_book_top": 1,
|
||||
"price_last_balance": 0.0
|
||||
},
|
||||
"files": [
|
||||
"pricing2.json"
|
||||
]
|
||||
}
|
18
tests/testdata/testconfigs/pricing2.json
vendored
Normal file
18
tests/testdata/testconfigs/pricing2.json
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
{
|
||||
"entry_pricing": {
|
||||
"price_side": "same",
|
||||
"use_order_book": true,
|
||||
"order_book_top": 1,
|
||||
"price_last_balance": 0.0,
|
||||
"check_depth_of_market": {
|
||||
"enabled": false,
|
||||
"bids_to_ask_delta": 1
|
||||
}
|
||||
},
|
||||
"exit_pricing":{
|
||||
"price_side": "other",
|
||||
"use_order_book": true,
|
||||
"order_book_top": 1,
|
||||
"price_last_balance": 0.0
|
||||
}
|
||||
}
|
6
tests/testdata/testconfigs/recursive.json
vendored
Normal file
6
tests/testdata/testconfigs/recursive.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
// This file fails as it's loading itself over and over
|
||||
"files": [
|
||||
"./recursive.json"
|
||||
]
|
||||
}
|
6
tests/testdata/testconfigs/testconfig.json
vendored
Normal file
6
tests/testdata/testconfigs/testconfig.json
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"files": [
|
||||
"base_config.json",
|
||||
"pricing.json"
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user