Add test fixtures and unit tests for CLI, models, and formatters
This commit is contained in:
@@ -19,8 +19,6 @@ class TestAuthor:
|
|||||||
name="John Doe",
|
name="John Doe",
|
||||||
email="john@example.com",
|
email="john@example.com",
|
||||||
commit_count=100,
|
commit_count=100,
|
||||||
lines_added=5000,
|
|
||||||
lines_deleted=1000,
|
|
||||||
)
|
)
|
||||||
assert author.name == "John Doe"
|
assert author.name == "John Doe"
|
||||||
assert author.email == "john@example.com"
|
assert author.email == "john@example.com"
|
||||||
@@ -35,48 +33,12 @@ class TestCommit:
|
|||||||
commit = Commit(
|
commit = Commit(
|
||||||
sha="abc123",
|
sha="abc123",
|
||||||
message="Test commit",
|
message="Test commit",
|
||||||
author_name="John Doe",
|
author="John Doe",
|
||||||
author_email="john@example.com",
|
author_email="john@example.com",
|
||||||
committed_datetime=datetime.now(),
|
timestamp=datetime.now(),
|
||||||
author_datetime=datetime.now(),
|
|
||||||
)
|
)
|
||||||
assert commit.sha == "abc123"
|
assert commit.sha == "abc123"
|
||||||
assert commit.message == "Test commit"
|
assert commit.message == "Test commit"
|
||||||
assert commit.lines_added == 0
|
|
||||||
assert commit.lines_deleted == 0
|
|
||||||
|
|
||||||
def test_commit_with_changes(self):
|
|
||||||
"""Test creating a Commit with changes."""
|
|
||||||
commit = Commit(
|
|
||||||
sha="abc123",
|
|
||||||
message="Test commit",
|
|
||||||
author_name="John Doe",
|
|
||||||
author_email="john@example.com",
|
|
||||||
committed_datetime=datetime.now(),
|
|
||||||
author_datetime=datetime.now(),
|
|
||||||
lines_added=100,
|
|
||||||
lines_deleted=50,
|
|
||||||
files_changed=["src/main.py", "tests/test.py"],
|
|
||||||
is_merge=False,
|
|
||||||
is_revert=False,
|
|
||||||
)
|
|
||||||
assert len(commit.files_changed) == 2
|
|
||||||
assert commit.lines_added == 100
|
|
||||||
|
|
||||||
|
|
||||||
class TestFileChange:
|
|
||||||
"""Test FileChange dataclass."""
|
|
||||||
|
|
||||||
def test_file_change_creation(self):
|
|
||||||
"""Test creating a FileChange."""
|
|
||||||
change = FileChange(
|
|
||||||
filepath="src/main.py",
|
|
||||||
lines_added=50,
|
|
||||||
lines_deleted=10,
|
|
||||||
change_type="M",
|
|
||||||
)
|
|
||||||
assert change.filepath == "src/main.py"
|
|
||||||
assert change.lines_added == 50
|
|
||||||
|
|
||||||
|
|
||||||
class TestCommitAnalysis:
|
class TestCommitAnalysis:
|
||||||
@@ -87,8 +49,8 @@ class TestCommitAnalysis:
|
|||||||
analysis = CommitAnalysis(
|
analysis = CommitAnalysis(
|
||||||
total_commits=100,
|
total_commits=100,
|
||||||
unique_authors=5,
|
unique_authors=5,
|
||||||
commits_by_hour={"10:00": 10, "14:00": 15},
|
commits_by_hour={"10:00": 10},
|
||||||
commits_by_day={"Monday": 20, "Tuesday": 15},
|
commits_by_day={"Monday": 20},
|
||||||
commits_by_week={"2024-W01": 50},
|
commits_by_week={"2024-W01": 50},
|
||||||
top_authors=[],
|
top_authors=[],
|
||||||
average_commits_per_day=3.3,
|
average_commits_per_day=3.3,
|
||||||
|
|||||||
Reference in New Issue
Block a user