Ejemplo n.º 1
0
def test_load_config_file_exception(mocker) -> None:
    mocker.patch('freqtrade.configuration.open',
                 MagicMock(side_effect=FileNotFoundError('File not found')))
    configuration = Configuration(Namespace())

    with pytest.raises(OperationalException,
                       match=r'.*Config file "somefile" not found!*'):
        configuration._load_config_file('somefile')
Ejemplo n.º 2
0
def test_load_config_file_exception(mocker, caplog) -> None:
    """
    Test Configuration._load_config_file() method
    """
    mocker.patch('freqtrade.configuration.open',
                 MagicMock(side_effect=FileNotFoundError('File not found')))
    configuration = Configuration([])

    with pytest.raises(SystemExit):
        configuration._load_config_file('somefile')
    assert log_has(
        'Config file "somefile" not found. Please create your config file',
        caplog.record_tuples)
def test_load_config_file(default_conf, mocker, caplog) -> None:
    file_mock = mocker.patch(
        'freqtrade.configuration.open',
        mocker.mock_open(read_data=json.dumps(default_conf)))

    configuration = Configuration(Namespace())
    validated_conf = configuration._load_config_file('somefile')
    assert file_mock.call_count == 1
    assert validated_conf.items() >= default_conf.items()
Ejemplo n.º 4
0
def test_load_config_file(default_conf, mocker, caplog) -> None:
    file_mock = mocker.patch(
        'freqtrade.configuration.open',
        mocker.mock_open(read_data=json.dumps(default_conf)))

    configuration = Configuration(Namespace())
    validated_conf = configuration._load_config_file('somefile')
    assert file_mock.call_count == 1
    assert validated_conf.items() >= default_conf.items()
    assert 'internals' in validated_conf
    assert log_has('Validating configuration ...', caplog.record_tuples)
    level=logging.INFO,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
)
set_loggers(0)

DEFAULT_DL_PATH = 'user_data/data'

arguments = arguments.Arguments(sys.argv[1:], 'download utility')
arguments.testdata_dl_options()
args = arguments.parse_args()

timeframes = args.timeframes

if args.config:
    configuration = Configuration(args)
    config = configuration._load_config_file(args.config)

    config['stake_currency'] = ''
    # Ensure we do not use Exchange credentials
    config['exchange']['key'] = ''
    config['exchange']['secret'] = ''
else:
    config = {
        'stake_currency': '',
        'dry_run': True,
        'exchange': {
            'name': args.exchange,
            'key': '',
            'secret': '',
            'pair_whitelist': [],
            'ccxt_async_config': {
args = arguments.parse_args(no_default_config=True)

# Use bittrex as default exchange
exchange_name = args.exchange or 'bittrex'

pairs: List = []

configuration = Configuration(args)
config: Dict[str, Any] = {}

if args.config:
    # Now expecting a list of config filenames here, not a string
    for path in args.config:
        logger.info(f"Using config: {path}...")
        # Merge config options, overwriting old values
        config = deep_merge_dicts(configuration._load_config_file(path),
                                  config)

    config['stake_currency'] = ''
    # Ensure we do not use Exchange credentials
    config['exchange']['dry_run'] = True
    config['exchange']['key'] = ''
    config['exchange']['secret'] = ''

    pairs = config['exchange']['pair_whitelist']

    if config.get('ticker_interval'):
        timeframes = args.timeframes or [config.get('ticker_interval')]
    else:
        timeframes = args.timeframes or ['1m', '5m']
Ejemplo n.º 7
0
def all_conf():
    config_file = Path(__file__).parents[2] / "config_full.json.example"
    print(config_file)
    configuration = Configuration(Namespace())
    conf = configuration._load_config_file(str(config_file))
    return conf