""" Tests for configuration settings and helper functions. """ import pytest import os from config import Config from app import get_application_path, get_data_file_path, get_attachments_path class TestConfiguration: """Tests for Config class.""" def test_config_has_required_settings(self): """Test that all required configuration values exist.""" assert hasattr(Config, 'SECRET_KEY') assert hasattr(Config, 'MAIL_SERVER') assert hasattr(Config, 'MAIL_PORT') assert hasattr(Config, 'MAIL_USE_TLS') assert hasattr(Config, 'APPLICATIONS_FOLDER') assert hasattr(Config, 'MAX_FILE_SIZE') assert hasattr(Config, 'MAX_FILES') assert hasattr(Config, 'ALLOWED_EXTENSIONS') assert hasattr(Config, 'MAX_STRING_LENGTH') assert hasattr(Config, 'MAX_TEXT_AREA_LENGTH') assert hasattr(Config, 'MAX_ZIP_DIGITS') assert hasattr(Config, 'MIN_BIRTH_YEAR') assert hasattr(Config, 'MAX_BIRTH_YEAR') def test_file_size_limit(self): """Test that file size limit is set correctly.""" assert Config.MAX_FILE_SIZE == 4 * 1024 * 1024 # 4 MB def test_max_files_limit(self): """Test that maximum number of files is set correctly.""" assert Config.MAX_FILES == 3 def test_allowed_extensions(self): """Test that allowed file extensions are configured.""" assert isinstance(Config.ALLOWED_EXTENSIONS, set) assert 'pdf' in Config.ALLOWED_EXTENSIONS assert 'doc' in Config.ALLOWED_EXTENSIONS assert 'docx' in Config.ALLOWED_EXTENSIONS def test_string_length_limits(self): """Test that string length limits are set.""" assert Config.MAX_STRING_LENGTH == 255 assert Config.MAX_TEXT_AREA_LENGTH == 3000 assert Config.MAX_ZIP_DIGITS == 10 def test_birth_year_range(self): """Test that birth year range is configured correctly.""" assert Config.MIN_BIRTH_YEAR == 1940 assert Config.MAX_BIRTH_YEAR == 2010 assert Config.MIN_BIRTH_YEAR < Config.MAX_BIRTH_YEAR class TestPathHelpers: """Tests for path helper functions.""" def test_get_application_path(self, app): """Test get_application_path returns correct path.""" session_id = 'test-123' expected_path = os.path.join(app.config['APPLICATIONS_FOLDER'], session_id) assert get_application_path(session_id) == expected_path def test_get_data_file_path(self, app): """Test get_data_file_path returns correct YAML file path.""" session_id = 'test-456' expected_path = os.path.join( app.config['APPLICATIONS_FOLDER'], session_id, 'data.yaml' ) assert get_data_file_path(session_id) == expected_path def test_get_attachments_path(self, app): """Test get_attachments_path returns correct attachments directory path.""" session_id = 'test-789' expected_path = os.path.join( app.config['APPLICATIONS_FOLDER'], session_id, 'attachments' ) assert get_attachments_path(session_id) == expected_path def test_path_helpers_with_special_characters(self, app): """Test path helpers handle session IDs with special characters.""" session_id = 'test-abc-123-def' app_path = get_application_path(session_id) assert session_id in app_path assert os.path.isabs(app_path) or app_path.startswith('.')