From e5008fbf9347d5d8234a70afc2f65c1049b695ab Mon Sep 17 00:00:00 2001 From: Matthias Date: Fri, 29 Mar 2019 20:16:52 +0100 Subject: [PATCH] Add test for logfile attribute --- freqtrade/tests/test_configuration.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/freqtrade/tests/test_configuration.py b/freqtrade/tests/test_configuration.py index 21547d205..45e539c2f 100644 --- a/freqtrade/tests/test_configuration.py +++ b/freqtrade/tests/test_configuration.py @@ -5,6 +5,7 @@ import logging from argparse import Namespace from copy import deepcopy from unittest.mock import MagicMock +from pathlib import Path import pytest from jsonschema import Draft4Validator, ValidationError, validate @@ -547,6 +548,23 @@ def test_set_loggers() -> None: assert logging.getLogger('telegram').level is logging.INFO +def test_set_logfile(default_conf, mocker): + mocker.patch('freqtrade.configuration.open', + mocker.mock_open(read_data=json.dumps(default_conf))) + + arglist = [ + '--logfile', 'test_file.log', + ] + args = Arguments(arglist, '').get_parsed_arg() + configuration = Configuration(args) + validated_conf = configuration.load_config() + + assert validated_conf['logfile'] == "test_file.log" + f = Path("test_file.log") + assert f.is_file() + f.unlink() + + def test_load_config_warn_forcebuy(default_conf, mocker, caplog) -> None: default_conf['forcebuy_enable'] = True mocker.patch('freqtrade.configuration.open', mocker.mock_open(