1- from fake_commit_source import FakeCommitSource
2- from fake_data import FAKE_COMMITS
3-
41from git_analytics .analyzers .authors_statistics import AuthorsStatisticsAnalyzer
5-
6-
7- def test_first ():
8- assert 1 == 1
2+ from tests .fakes import FAKE_COMMITS , FakeCommitSource
93
104
115def test_authors_statistics_list_of_authors ():
@@ -17,3 +11,48 @@ def test_authors_statistics_list_of_authors():
1711 result = analyzer .result ()
1812
1913 assert set (result .authors .keys ()) == {"Alice" , "Bob" , "Carol" , "Dave" , "Oscar" }
14+
15+
16+ def test_authors_statistics_commits_count_per_author ():
17+ source = FakeCommitSource (FAKE_COMMITS )
18+
19+ analyzer = AuthorsStatisticsAnalyzer ()
20+ for commit in source .iter_commits ():
21+ analyzer .process (commit )
22+ result = analyzer .result ()
23+
24+ assert result .authors ["Alice" ].commits == 11
25+ assert result .authors ["Bob" ].commits == 6
26+ assert result .authors ["Carol" ].commits == 4
27+ assert result .authors ["Dave" ].commits == 11
28+ assert result .authors ["Oscar" ].commits == 8
29+
30+
31+ def test_authors_statistics_insertions_count_per_author ():
32+ source = FakeCommitSource (FAKE_COMMITS )
33+
34+ analyzer = AuthorsStatisticsAnalyzer ()
35+ for commit in source .iter_commits ():
36+ analyzer .process (commit )
37+ result = analyzer .result ()
38+
39+ assert result .authors ["Alice" ].insertions == 517 + 225 + 391 + 572 + 582 + 179 + 109 + 304 + 47 + 387 + 270
40+ assert result .authors ["Bob" ].insertions == 781 + 760 + 314 + 461 + 442 + 1078
41+ assert result .authors ["Carol" ].insertions == 614 + 102 + 280 + 303
42+ assert result .authors ["Dave" ].insertions == 118 + 100 + 214 + 35 + 52 + 140 + 243 + 147 + 68 + 236 + 212
43+ assert result .authors ["Oscar" ].insertions == 599 + 623 + 429 + 544 + 579 + 138 + 287 + 494
44+
45+
46+ def test_authors_statistics_deletions_count_per_author ():
47+ source = FakeCommitSource (FAKE_COMMITS )
48+
49+ analyzer = AuthorsStatisticsAnalyzer ()
50+ for commit in source .iter_commits ():
51+ analyzer .process (commit )
52+ result = analyzer .result ()
53+
54+ assert result .authors ["Alice" ].deletions == 40 + 164 + 162 + 276 + 89 + 115 + 221 + 8 + 292 + 181 + 119
55+ assert result .authors ["Bob" ].deletions == 513 + 165 + 172 + 665 + 146 + 384
56+ assert result .authors ["Carol" ].deletions == 305 + 273 + 93 + 369
57+ assert result .authors ["Dave" ].deletions == 23 + 54 + 110 + 6 + 52 + 63 + 120 + 33 + 105 + 117 + 87
58+ assert result .authors ["Oscar" ].deletions == 343 + 381 + 140 + 276 + 389 + 325 + 288 + 6
0 commit comments