"""Unit tests for constants module.""" from abacus_common_logic.constants.math import Bytes from config import EncodingConfig, StorageSettings, ValidationPolicy from src.constants import AdjustmentInputSchema class TestAdjustmentFileColumns: """Tests for ADJUSTMENT_FILE_COLUMNS constant.""" def test_adjustment_file_columns_not_empty(self): """Test ADJUSTMENT_FILE_COLUMNS is not empty.""" assert len(AdjustmentInputSchema.COLUMNS) > 0 def test_adjustment_file_columns_has_required_fields(self): """Test all column mappings have required fields.""" for column_mapping in AdjustmentInputSchema.COLUMNS: assert hasattr(column_mapping, 'column_name') assert hasattr(column_mapping, 'display_name') assert hasattr(column_mapping, 'required') def test_adjustment_file_columns_has_required_columns(self): """Test ADJUSTMENT_FILE_COLUMNS includes required columns.""" required_columns = [ col for col in AdjustmentInputSchema.COLUMNS if col.required ] assert len(required_columns) > 0 def test_adjustment_file_columns_has_optional_columns(self): """Test ADJUSTMENT_FILE_COLUMNS includes optional columns.""" optional_columns = [ col for col in AdjustmentInputSchema.COLUMNS if not col.required ] assert len(optional_columns) > 0 class TestValidateConfig: """Tests for validate_config function - REMOVED. These tests are no longer relevant as validate_config now validates an AppConfig instance with different structure and validation logic. The validation is handled in config.py with different error messages and validation rules. """ pass class TestEncodingConstants: """Tests for encoding-related constants.""" def test_encoding_default_is_utf8(self): """Test ENCODING_DEFAULT is utf-8.""" enc = EncodingConfig() assert enc.DEFAULT == 'utf-8' def test_encoding_chunk_size_valid(self): """Test ENCODING_CHUNK_SIZE is at least 256 bytes.""" enc = EncodingConfig() assert enc.SAMPLE_CHUNK_BYTES >= 256 assert enc.SAMPLE_CHUNK_BYTES == 64 * Bytes.KB def test_encoding_sample_size_valid(self): """Test ENCODING_SAMPLE_SIZE is reasonable.""" enc = EncodingConfig() assert enc.SAMPLE_BYTES >= 256 assert enc.SAMPLE_BYTES == 512 * Bytes.KB class TestFileProcessingConstants: """Tests for file processing constants.""" def test_max_file_row_count_positive(self): """Test MAX_FILE_ROWS is positive.""" policy = ValidationPolicy() assert policy.MAX_FILE_ROWS > 0 assert policy.MAX_FILE_ROWS == 1_000_000 def test_md5_chunk_size_positive(self): """Test DEFAULT_MD5_CHUNK_BYTES is positive.""" enc = EncodingConfig() assert enc.MD5_CHUNK_BYTES > 0 assert enc.MD5_CHUNK_BYTES == 64 * Bytes.KB def test_csv_sample_rows_positive(self): """Test CSV_SAMPLE_ROWS is positive.""" enc = EncodingConfig() assert enc.CSV_SAMPLE_ROWS > 0 assert enc.CSV_SAMPLE_ROWS == 1000 class TestS3Constants: """Tests for S3-related constants.""" def test_s3_max_file_size_bytes(self): """Test MAX_FILE_SIZE_BYTES is 1 GB.""" policy = ValidationPolicy() assert policy.MAX_FILE_BYTES == Bytes.GB assert policy.MAX_FILE_BYTES == 1073741824 def test_s3_staging_key_format_not_empty(self): """Test S3_STAGING_FORMAT is not empty.""" storage = StorageSettings() assert storage.S3_STAGING_FORMAT != '' assert 'batch_id' in storage.S3_STAGING_FORMAT