From bd7780f112a2c539ff339459eed1e1f71f753a34 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Sun, 13 Sep 2026 19:01:46 +0200 Subject: [PATCH] test(cli): add tests for Python sections list parser --- tests/unit/cli/test_python.py | 102 ++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) diff --git a/tests/unit/cli/test_python.py b/tests/unit/cli/test_python.py index 947f566..a797249 100644 --- a/tests/unit/cli/test_python.py +++ b/tests/unit/cli/test_python.py @@ -15,6 +15,108 @@ import pathlib import pytest from jcloud_docsgen.cli.cli import create_argument_parser, main as cli_main +from jcloud_docsgen.cli.languages.python import parse_sections_list +from jcloud_docsgen.core.python import PythonDefinitionDocumentationIncludeSections + +@pytest.mark.parametrize('include,exclude,expected', [ + ( + [], + [], + PythonDefinitionDocumentationIncludeSections( + signature = False, + returns = False, + params = False, + exceptions = False, + examples = False, + docstring = False, + bases = False, + decorators = False, + class_body = False + ) + ), + ( + [], + ['signature'], + PythonDefinitionDocumentationIncludeSections( + signature = False, + returns = False, + params = False, + exceptions = False, + examples = False, + docstring = False, + bases = False, + decorators = False, + class_body = False + ) + ), + ( + ['signature'], + ['signature'], + PythonDefinitionDocumentationIncludeSections( + signature = False, + returns = False, + params = False, + exceptions = False, + examples = False, + docstring = False, + bases = False, + decorators = False, + class_body = False + ) + ), + ( + ['signature'], + [], + PythonDefinitionDocumentationIncludeSections( + signature = True, + returns = False, + params = False, + exceptions = False, + examples = False, + docstring = False, + bases = False, + decorators = False, + class_body = False + ) + ), + ( + None, + [], + PythonDefinitionDocumentationIncludeSections() + ), + ( + ['signature', 'exceptions', 'bases', 'class_body'], + ['signature', 'bases'], + PythonDefinitionDocumentationIncludeSections( + signature = False, + returns = False, + params = False, + exceptions = True, + examples = False, + docstring = False, + bases = False, + decorators = False, + class_body = True + ) + ), + ( + None, + ['params', 'docstring'], + PythonDefinitionDocumentationIncludeSections( + signature = True, + returns = True, + params = False, + exceptions = True, + examples = True, + docstring = False, + bases = True, + decorators = True, + class_body = True + ) + ) +]) +def test_parse_sections_list(include, exclude, expected): + assert parse_sections_list(include, exclude) == expected def test_sections_error(): parser = create_argument_parser()