From 6bcddd99292446f5de6ef70b4148d87cd870ce7f Mon Sep 17 00:00:00 2001 From: Mohammad Wasi Date: Sat, 16 May 2026 09:09:49 +0530 Subject: [PATCH] test: add unit test infrastructure and tests for check.py --- pytest.ini | 5 +++++ requirements-dev.txt | 2 ++ tests/test_check.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) create mode 100644 pytest.ini create mode 100644 requirements-dev.txt create mode 100644 tests/test_check.py diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 00000000..4ecb1ad2 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,5 @@ +[pytest] +testpaths = tests +python_files = test_*.py +python_classes = Test* +python_functions = test_* diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 00000000..0ca45cd3 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,2 @@ +pytest>=7.0.0 +pytest-cov>=4.0.0 diff --git a/tests/test_check.py b/tests/test_check.py new file mode 100644 index 00000000..7574d8cf --- /dev/null +++ b/tests/test_check.py @@ -0,0 +1,32 @@ +"""Unit tests for check.py script.""" + +import sys +from pathlib import Path + +# Add scripts directory to path for imports +sys.path.insert(0, str(Path(__file__).parent.parent / "scripts")) + + +def test_rel_function(): + """Test the rel() function converts paths correctly.""" + # Import after path is set up + import check + + root = Path("/Users/test/financial-services") + check.ROOT = root + + test_path = Path("/Users/test/financial-services/plugins/test/file.md") + result = check.rel(test_path) + + assert result == "plugins/test/file.md" + + +def test_err_function(): + """Test the err() function appends to errors list.""" + import check + + check.errors = [] + check.err("test error") + + assert len(check.errors) == 1 + assert check.errors[0] == "test error"