This commit is contained in:
@@ -1,53 +1,53 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from src.models.data_structures import Author, Commit
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from unittest.mock import MagicMock, patch
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sample_commit():
|
def mock_commit():
|
||||||
"""Create a sample commit for testing."""
|
"""Create a mock commit object."""
|
||||||
return Commit(
|
commit = MagicMock()
|
||||||
sha="abc123def456",
|
commit.sha = "abc123"
|
||||||
message="Add new feature",
|
commit.message = "Test commit"
|
||||||
author="Test User",
|
commit.author_name = "John Doe"
|
||||||
author_email="test@example.com",
|
commit.author_email = "john@test.com"
|
||||||
timestamp=datetime(2024, 1, 15, 10, 30, 0),
|
commit.committed_datetime = datetime(2024, 1, 15, 10, 30, 0)
|
||||||
lines_added=50,
|
commit.author_datetime = datetime(2024, 1, 15, 10, 30, 0)
|
||||||
lines_deleted=10,
|
commit.additions = 50
|
||||||
files_changed=["src/new_feature.py", "tests/test_new_feature.py"],
|
commit.deletions = 10
|
||||||
is_merge=False,
|
commit.files_changed = ["src/main.py", "tests/test.py"]
|
||||||
is_revert=False,
|
commit.parents = []
|
||||||
)
|
commit.is_merge = False
|
||||||
|
commit.is_revert = False
|
||||||
|
commit.lines_changed_count = 60
|
||||||
|
return commit
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sample_author():
|
def mock_repo():
|
||||||
"""Create a sample author for testing."""
|
"""Create a mock git repository."""
|
||||||
return Author(
|
repo = MagicMock()
|
||||||
name="Test User",
|
return repo
|
||||||
email="test@example.com",
|
|
||||||
commit_count=42,
|
|
||||||
lines_added=5000,
|
|
||||||
lines_deleted=1000,
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def sample_commits():
|
def sample_commits():
|
||||||
"""Create a list of sample commits for testing."""
|
"""Create a list of sample commits."""
|
||||||
commits = []
|
commits = []
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
commit = Commit(
|
commit = MagicMock()
|
||||||
sha=f"sha{i}123{i}",
|
commit.sha = f"sha{i}"
|
||||||
message=f"Commit {i}",
|
commit.message = f"Commit {i}"
|
||||||
author="Test User",
|
commit.author_name = "John Doe"
|
||||||
author_email="test@example.com",
|
commit.author_email = "john@test.com"
|
||||||
timestamp=datetime(2024, 1, 15, 10 + i, 30, 0),
|
commit.committed_datetime = datetime(2024, 1, i + 1, 10, 0, 0)
|
||||||
lines_added=10 * i,
|
commit.author_datetime = datetime(2024, 1, i + 1, 10, 0, 0)
|
||||||
lines_deleted=2 * i,
|
commit.additions = 10 * i
|
||||||
files_changed=[f"file{i}.py"],
|
commit.deletions = 5 * i
|
||||||
is_merge=False,
|
commit.files_changed = [f"src/file{i}.py"]
|
||||||
is_revert=False,
|
commit.parents = []
|
||||||
)
|
commit.is_merge = False
|
||||||
|
commit.is_revert = False
|
||||||
|
commit.lines_changed_count = 15 * i
|
||||||
commits.append(commit)
|
commits.append(commit)
|
||||||
return commits
|
return commits
|
||||||
|
|||||||
Reference in New Issue
Block a user