From ec156a538ea39202fe7693caf23f1ae7829ec131 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Tue, 22 Sep 2026 17:04:56 +0200 Subject: [PATCH] test(python-generator): add test for directory creation Added a testing function which tests whether the documentation directory is created when the documentation is generated. --- .../test_PythonDocumentationGenerator.py | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py b/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py index c97d66f..89612b9 100644 --- a/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py +++ b/tests/unit/core/python/_core/test_PythonDocumentationGenerator.py @@ -16,6 +16,8 @@ import pathlib import pytest +import tempfile + from src.jcloud_docsgen.core.python import PythonDocumentationGenerator from src.jcloud_docsgen.core.python.namespaces import ( PythonModuleNamespace, @@ -119,3 +121,26 @@ def test_generate_documentation(dir, expectdir): allow_tables=True, allow_html=False, ).generate_documentation() # simplify the tests + + +def test_creates_directory(): + with tempfile.TemporaryDirectory() as output_dir: + output_dir = pathlib.Path(output_dir) + with tempfile.TemporaryDirectory() as project_dir: + project_dir = pathlib.Path(project_dir) + + # The directory of the package + package_dir = project_dir / 'src' / 'pkg' + assert not package_dir.exists() + package_dir.mkdir(parents=True, exist_ok=True) + + # The actual output directory directory + docs_dir = output_dir / 'docs' / 'reference' + # It should not exist + assert not docs_dir.exists() + + docs_generator = PythonDocumentationGenerator( + project_dir, docs_dir + ) + docs_generator.generate_documentation() + assert docs_dir.exists()