""" Pytest configuration and shared fixtures for API tests """ import pytest import os @pytest.fixture(scope="session") def figma_config(): """Load Figma configuration from environment""" api_key = os.environ.get('FIGMA_API_KEY') file_key = os.environ.get('DSS_FIGMA_FILE_KEY') if not api_key or not file_key: pytest.skip('FIGMA_API_KEY or DSS_FIGMA_FILE_KEY not set') return { 'api_key': api_key, 'file_key': file_key } @pytest.fixture def figma_client(figma_config): """Initialize Figma client (mocked for now)""" def _mock_extract_variables(file_key, format='json'): """Mock variable extraction""" return { 'status': 'success', 'file_key': file_key, 'format': format, 'variables': { 'colors': { 'primary': '#0066FF', 'secondary': '#FF6B00', 'success': '#00B600', 'warning': '#FFB800', 'danger': '#FF0000', }, 'typography': { 'heading-1': {'fontSize': 32, 'fontWeight': 700}, 'heading-2': {'fontSize': 24, 'fontWeight': 700}, 'body': {'fontSize': 16, 'fontWeight': 400}, 'caption': {'fontSize': 12, 'fontWeight': 400}, }, 'spacing': { 'xs': 4, 'sm': 8, 'md': 16, 'lg': 24, 'xl': 32, }, }, 'tokens_count': 14 } def _mock_extract_components(file_key): """Mock component extraction""" return { 'status': 'success', 'file_key': file_key, 'components': { 'Button': { 'description': 'Primary action button', 'variants': ['primary', 'secondary', 'small', 'large'], 'properties': ['onClick', 'disabled', 'loading'] }, 'Card': { 'description': 'Content container', 'variants': ['elevated', 'outlined'], 'properties': ['spacing', 'border'] }, 'TextField': { 'description': 'Text input field', 'variants': ['default', 'error', 'disabled'], 'properties': ['placeholder', 'value', 'onChange'] }, }, 'components_count': 3 } def _mock_extract_styles(file_key): """Mock style extraction""" return { 'status': 'success', 'file_key': file_key, 'styles': { 'colors': ['primary', 'secondary', 'success', 'warning', 'danger'], 'fills': ['solid-primary', 'solid-secondary', 'gradient-main'], 'typography': ['heading-1', 'heading-2', 'body', 'caption'], 'effects': ['shadow-sm', 'shadow-md', 'shadow-lg'], }, 'styles_count': 14 } return { 'config': figma_config, 'extract_variables': _mock_extract_variables, 'extract_components': _mock_extract_components, 'extract_styles': _mock_extract_styles, }