Add no-arg test

This commit is contained in:
Matthias 2019-11-12 13:33:37 +01:00
parent b36a1d3260
commit 65489c894d
3 changed files with 12 additions and 6 deletions

View File

@ -111,8 +111,7 @@ def start_new_strategy(args: Dict[str, Any]) -> None:
logger.info(f"Writing strategy to `{new_path}`.") logger.info(f"Writing strategy to `{new_path}`.")
new_path.write_text(strategy_text) new_path.write_text(strategy_text)
else: else:
logger.warning("`new-strategy` requires --strategy to be set.") raise OperationalException("`new-strategy` requires --strategy to be set.")
sys.exit(1)
def start_new_hyperopt(args: Dict[str, Any]) -> None: def start_new_hyperopt(args: Dict[str, Any]) -> None:
@ -135,8 +134,7 @@ def start_new_hyperopt(args: Dict[str, Any]) -> None:
logger.info(f"Writing hyperopt to `{new_path}`.") logger.info(f"Writing hyperopt to `{new_path}`.")
new_path.write_text(strategy_text) new_path.write_text(strategy_text)
else: else:
logger.warning("`new-hyperopt` requires --hyperopt to be set.") raise OperationalException("`new-hyperopt` requires --hyperopt to be set.")
sys.exit(1)
def start_download_data(args: Dict[str, Any]) -> None: def start_download_data(args: Dict[str, Any]) -> None:

View File

@ -469,7 +469,6 @@ def test_start_new_strategy(mocker, caplog):
assert log_has_re("Writing strategy to .*", caplog) assert log_has_re("Writing strategy to .*", caplog)
def test_start_new_strategy_DefaultStrat(mocker, caplog): def test_start_new_strategy_DefaultStrat(mocker, caplog):
args = [ args = [
"new-strategy", "new-strategy",
@ -481,6 +480,15 @@ def test_start_new_strategy_DefaultStrat(mocker, caplog):
start_new_strategy(get_args(args)) start_new_strategy(get_args(args))
def test_start_new_strategy_no_arg(mocker, caplog):
args = [
"new-strategy",
]
with pytest.raises(OperationalException,
match="`new-strategy` requires --strategy to be set."):
start_new_strategy(get_args(args))
def test_download_data_keyboardInterrupt(mocker, caplog, markets): def test_download_data_keyboardInterrupt(mocker, caplog, markets):
dl_mock = mocker.patch('freqtrade.utils.refresh_backtest_ohlcv_data', dl_mock = mocker.patch('freqtrade.utils.refresh_backtest_ohlcv_data',
MagicMock(side_effect=KeyboardInterrupt)) MagicMock(side_effect=KeyboardInterrupt))