From afd6b2f38f66adbabc0f7cd06c421bfabedd5bb5 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Wed, 4 Feb 2026 20:09:46 +0000 Subject: [PATCH] Add remaining test files: test_merge, test_sync, test_validate --- confsync/tests/test_sync.py | 81 +++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 confsync/tests/test_sync.py diff --git a/confsync/tests/test_sync.py b/confsync/tests/test_sync.py new file mode 100644 index 0000000..b5dc0f7 --- /dev/null +++ b/confsync/tests/test_sync.py @@ -0,0 +1,81 @@ +"""Tests for sync operations.""" + +import pytest + + +class TestGitOperations: + """Tests for Git operations.""" + + def test_git_manager_init(self): + """Test GitManager initialization.""" + from confsync.utils.git_utils import GitManager + + git = GitManager() + assert git.repo_path is None + + git = GitManager(repo_path="/test/repo") + assert git.repo_path == "/test/repo" + + +class TestSyncManager: + """Tests for sync manager operations.""" + + def test_sync_operation_enum(self): + """Test SyncOperation enum values.""" + from confsync.models.config_models import SyncOperation + + assert SyncOperation.PUSH.value == "push" + assert SyncOperation.PULL.value == "pull" + assert SyncOperation.SYNC.value == "sync" + assert SyncOperation.STATUS.value == "status" + + +class TestSyncWorkflows: + """Tests for sync workflows.""" + + def test_create_encrypted_manifest(self): + """Test creating encrypted manifest.""" + from confsync.core.manifest import ManifestBuilder + from confsync.utils.encryption import EncryptionManager + from confsync.models.config_models import ConfigFile, ConfigCategory + + builder = ManifestBuilder() + + config = ConfigFile( + path="/test/.vimrc", + name=".vimrc", + category=ConfigCategory.EDITOR, + tool_name="vim", + content="set nocompatible", + ) + + builder.build_from_detected([config]) + + enc_manager = EncryptionManager(passphrase="test_key") + encrypted = enc_manager.encrypt_manifest("test manifest data") + + assert isinstance(encrypted, str) + assert len(encrypted) > 0 + + +class TestSyncIntegration: + """Integration tests for sync operations.""" + + def test_sync_with_mocked_git(self): + """Test sync with mocked Git operations.""" + from confsync.models.config_models import SyncMetadata, SyncOperation + + metadata = SyncMetadata( + operation=SyncOperation.PUSH, + source="/local/configs", + destination="https://github.com/user/configs.git", + committed_files=[".vimrc", ".bashrc"], + status="pending", + ) + + assert metadata.operation == SyncOperation.PUSH + assert len(metadata.committed_files) == 2 + + +if __name__ == "__main__": + pytest.main([__file__, "-v"])