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.
This commit is contained in:
jakob.scheid committed 2026-09-22 17:04:56 +02:00
1 parent e2264696e8
commit ec156a538e
1 file changed
+25
@@ -16,6 +16,8 @@ import pathlib
import pytest import pytest
import tempfile
from src.jcloud_docsgen.core.python import PythonDocumentationGenerator from src.jcloud_docsgen.core.python import PythonDocumentationGenerator
from src.jcloud_docsgen.core.python.namespaces import ( from src.jcloud_docsgen.core.python.namespaces import (
PythonModuleNamespace, PythonModuleNamespace,
@@ -119,3 +121,26 @@ def test_generate_documentation(dir, expectdir):
allow_tables=True, allow_tables=True,
allow_html=False, allow_html=False,
).generate_documentation() # simplify the tests ).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()