1+ from mkdocs_git_authors_plugin import util
2+ import os
3+ from git import Actor , Repo
4+
5+ # def test_empty_file(tmp_path):
6+
7+ # # Create empty file
8+ # file_name = os.path.join(tmp_path, 'new-file')
9+ # open(file_name, 'a').close()
10+
11+ # # Get authors of empty, uncommitted file
12+ # r = Repo.init(tmp_path)
13+ # instance = util.Util(tmp_path)
14+ # authors = instance.get_authors(path = file_name)
15+ # assert authors == ""
16+
17+ # # Get authors of empty, committed file
18+ # r.index.add([file_name])
19+ # author = Actor('Tim', '[email protected] ') 20+ # r.index.commit("initial commit", author = author)
21+ # authors = instance.get_authors(path = file_name)
22+ # assert authors == ""
23+
24+ # def test_retrieve_authors(tmp_path):
25+
26+ # # Create file
27+ # file_name = os.path.join(tmp_path, 'new-file')
28+ # with open(file_name, 'w') as the_file:
29+ # the_file.write('Hello\n')
30+
31+ # # Create git repo and commit file
32+ # r = Repo.init(tmp_path)
33+ # r.index.add([file_name])
34+ # author = Actor('Tim', '[email protected] ') 35+ # r.index.commit("initial commit", author = author)
36+
37+ # instance = util.Util(tmp_path)
38+ # authors = instance.get_authors(path = file_name)
39+ # authors[0]['last_datetime'] = None
40+
41+ # assert authors == [{
42+ # 'name' : "Tim",
43+ 44+ # 'last_datetime' : None,
45+ # 'lines' : 1,
46+ # 'contribution' : '100.0%'
47+ # }]
48+
49+ # # Now add a line to the file
50+ # # From a second author with same email
51+ # with open(file_name, 'a+') as the_file:
52+ # the_file.write('World\n')
53+ # r.index.add([file_name])
54+ # author = Actor('Tim2', '[email protected] ') 55+ # r.index.commit("another commit", author = author)
56+
57+ # authors = instance.get_authors(path = file_name)
58+ # authors[0]['last_datetime'] = None
59+
60+ # assert authors == [{
61+ # 'name' : "Tim",
62+ 63+ # 'last_datetime' : None,
64+ # 'lines' : 2,
65+ # 'contribution' : '100.0%'
66+ # }]
67+
68+ # # Then a third commit from a new author
69+ # with open(file_name, 'a+') as the_file:
70+ # the_file.write('A new line\n')
71+ # r.index.add([file_name])
72+ # author = Actor('John', '[email protected] ') 73+ # r.index.commit("third commit", author = author)
74+
75+ # authors = instance.get_authors(path = file_name)
76+ # authors[0]['last_datetime'] = None
77+ # authors[1]['last_datetime'] = None
78+
79+ # assert authors == [{
80+ # 'name' : "John",
81+ 82+ # 'last_datetime' : None,
83+ # 'lines' : 1,
84+ # 'contribution' : '33.33%'
85+ # },{
86+ # 'name' : "Tim",
87+ 88+ # 'last_datetime' : None,
89+ # 'lines' : 2,
90+ # 'contribution' : '66.67%'
91+ # }]
92+
93+ # def test_summarize_authors():
94+
95+ # authors = [
96+ # {'name' : 'Tim',
97+ 98+ # }
99+ # ]
100+
101+ # summary = util.Util().summarize(authors)
102+ # assert summary == "<span class='git-authors'><a href='mailto:[email protected] '>Tim</a></span>"
0 commit comments