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:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user