From a985d6e937a310eef75690a77d477d9b25c6c4e7 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Sun, 1 Feb 2026 07:59:09 +0000 Subject: [PATCH] Add test suite and configuration --- tests/conftest.py | 74 +++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index ca56adb..36f9eef 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,53 +1,53 @@ import pytest -from src.models.data_structures import Author, Commit from datetime import datetime +from unittest.mock import MagicMock, patch @pytest.fixture -def sample_commit(): - """Create a sample commit for testing.""" - return Commit( - sha="abc123def456", - message="Add new feature", - author="Test User", - author_email="test@example.com", - timestamp=datetime(2024, 1, 15, 10, 30, 0), - lines_added=50, - lines_deleted=10, - files_changed=["src/new_feature.py", "tests/test_new_feature.py"], - is_merge=False, - is_revert=False, - ) +def mock_commit(): + """Create a mock commit object.""" + commit = MagicMock() + commit.sha = "abc123" + commit.message = "Test commit" + commit.author_name = "John Doe" + commit.author_email = "john@test.com" + commit.committed_datetime = datetime(2024, 1, 15, 10, 30, 0) + commit.author_datetime = datetime(2024, 1, 15, 10, 30, 0) + commit.additions = 50 + commit.deletions = 10 + commit.files_changed = ["src/main.py", "tests/test.py"] + commit.parents = [] + commit.is_merge = False + commit.is_revert = False + commit.lines_changed_count = 60 + return commit @pytest.fixture -def sample_author(): - """Create a sample author for testing.""" - return Author( - name="Test User", - email="test@example.com", - commit_count=42, - lines_added=5000, - lines_deleted=1000, - ) +def mock_repo(): + """Create a mock git repository.""" + repo = MagicMock() + return repo @pytest.fixture def sample_commits(): - """Create a list of sample commits for testing.""" + """Create a list of sample commits.""" commits = [] for i in range(10): - commit = Commit( - sha=f"sha{i}123{i}", - message=f"Commit {i}", - author="Test User", - author_email="test@example.com", - timestamp=datetime(2024, 1, 15, 10 + i, 30, 0), - lines_added=10 * i, - lines_deleted=2 * i, - files_changed=[f"file{i}.py"], - is_merge=False, - is_revert=False, - ) + commit = MagicMock() + commit.sha = f"sha{i}" + commit.message = f"Commit {i}" + commit.author_name = "John Doe" + commit.author_email = "john@test.com" + commit.committed_datetime = datetime(2024, 1, i + 1, 10, 0, 0) + commit.author_datetime = datetime(2024, 1, i + 1, 10, 0, 0) + commit.additions = 10 * i + commit.deletions = 5 * i + commit.files_changed = [f"src/file{i}.py"] + commit.parents = [] + commit.is_merge = False + commit.is_revert = False + commit.lines_changed_count = 15 * i commits.append(commit) return commits