def test_get_project_by_id_raises_error_when_no_project_with_given_id_exists(
) -> None:
    create_fake_lean_cli_directory()

    project_config_manager = ProjectConfigManager(XMLManager())
    python_project_id = project_config_manager.get_local_id(Path.cwd() /
                                                            "Python Project")
    csharp_project_id = project_config_manager.get_local_id(Path.cwd() /
                                                            "CSharp Project")

    project_manager = _create_project_manager()

    with pytest.raises(Exception):
        project_manager.get_project_by_id(
            max(python_project_id, csharp_project_id) + 1)
def test_get_local_id_returns_unique_id_per_project() -> None:
    create_fake_lean_cli_directory()

    project_config_manager = ProjectConfigManager(XMLManager())

    python_id = project_config_manager.get_local_id(Path.cwd() / "Python Project")
    csharp_id = project_config_manager.get_local_id(Path.cwd() / "CSharp Project")

    assert python_id != csharp_id
def test_get_local_id_returns_same_id_for_project_when_called_multiple_times() -> None:
    create_fake_lean_cli_directory()

    project_config_manager = ProjectConfigManager(XMLManager())

    ids = []
    for _ in range(5):
        ids.append(project_config_manager.get_local_id(Path.cwd() / "Python Project"))

    assert len(set(ids)) == 1
def test_get_project_by_id_returns_path_to_project() -> None:
    create_fake_lean_cli_directory()

    project_dir = Path.cwd() / "Python Project"

    project_config_manager = ProjectConfigManager(XMLManager())
    project_id = project_config_manager.get_local_id(project_dir)

    project_manager = _create_project_manager()

    assert project_manager.get_project_by_id(project_id) == project_dir