Fix: #6098 - Add validation logic for parser_config when update document (#13911)

### What problem does this PR solve?

Add validation logic for parser_config.
Refactor the processing flow. Before change, validation logics and
update logics are mixed up - some validation logis executes followed by
some update logic executes and then another such
"validation-and-then-update" which is not good. After change, all
validation logic executes firstly. Update logic will be executed after
ALL validation logic executed.
Validation logic for parameters (that come from front end) will be
checked using Pydantic. For validation logic that depends on data from
DB, they will be in separate methods.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)
- [x] Refactoring
This commit is contained in:
Jack
2026-04-07 11:33:05 +08:00
committed by GitHub
parent 5673245134
commit c4b0aaa874
11 changed files with 1079 additions and 193 deletions

View File

@@ -41,6 +41,7 @@ class TestRunner:
self.coverage = False
self.parallel = False
self.verbose = False
self.ignore_syntax_warning = False
self.markers = ""
# Python interpreter path
@@ -67,6 +68,7 @@ OPTIONS:
-h, --help Show this help message
-c, --coverage Run tests with coverage report
-p, --parallel Run tests in parallel (requires pytest-xdist)
-i, --ignore Run tests with "-W ignore::SyntaxWarning" option
-v, --verbose Verbose output
-t, --test FILE Run specific test file or directory
-m, --markers MARKERS Run tests with specific markers (e.g., "unit", "integration")
@@ -80,6 +82,9 @@ EXAMPLES:
# Run in parallel
python run_tests.py --parallel
# Run tests with "-W ignore::SyntaxWarning" option
python run_tests.py --ignore
# Run specific test file
python run_tests.py --test services/test_dialog_service.py
@@ -130,6 +135,10 @@ EXAMPLES:
# Fallback to auto if multiprocessing not available
cmd.extend(["-n", "auto"])
# Add ignore syntax warning
if self.ignore_syntax_warning:
cmd.extend(["-W", "ignore::SyntaxWarning"])
# Add default options from pyproject.toml if it exists
pyproject_path = self.project_root / "pyproject.toml"
if pyproject_path.exists():
@@ -200,6 +209,7 @@ Examples:
python run_tests.py --parallel # Run in parallel
python run_tests.py --test services/test_dialog_service.py # Run specific test
python run_tests.py --markers "unit" # Run only unit tests
python run_tests.py --ignore # Run with "-W ignore::SyntaxWarning" option
"""
)
@@ -215,6 +225,12 @@ Examples:
help="Run tests in parallel (requires pytest-xdist)"
)
parser.add_argument(
"-i", "--ignore",
action="store_true",
help="Run tests with '-W ignore::SyntaxWarning' "
)
parser.add_argument(
"-v", "--verbose",
action="store_true",
@@ -243,6 +259,7 @@ Examples:
self.parallel = args.parallel
self.verbose = args.verbose
self.markers = args.markers
self.ignore_syntax_warning = args.ignore
return True