From a8fd7a69abde17c138a6cae1b944f505ae7e5d87 Mon Sep 17 00:00:00 2001 From: Gerald Lonlas Date: Mon, 5 Mar 2018 19:44:27 -0800 Subject: [PATCH] Increase Configuration._load_config_file() code coverage --- freqtrade/tests/test_configuration.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/freqtrade/tests/test_configuration.py b/freqtrade/tests/test_configuration.py index 195679bfa..4ca92c343 100644 --- a/freqtrade/tests/test_configuration.py +++ b/freqtrade/tests/test_configuration.py @@ -7,6 +7,7 @@ import json from copy import deepcopy import pytest +from unittest.mock import MagicMock from jsonschema import ValidationError from freqtrade.arguments import Arguments @@ -67,6 +68,24 @@ def test_load_config_file(default_conf, mocker, caplog) -> None: assert log_has('Validating configuration ...', caplog.record_tuples) +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(default_conf, mocker) -> None: """ Test Configuration.load_config() without any cli params