Skip to content

Commit 456e5c5

Browse files
committed
refactor test: updated test module
1 parent 5e3cf90 commit 456e5c5

File tree

7 files changed

+57
-11
lines changed

7 files changed

+57
-11
lines changed

tests/fakes/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from .fake_analyzer import FakeAnalyzer
2+
from .fake_commit_source import FakeCommitSource
3+
from .fake_data import FAKE_COMMITS
4+
5+
__all__ = [
6+
"FakeAnalyzer",
7+
"FakeCommitSource",
8+
"FAKE_COMMITS",
9+
]
Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
1-
from fake_commit_source import FakeCommitSource
2-
from fake_data import FAKE_COMMITS
3-
41
from 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

115
def 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

tests/test_engine.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
from datetime import date
22

33
import freezegun
4-
from fake_analyzer import FakeAnalyzer
5-
from fake_commit_source import FakeCommitSource
6-
from fake_data import FAKE_COMMITS
74

85
from git_analytics.engine import CommitAnalyticsEngine
6+
from tests.fakes import FAKE_COMMITS, FakeAnalyzer, FakeCommitSource
97

108

119
def test_number_of_calls_without_start_and_stop_date():
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from fake_data import FAKE_COMMITS
1+
from tests.fakes import FAKE_COMMITS
22

33

44
def test_count_commit():

0 commit comments

Comments
 (0)