Ejemplo n.º 1
0
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))
Ejemplo n.º 2
0
def test_start_new_strategy_DefaultStrat(mocker, caplog):
    args = [
        "new-strategy",
        "--strategy",
        "DefaultStrategy"
    ]
    with pytest.raises(OperationalException,
                       match=r"DefaultStrategy is not allowed as name\."):
        start_new_strategy(get_args(args))
Ejemplo n.º 3
0
def test_start_new_strategy(mocker, caplog):
    wt_mock = mocker.patch.object(Path, "write_text", MagicMock())
    mocker.patch.object(Path, "exists", MagicMock(return_value=False))

    args = ["new-strategy", "--strategy", "CoolNewStrategy"]
    start_new_strategy(get_args(args))

    assert wt_mock.call_count == 1
    assert "CoolNewStrategy" in wt_mock.call_args_list[0][0][0]
    assert log_has_re("Writing strategy to .*", caplog)
Ejemplo n.º 4
0
def test_start_new_strategy(mocker, caplog):
    wt_mock = mocker.patch.object(Path, "write_text", MagicMock())
    mocker.patch.object(Path, "exists", MagicMock(return_value=False))

    args = ["new-strategy", "--strategy", "CoolNewStrategy"]
    start_new_strategy(get_args(args))

    assert wt_mock.call_count == 1
    assert "CoolNewStrategy" in wt_mock.call_args_list[0][0][0]
    assert log_has_re("Writing strategy to .*", caplog)

    mocker.patch(
        'freqtrade.commands.deploy_commands.setup_utils_configuration')
    mocker.patch.object(Path, "exists", MagicMock(return_value=True))
    with pytest.raises(
            OperationalException,
            match=r".* already exists. Please choose another Strategy Name\."):
        start_new_strategy(get_args(args))