refactor: extract PROCEDURAL_TREE_TYPES constant and add negative tree_type test

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
chihlasm
2026-02-17 10:54:39 -05:00
parent d75e6f78e1
commit 36e1335a00
2 changed files with 25 additions and 2 deletions

View File

@@ -1,6 +1,8 @@
"""Tree validation helper module for draft/published workflow."""
from typing import Any
PROCEDURAL_TREE_TYPES = {"procedural", "maintenance"}
class TreeValidationError(Exception):
"""Custom exception for tree validation errors."""
@@ -224,14 +226,14 @@ def can_publish_tree(
errors.append({"field": "name", "message": "Tree must have a name to be published"})
# Validate structure based on tree type
if tree_type in ("procedural", "maintenance"):
if tree_type in PROCEDURAL_TREE_TYPES:
structure_valid, structure_errors = validate_procedural_structure(tree_structure)
else:
structure_valid, structure_errors = validate_tree_structure(tree_structure)
errors.extend(structure_errors)
# Validate intake form if present (procedural only)
if intake_form and tree_type in ("procedural", "maintenance"):
if intake_form and tree_type in PROCEDURAL_TREE_TYPES:
form_valid, form_errors = _validate_intake_form(intake_form)
errors.extend(form_errors)