Exemplo n.º 1
0
def create_lean_runner(docker_manager: mock.Mock) -> LeanRunner:
    logger = mock.Mock()
    logger.debug_logging_enabled = False

    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"

    project_config_manager = ProjectConfigManager(XMLManager())

    cache_storage = Storage(str(Path("~/.lean/cache").expanduser()))
    lean_config_manager = LeanConfigManager(logger, cli_config_manager,
                                            project_config_manager,
                                            mock.Mock(), cache_storage)
    output_config_manager = OutputConfigManager(lean_config_manager)

    module_manager = mock.Mock()
    module_manager.get_installed_packages.return_value = [
        NuGetPackage(name="QuantConnect.Brokerages", version="1.0.0")
    ]

    xml_manager = XMLManager()
    project_manager = ProjectManager(project_config_manager,
                                     lean_config_manager, xml_manager,
                                     PlatformManager())

    return LeanRunner(logger, project_config_manager, lean_config_manager,
                      output_config_manager, docker_manager, module_manager,
                      project_manager, TempManager(), xml_manager)
Exemplo n.º 2
0
def test_is_path_valid_windows(path: str, valid: bool) -> None:
    if platform.system() != "Windows":
        pytest.skip("This test requires Windows")

    path_manager = PathManager(PlatformManager())

    assert path_manager.is_path_valid(Path.cwd() / path) == valid
Exemplo n.º 3
0
def test_get_relative_path_returns_full_destination_path_when_destination_is_not_relative_to_source(
) -> None:
    path_manager = PathManager(PlatformManager())

    source = Path.cwd()
    destination = Path.cwd().parent

    assert path_manager.get_relative_path(destination, source) == destination
Exemplo n.º 4
0
def test_get_relative_path_returns_relative_path_when_destination_is_relative_to_source(
) -> None:
    path_manager = PathManager(PlatformManager())

    source = Path.cwd()
    destination = Path.cwd() / "path" / "to" / "file.txt"

    assert path_manager.get_relative_path(
        destination, source) == Path("path") / "to" / "file.txt"
Exemplo n.º 5
0
def _create_project_manager() -> ProjectManager:
    xml_manager = XMLManager()
    project_config_manager = ProjectConfigManager(xml_manager)
    cache_storage = Storage(str(Path("~/.lean/cache").expanduser()))

    return ProjectManager(
        project_config_manager,
        LeanConfigManager(mock.Mock(), mock.Mock(), project_config_manager,
                          mock.Mock(), cache_storage), xml_manager,
        PlatformManager())
Exemplo n.º 6
0
def test_is_path_valid_returns_true_for_valid_path() -> None:
    path_manager = PathManager(PlatformManager())

    assert path_manager.is_path_valid(Path.cwd() / "My Path/file.txt")
Exemplo n.º 7
0
def test_get_relative_path_uses_cwd_as_source_when_not_given() -> None:
    path_manager = PathManager(PlatformManager())

    assert path_manager.get_relative_path(
        Path.cwd() / "path" / "to" / "file.txt") == Path("path/to/file.txt")