Ejemplo n.º 1
0
def test_get_complete_lean_config_sets_close_automatically() -> None:
    create_fake_lean_cli_directory()

    manager = LeanConfigManager(mock.Mock(), ProjectConfigManager())
    config = manager.get_complete_lean_config(
        "my-environment",
        Path.cwd() / "Python Project" / "main.py", None)

    assert config["close-automatically"]
Ejemplo n.º 2
0
def test_get_complete_lean_config_sets_iqfeed_host() -> None:
    create_fake_lean_cli_directory()

    manager = LeanConfigManager(mock.Mock(), ProjectConfigManager())
    config = manager.get_complete_lean_config(
        "my-environment",
        Path.cwd() / "Python Project" / "main.py", None)

    assert config["iqfeed-host"] == "host.docker.internal"
Ejemplo n.º 3
0
def test_get_complete_lean_config_disables_debugging_when_no_method_given(
) -> None:
    create_fake_lean_cli_directory()

    manager = LeanConfigManager(mock.Mock(), ProjectConfigManager())
    config = manager.get_complete_lean_config(
        "my-environment",
        Path.cwd() / "Python Project" / "main.py", None)

    assert not config["debugging"]
Ejemplo n.º 4
0
def test_get_complete_lean_config_sets_python_algorithm_details() -> None:
    create_fake_lean_cli_directory()

    manager = LeanConfigManager(mock.Mock(), ProjectConfigManager())
    config = manager.get_complete_lean_config(
        "my-environment",
        Path.cwd() / "Python Project" / "main.py", None)

    assert config["algorithm-type-name"] == "main"
    assert config["algorithm-language"] == "Python"
    assert config["algorithm-location"] == "/LeanCLI/main.py"
Ejemplo n.º 5
0
def test_get_complete_lean_config_parses_debugging_method_correctly(
        method: DebuggingMethod, value: str) -> None:
    create_fake_lean_cli_directory()

    manager = LeanConfigManager(mock.Mock(), ProjectConfigManager())
    config = manager.get_complete_lean_config(
        "my-environment",
        Path.cwd() / "Python Project" / "main.py", method)

    assert config["debugging"]
    assert config["debugging-method"] == value
Ejemplo n.º 6
0
def test_get_complete_lean_config_sets_interactive_brokers_config() -> None:
    create_fake_lean_cli_directory()

    manager = LeanConfigManager(mock.Mock(), ProjectConfigManager())
    config = manager.get_complete_lean_config(
        "my-environment",
        Path.cwd() / "Python Project" / "main.py", None)

    assert config["ib-host"] == "127.0.0.1"
    assert config["ib-port"] == "4002"
    assert config["ib-tws-dir"] == "/root/Jts"
    assert config["ib-version"] == "978"
Ejemplo n.º 7
0
def test_get_complete_lean_config_sets_csharp_algorithm_details(
        csharp_code: str, class_name: str) -> None:
    create_fake_lean_cli_directory()

    csharp_path = Path.cwd() / "CSharp Project" / "Main.cs"
    with csharp_path.open("w+", encoding="utf-8") as file:
        file.write(csharp_code.strip() + "\n")

    manager = LeanConfigManager(mock.Mock(), ProjectConfigManager())
    config = manager.get_complete_lean_config("my-environment", csharp_path,
                                              None)

    assert config["algorithm-type-name"] == class_name
    assert config["algorithm-language"] == "CSharp"
    assert config["algorithm-location"] == "CSharp Project.dll"
Ejemplo n.º 8
0
def test_get_complete_lean_config_sets_credentials_from_cli_config_manager(
) -> None:
    create_fake_lean_cli_directory()

    cli_config_manager = mock.Mock()
    cli_config_manager.user_id.get_value.return_value = "123"
    cli_config_manager.api_token.get_value.return_value = "456"

    manager = LeanConfigManager(cli_config_manager, ProjectConfigManager())
    config = manager.get_complete_lean_config(
        "my-environment",
        Path.cwd() / "Python Project" / "main.py", None)

    assert config["job-user-id"] == "123"
    assert config["api-access-token"] == "456"
Ejemplo n.º 9
0
def test_get_complete_lean_config_returns_dict_with_all_keys_removed_in_clean_lean_config(
) -> None:
    create_fake_lean_cli_directory()

    manager = LeanConfigManager(mock.Mock(), ProjectConfigManager())
    config = manager.get_complete_lean_config(
        "backtesting",
        Path.cwd() / "Python Project" / "main.py", None)

    for key in [
            "environment", "algorithm-type-name", "algorithm-language",
            "algorithm-location", "composer-dll-directory", "debugging",
            "debugging-method", "parameters"
    ]:
        assert key in config
Ejemplo n.º 10
0
def test_get_complete_lean_config_sets_parameters() -> None:
    create_fake_lean_cli_directory()

    Storage(str(Path.cwd() / "Python Project" / "config.json")).set(
        "parameters", {
            "key1": "value1",
            "key2": "value2",
            "key3": "value3"
        })

    manager = LeanConfigManager(mock.Mock(), ProjectConfigManager())
    config = manager.get_complete_lean_config(
        "my-environment",
        Path.cwd() / "Python Project" / "main.py", None)

    assert config["parameters"] == {
        "key1": "value1",
        "key2": "value2",
        "key3": "value3"
    }