Skip to content

Commit 3b0813a

Browse files
twsltimvink
authored andcommitted
Add tests
1 parent f2033b0 commit 3b0813a

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

tests/basic_setup/mkdocs_mkapi.yml

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+
3+
nav:
4+
- Home: index.md
5+
- API: $api:src/mkdocs_git_authors_plugin.*
6+
7+
plugins:
8+
- search
9+
- mkapi
10+
- git-authors

tests/test_basic.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@
1919
import os
2020
import re
2121
import shutil
22+
import sys
2223
from contextlib import contextmanager
24+
from distutils.version import LooseVersion
2325
from typing import Any, Generator
2426

2527
import git as gitpython
28+
import mkdocs
2629
import pytest
2730
from click.testing import CliRunner, Result
2831
from git import Repo
@@ -316,3 +319,26 @@ def test_fallback(tmp_path) -> None:
316319
assert (
317320
result.exit_code == 0
318321
), f"'mkdocs build' command failed. Error: {result.stdout}"
322+
323+
324+
# https://github.com/daizutabi/mkapi#:~:text=Python%203.10%20or,1.6%20or%20higher
325+
@pytest.mark.skipif(sys.version_info < (3, 10), reason="Requires Python 3.10 or higher")
326+
@pytest.mark.skipif(
327+
LooseVersion(mkdocs.__version__) < LooseVersion("1.6"),
328+
reason="Requires mkdocs 1.6 or higher",
329+
)
330+
def test_mkapi_v3(tmp_path) -> None:
331+
result = build_docs_setup("tests/basic_setup/mkdocs_mkapi.yml", tmp_path)
332+
assert (
333+
result.exit_code == 0
334+
), f"'mkdocs build' command failed. Error: {result.stdout}"
335+
336+
index_file = tmp_path / "index.html"
337+
assert index_file.exists(), f"{index_file} does not exist"
338+
339+
contents = index_file.read_text()
340+
assert re.search("<span class='git-page-authors", contents)
341+
assert re.search(
342+
'<a href="#" class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false">API</a>',
343+
contents,
344+
)

tests/test_requirements.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,7 @@ mkdocs-macros-plugin
1313
# mkdocs
1414
mkdocs
1515
mkdocs-git-revision-date-localized-plugin
16-
mkdocs-material
16+
mkdocs-material
17+
18+
# mkapi
19+
mkapi>=3

0 commit comments

Comments
 (0)