"""Pytest configuration and fixtures for dev-env-sync tests.""" import os import tempfile from pathlib import Path from typing import Generator import pytest @pytest.fixture def temp_dir() -> Generator[Path, None, None]: """Create a temporary directory for tests.""" with tempfile.TemporaryDirectory() as tmp: yield Path(tmp) @pytest.fixture def sample_dotfile_content() -> str: """Sample dotfile content.""" return "# Sample dotfile content\nexport TEST='value'\n" @pytest.fixture def sample_settings_json() -> str: """Sample VS Code settings JSON.""" return '{\n "editor.fontSize": 14,\n "editor.tabSize": 2,\n "files.autoSave": "afterDelay"\n}' @pytest.fixture def sample_config_yaml() -> str: """Sample configuration YAML.""" return ''' version: "1.0" name: "Test Environment" description: "Test configuration" dotfiles: bashrc: source: ./dotfiles/.bashrc target: ~/.bashrc backup: true vimrc: source: ./dotfiles/.vimrc target: ~/.vimrc shell: shell: bash merge_strategy: replace editors: vscode: settings: settings_file: ./editors/vscode/settings.json extensions: - name: ms-python.python packages: - name: brew packages: - git - neovim backup: enabled: true directory: ~/.dev-env-sync-backups timestamp_format: "%Y%m%d_%H%M%S" ''' @pytest.fixture def mock_platform_linux(mocker): """Mock platform detection for Linux.""" mocker.patch('platform.system', return_value='Linux') mocker.patch('platform.release', return_value='5.4.0') mocker.patch('platform.version', return_value='#1 SMP') mocker.patch('platform.machine', return_value='x86_64') mocker.patch('pathlib.Path.home', return_value=Path('/home/testuser')) @pytest.fixture def mock_platform_macos(mocker): """Mock platform detection for macOS.""" mocker.patch('platform.system', return_value='Darwin') mocker.patch('platform.release', return_value='21.4.0') mocker.patch('platform.version', return_value='Darwin Kernel Version 21.4.0') mocker.patch('platform.machine', return_value='arm64') mocker.patch('pathlib.Path.home', return_value=Path('/Users/testuser')) @pytest.fixture def mock_platform_wsl(mocker): """Mock platform detection for WSL.""" mocker.patch('platform.system', return_value='Linux') mocker.patch('platform.release', return_value='5.4.72-microsoft-standard-WSL2') mocker.patch('platform.version', return_value='#1 SMP') mocker.patch('platform.machine', return_value='x86_64') mocker.patch('pathlib.Path.home', return_value=Path('/home/testuser'))