-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_markdown_writer_zero_contributions.py
More file actions
65 lines (54 loc) · 2.13 KB
/
test_markdown_writer_zero_contributions.py
File metadata and controls
65 lines (54 loc) · 2.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
Tests for markdown_writer.py specifically for zero contribution counts
"""
import os
import tempfile
from markdown_writer import write_to_markdown
class TestWriteToMarkdownZeroContributions:
"""
Test cases for zero contributions in markdown_writer.py
"""
def test_write_to_markdown_zero_contributions(self):
"""
Test writing markdown when team_member_contribution_counts has only zeros
"""
with tempfile.NamedTemporaryFile(suffix=".md", delete=False) as temp_file:
temp_file_path = temp_file.name
try:
# Mock repo data object
class MockRepo:
"""
Mock repository data class for testing
"""
@property
def full_name(self):
"""
Returns the full name of the mock repository
"""
return "owner/repo"
write_to_markdown(
report_title="Test Report",
output_file=temp_file_path,
innersource_ratio=0.5,
repo_data=MockRepo(),
original_commit_author="author",
original_commit_author_manager="manager",
team_members_that_own_the_repo=["team_member1"],
all_contributors=["contributor1"],
innersource_contributors=["contributor1"],
innersource_contribution_counts={"contributor1": 5},
team_member_contribution_counts={
"team_member1": 0,
"team_member2": 0,
}, # All zero counts
team_ownership_explicitly_specified=False,
)
# Read the generated file
with open(temp_file_path, "r", encoding="utf-8") as f:
content = f.read()
# Check if the "No team member contributions found" message is included
assert "No team member contributions found." in content
finally:
# Clean up the temporary file
if os.path.exists(temp_file_path):
os.remove(temp_file_path)