diff --git a/.gitignore b/.gitignore index d9c21c1..acc0e63 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ __pycache__ *.egg-info *.pyc +.coverage +htmlcov/ diff --git a/pyproject.toml b/pyproject.toml index bac77f6..f37fb2b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,9 @@ dependencies = [ dev = [ "beartype", "black", + "coverage", "mypy", + "pytest", "types-PyYAML", "types-Pygments", ] @@ -31,6 +33,15 @@ target-version = ["py314"] [tool.mypy] strict = true +[tool.pytest.ini_options] +testpaths = ["tests"] + +[tool.coverage.run] +source = ["omicron"] + +[tool.coverage.report] +show_missing = true + [tool.setuptools.packages.find] where = ["."] include = ["omicron.ssg*"] diff --git a/tests/unit/test_site.py b/tests/unit/test_site.py new file mode 100644 index 0000000..431ed96 --- /dev/null +++ b/tests/unit/test_site.py @@ -0,0 +1,19 @@ +from pathlib import Path +import pytest +from omicron.ssg.site import Site + + +@pytest.mark.parametrize( + "value, expected_origin, expected_path", + [ + (None, "", Path("/")), + ("http://example.com/blog", "http://example.com", Path("/blog")), + ("http://example.com", "http://example.com", Path("/")), + ("//example.com/blog", "//example.com", Path("/blog")), + ("/blog", "", Path("/blog")), + ], +) +def test_parse_base_url(value, expected_origin, expected_path): + origin, path = Site.parse_base_url(value) + assert origin == expected_origin + assert path == expected_path