1
- """ Unit tests for the write_to_markdown function in markdown_writer.py """
1
+ """Unit tests for the write_to_markdown function in markdown_writer.py"""
2
2
3
3
import unittest
4
4
from unittest .mock import call , mock_open , patch
@@ -13,7 +13,7 @@ def test_write_with_all_counts_and_no_users_to_remove(self):
13
13
"""Test that the function writes the correct markdown when there are no users to remove"""
14
14
mock_file = mock_open ()
15
15
with patch ("builtins.open" , mock_file ):
16
- write_to_markdown (0 , 0 , 2 , 3 , {})
16
+ write_to_markdown (0 , 0 , 2 , 3 , {}, [] )
17
17
mock_file ().write .assert_called_once_with (
18
18
"# Cleanowners Report\n \n "
19
19
"## Overall Stats\n "
@@ -28,7 +28,7 @@ def test_write_with_repos_and_users_with_users_to_remove(self):
28
28
mock_file = mock_open ()
29
29
repo_users = {"repo1" : ["user1" , "user2" ], "repo2" : ["user3" ]}
30
30
with patch ("builtins.open" , mock_file ):
31
- write_to_markdown (1 , 2 , 3 , 4 , repo_users )
31
+ write_to_markdown (1 , 2 , 3 , 4 , repo_users , [] )
32
32
calls = [
33
33
call (
34
34
"# Cleanowners Report\n \n "
@@ -49,11 +49,33 @@ def test_write_with_repos_and_users_with_users_to_remove(self):
49
49
]
50
50
mock_file ().write .assert_has_calls (calls , any_order = False )
51
51
52
+ def test_write_with_repos_missing_codeowners (self ):
53
+ """Test that the function writes the correct markdown when there are repos missing CODEOWNERS"""
54
+ mock_file = mock_open ()
55
+ repos_missing_codeowners = ["repo1" , "repo2" ]
56
+ with patch ("builtins.open" , mock_file ):
57
+ write_to_markdown (0 , 0 , 2 , 0 , {}, repos_missing_codeowners )
58
+ calls = [
59
+ call (
60
+ "# Cleanowners Report\n \n "
61
+ "## Overall Stats\n "
62
+ "0 Users to Remove\n "
63
+ "0 Pull Requests created\n "
64
+ "2 Repositories with no CODEOWNERS file\n "
65
+ "0 Repositories with CODEOWNERS file\n "
66
+ ),
67
+ call ("## Repositories Missing CODEOWNERS\n " ),
68
+ call ("- repo1\n " ),
69
+ call ("- repo2\n " ),
70
+ call ("\n " ),
71
+ ]
72
+ mock_file ().write .assert_has_calls (calls , any_order = False )
73
+
52
74
def test_write_with_empty_inputs (self ):
53
75
"""Test that the function writes the correct markdown when all inputs are 0"""
54
76
mock_file = mock_open ()
55
77
with patch ("builtins.open" , mock_file ):
56
- write_to_markdown (0 , 0 , 0 , 0 , {})
78
+ write_to_markdown (0 , 0 , 0 , 0 , {}, [] )
57
79
mock_file ().write .assert_called_once_with (
58
80
"# Cleanowners Report\n \n "
59
81
"## Overall Stats\n "
0 commit comments