Extract item template metadata policy
This commit is contained in:
@@ -10,11 +10,17 @@ from __future__ import annotations
|
||||
import ast
|
||||
import json
|
||||
import re
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
import category_template_metadata as template_metadata_policy # noqa: E402
|
||||
|
||||
POOL_DEFINITION_KEYS = ("scene_pools", "expression_pools", "composition_pools")
|
||||
POOL_REFERENCE_KEYS = {
|
||||
"scene_pool": "scene_pools",
|
||||
@@ -187,6 +193,9 @@ def _template_axis_errors(path: str, node: dict[str, Any]) -> list[tuple[str, st
|
||||
or template.get("name")
|
||||
or ""
|
||||
).strip()
|
||||
metadata = template_metadata_policy.template_metadata(template)
|
||||
for issue in template_metadata_policy.template_metadata_errors(metadata):
|
||||
errors.append((template_path, issue))
|
||||
elif isinstance(template, str):
|
||||
template_text = template
|
||||
else:
|
||||
|
||||
@@ -25,6 +25,7 @@ if str(ROOT) not in sys.path:
|
||||
|
||||
import caption_naturalizer # noqa: E402
|
||||
import caption_policy # noqa: E402
|
||||
import category_template_metadata # noqa: E402
|
||||
import character_config # noqa: E402
|
||||
import character_profile # noqa: E402
|
||||
import category_cast_config # noqa: E402
|
||||
@@ -1212,6 +1213,23 @@ def smoke_hardcore_position_config_policy() -> None:
|
||||
_expect(pb._template_position_family(template_metadata) == "oral", "Template metadata route lost position family")
|
||||
_expect(pb._template_position_keys(template_metadata) == ["kneeling", "open_thighs"], "Template metadata route lost position keys")
|
||||
_expect(pb._template_action_family(template_metadata) == "oral", "Template metadata route lost normalized action family")
|
||||
_expect(
|
||||
pb._template_action_family(template_metadata) == category_template_metadata.template_action_family(template_metadata),
|
||||
"Prompt builder template action policy should delegate",
|
||||
)
|
||||
_expect(
|
||||
category_template_metadata.template_metadata_errors(template_metadata) == [],
|
||||
"Valid template metadata should not report audit errors",
|
||||
)
|
||||
invalid_metadata = {
|
||||
"action_family": "bad_action",
|
||||
"position_family": "bad_family",
|
||||
"position_keys": ["kneeling", "bad_position"],
|
||||
}
|
||||
invalid_errors = category_template_metadata.template_metadata_errors(invalid_metadata)
|
||||
_expect(any("bad_action" in error for error in invalid_errors), "Template metadata validation missed bad action")
|
||||
_expect(any("bad_family" in error for error in invalid_errors), "Template metadata validation missed bad family")
|
||||
_expect(any("bad_position" in error for error in invalid_errors), "Template metadata validation missed bad position key")
|
||||
|
||||
|
||||
def smoke_category_library_route() -> None:
|
||||
|
||||
Reference in New Issue
Block a user