# Path: valohai_cli/exceptions.py
# class ConfigurationError(CLIException, RuntimeError):
#     kind = 'Configuration Error'
# 
# class NoCommit(ValueError, CLIException):
#     color = 'yellow'
# 
#     def __init__(self, directory: str) -> None:
#         self.directory = directory
#         super().__init__(f'{directory} has no commits')
# 
# class PackageTooLarge(CLIException):
#     pass
# 
# Path: valohai_cli/git.py
# def describe_current_commit(directory: str) -> str:
#     """
#     (Try to) describe the lineage and status of the Git working copy in `directory`.
#     :param directory: Directory path.
#     :return: Git description string
#     """
#     return check_git_output(['git', 'describe', '--always', '--long', '--dirty', '--all'], directory).strip().decode()


import os
import pytest
import valohai_cli.packager as pkg
from subprocess import check_call, check_output
from typing import Set
from click import termui
from valohai_cli.exceptions import ConfigurationError, NoCommit, PackageTooLarge
from valohai_cli.git import describe_current_commit
        pkg.package_directory(str(tmpdir))


def test_file_soft_size_warn(tmpdir, capsys, monkeypatch):
    monkeypatch.setattr(termui, 'visible_prompt_func', lambda x: 'y\n')
    write_temp_files(tmpdir, with_yaml=True, large_file_size=int(pkg.FILE_SIZE_WARN_THRESHOLD + 50))
    pkg.package_directory(str(tmpdir))
    out, err = capsys.readouterr()
    assert 'Large file large_file.dat' in err


@pytest.mark.parametrize('threshold', (
    'UNCOMPRESSED_PACKAGE_SIZE_HARD_THRESHOLD',
    'COMPRESSED_PACKAGE_SIZE_HARD_THRESHOLD',
))
def test_package_hard_size_fail(tmpdir, monkeypatch, threshold):
    monkeypatch.setattr(pkg, threshold, 200)
    write_temp_files(tmpdir, with_yaml=True, with_gitignore=False, large_file_size=10000)
    with pytest.raises(PackageTooLarge):
        pkg.package_directory(str(tmpdir))


def test_package_file_count_hard_fail(tmpdir, monkeypatch):
    # Should not fail here
    monkeypatch.setattr(pkg, 'FILE_COUNT_HARD_THRESHOLD', 3)
    write_temp_files(tmpdir, with_yaml=True, with_gitignore=False)
    pkg.package_directory(str(tmpdir))

    # With threshold of 2, should fail for 3 files
    monkeypatch.setattr(pkg, 'FILE_COUNT_HARD_THRESHOLD', 2)

# Path: valohai_cli/exceptions.py
# class ConfigurationError(CLIException, RuntimeError):
#     kind = 'Configuration Error'
# 
# class NoCommit(ValueError, CLIException):
#     color = 'yellow'
# 
#     def __init__(self, directory: str) -> None:
#         self.directory = directory
#         super().__init__(f'{directory} has no commits')
# 
# class PackageTooLarge(CLIException):
#     pass
# 
# Path: valohai_cli/git.py
# def describe_current_commit(directory: str) -> str:
#     """
#     (Try to) describe the lineage and status of the Git working copy in `directory`.
#     :param directory: Directory path.
#     :return: Git description string
#     """
#     return check_git_output(['git', 'describe', '--always', '--long', '--dirty', '--all'], directory).strip().decode()


# Path: tests/test_packaging.py
import os
import pytest
import valohai_cli.packager as pkg
from subprocess import check_call, check_output
from typing import Set
from click import termui
from valohai_cli.exceptions import ConfigurationError, NoCommit, PackageTooLarge
from valohai_cli.git import describe_current_commit

        pkg.package_directory(str(tmpdir))


def test_file_soft_size_warn(tmpdir, capsys, monkeypatch):
    monkeypatch.setattr(termui, 'visible_prompt_func', lambda x: 'y\n')
    write_temp_files(tmpdir, with_yaml=True, large_file_size=int(pkg.FILE_SIZE_WARN_THRESHOLD + 50))
    pkg.package_directory(str(tmpdir))
    out, err = capsys.readouterr()
    assert 'Large file large_file.dat' in err


@pytest.mark.parametrize('threshold', (
    'UNCOMPRESSED_PACKAGE_SIZE_HARD_THRESHOLD',
    'COMPRESSED_PACKAGE_SIZE_HARD_THRESHOLD',
))
def test_package_hard_size_fail(tmpdir, monkeypatch, threshold):
    monkeypatch.setattr(pkg, threshold, 200)
    write_temp_files(tmpdir, with_yaml=True, with_gitignore=False, large_file_size=10000)
    with pytest.raises(PackageTooLarge):
        pkg.package_directory(str(tmpdir))


def test_package_file_count_hard_fail(tmpdir, monkeypatch):
    # Should not fail here
    monkeypatch.setattr(pkg, 'FILE_COUNT_HARD_THRESHOLD', 3)
    write_temp_files(tmpdir, with_yaml=True, with_gitignore=False)
    pkg.package_directory(str(tmpdir))

    # With threshold of 2, should fail for 3 files
    monkeypatch.setattr(pkg, 'FILE_COUNT_HARD_THRESHOLD', 2)

    with pytest.raises(PackageTooLarge):