Skip to content

Commit b971c84

Browse files
committed
Expand unit tests for authorship_threshold_percent and sort_authors_by options
1 parent 50c60c4 commit b971c84

File tree

6 files changed

+38
-6
lines changed

6 files changed

+38
-6
lines changed

tests/basic_setup/mkdocs.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,4 @@ use_directory_urls: true
33

44
plugins:
55
- search
6-
- git-authors:
7-
sort_authors_by: "contribution"
8-
authorship_threshold_percent: 50
6+
- git-authors

tests/basic_setup/mkdocs_w_contribution.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ plugins:
77
count_empty_lines: false
88
show_contribution: true
99
show_line_count: true
10-
authorship_threshold_percent: 50
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
site_name: test gitauthors_plugin
2+
use_directory_urls: true
3+
4+
plugins:
5+
- search
6+
- git-authors:
7+
count_empty_lines: false
8+
show_contribution: true
9+
show_line_count: true
10+
authorship_threshold_percent: 50
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
site_name: test gitauthors_plugin
2+
use_directory_urls: true
3+
4+
plugins:
5+
- search
6+
- git-authors:
7+
sort_authors_by: "contribution"
8+
authorship_threshold_percent: 50

tests/test_basic.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@
2727
import git as gitpython
2828
from contextlib import contextmanager
2929

30+
SITES_THAT_SHOULD_SUCCEED = [
31+
"mkdocs.yml",
32+
"mkdocs_complete_material_disabled.yml",
33+
"mkdocs_complete_material.yml",
34+
"mkdocs_exclude.yml",
35+
"mkdocs_fallback.yml",
36+
"mkdocs_genfiles.yml",
37+
"mkdocs_no_email.yml",
38+
"mkdocs_w_contribution_and_author_threshold.yml",
39+
"mkdocs_w_contribution_sort_and_author_threshold.yml",
40+
"mkdocs_w_contribution.yml",
41+
"mkdocs_w_macros.yml",
42+
"mkdocs_w_macros2.yml",
43+
]
3044

3145
@contextmanager
3246
def working_directory(path):
@@ -58,7 +72,7 @@ def build_docs_setup(mkdocs_path, output_path):
5872

5973
@pytest.mark.parametrize(
6074
"mkdocs_file",
61-
["mkdocs.yml", "mkdocs_w_macros.yml", "mkdocs_w_macros2.yml", "mkdocs_complete_material.yml"],
75+
SITES_THAT_SHOULD_SUCCEED,
6276
)
6377
def test_basic_working(tmp_path, mkdocs_file):
6478
"""

tests/test_util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
"count_empty_lines": True,
3434
"sort_authors_by_name": True,
3535
"sort_reverse": False,
36+
"sort_authors_by": "name",
37+
"authorship_threshold_percent": 0,
3638
}
3739

3840
#### Helpers ####
@@ -331,7 +333,6 @@ def test_mkdocs_in_git_subdir(tmp_path):
331333

332334
os.chdir(cwd)
333335

334-
335336
def test_summarize_authors():
336337
"""
337338
Test summary functions.
@@ -365,3 +366,5 @@ def test_summarize_authors():
365366
# # Now contribution is displayed
366367
# summary = util.Util().summarize(authors, config)
367368
# assert summary == "<span class='git-authors'><a href='mailto:[email protected]'>Tim</a> (64.23%), <a href='mailto:[email protected]'>Tom</a> (35.77%)</span>"
369+
370+
# TODO: test authors threshold with commits

0 commit comments

Comments
 (0)