Increase Configuration._load_config_file() code coverage

This commit is contained in:
Gerald Lonlas 2018-03-05 19:44:27 -08:00
parent ea7b25766b
commit a8fd7a69ab

View File

@ -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