Add remaining test files: test_merge, test_sync, test_validate
Some checks failed
CI / build (push) Has been cancelled
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-04 20:09:46 +00:00
parent 1f4c815be0
commit afd6b2f38f

View File

@@ -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"])