From 972736f0abd34945b4505a351aece6e4436c82a2 Mon Sep 17 00:00:00 2001 From: xmatthias Date: Sat, 16 Jun 2018 20:55:35 +0200 Subject: [PATCH 1/3] increase test-coverate for configureation --- freqtrade/tests/test_configuration.py | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/freqtrade/tests/test_configuration.py b/freqtrade/tests/test_configuration.py index 212df2e96..019c0c09d 100644 --- a/freqtrade/tests/test_configuration.py +++ b/freqtrade/tests/test_configuration.py @@ -13,6 +13,7 @@ from jsonschema import ValidationError from freqtrade.arguments import Arguments from freqtrade.configuration import Configuration +from freqtrade.constants import DEFAULT_DB_PROD_URL, DEFAULT_DB_DRYRUN_URL from freqtrade.tests.conftest import log_has from freqtrade import OperationalException @@ -140,6 +141,43 @@ def test_load_config_with_params(default_conf, mocker) -> None: assert validated_conf.get('strategy_path') == '/some/path' assert validated_conf.get('db_url') == 'sqlite:///someurl' + conf = default_conf.copy() + conf["dry_run"] = False + del conf["db_url"] + mocker.patch('freqtrade.configuration.open', mocker.mock_open( + read_data=json.dumps(conf) + )) + + arglist = [ + '--dynamic-whitelist', '10', + '--strategy', 'TestStrategy', + '--strategy-path', '/some/path' + ] + args = Arguments(arglist, '').get_parsed_arg() + + configuration = Configuration(args) + validated_conf = configuration.load_config() + assert validated_conf.get('db_url') == DEFAULT_DB_PROD_URL + + # Test dry=run with ProdURL + conf = default_conf.copy() + conf["dry_run"] = True + conf["db_url"] = DEFAULT_DB_PROD_URL + mocker.patch('freqtrade.configuration.open', mocker.mock_open( + read_data=json.dumps(conf) + )) + + arglist = [ + '--dynamic-whitelist', '10', + '--strategy', 'TestStrategy', + '--strategy-path', '/some/path' + ] + args = Arguments(arglist, '').get_parsed_arg() + + configuration = Configuration(args) + validated_conf = configuration.load_config() + assert validated_conf.get('db_url') == DEFAULT_DB_DRYRUN_URL + def test_load_custom_strategy(default_conf, mocker) -> None: """ From 7cfd99d17f574de139ccd11e5cdd3b2a5b4ca124 Mon Sep 17 00:00:00 2001 From: xmatthias Date: Sat, 16 Jun 2018 21:00:45 +0200 Subject: [PATCH 2/3] exclude __main__.py from coveralls - if __name__ == '__main__' is close to untestable - and should do nothing other than calling another function. --- .coveragerc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index 95eea4f8f..80ed2af23 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,4 +2,5 @@ omit = scripts/* freqtrade/tests/* - freqtrade/vendor/* \ No newline at end of file + freqtrade/vendor/* + freatrade/__main__.py From 90a7fb603d50e52aced0cfaf1ed6221c469a8e10 Mon Sep 17 00:00:00 2001 From: xmatthias Date: Sat, 16 Jun 2018 21:28:41 +0200 Subject: [PATCH 3/3] fix typo in coverage-omit --- .coveragerc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index 80ed2af23..4bd5b63fa 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,4 +3,4 @@ omit = scripts/* freqtrade/tests/* freqtrade/vendor/* - freatrade/__main__.py + freqtrade/__main__.py