Extract filter config policy

This commit is contained in:
2026-06-27 00:35:06 +02:00
parent 65574222b2
commit 5675536009
6 changed files with 369 additions and 200 deletions
+42
View File
@@ -26,6 +26,7 @@ if str(ROOT) not in sys.path:
import caption_naturalizer # noqa: E402
import category_cast_config # noqa: E402
import category_library # noqa: E402
import filter_config # noqa: E402
import __init__ as sxcp_nodes # noqa: E402
import generation_profile_config # noqa: E402
import krea_formatter # noqa: E402
@@ -620,6 +621,46 @@ def smoke_generation_profile_config_policy() -> None:
_expect(fallback.get("trigger") == "sxcpinup_coloredpencil", "Generation profile parser lost default trigger")
def smoke_filter_config_policy() -> None:
_expect(pb.ETHNICITY_FILTER_CHOICES is filter_config.ETHNICITY_FILTER_CHOICES, "Prompt builder ethnicity choices are not delegated")
_expect("french_european" in filter_config.ETHNICITY_LIST_KEYS, "Ethnicity list keys lost regional choices")
advanced = json.loads(
pb.build_filter_config_json(
include_european=True,
include_mediterranean_mena=False,
include_latina=False,
include_east_asian=False,
include_southeast_asian=False,
include_south_asian=False,
include_black_african=True,
include_indigenous=False,
include_mixed=False,
include_plus_size=False,
figure="bad",
)
)
_expect(advanced.get("ethnicity_includes") == ["european", "black_african"], "Advanced filter selected ethnicity list changed")
_expect("exclude_latina" in advanced.get("ethnicity", ""), "Advanced filter ethnicity excludes changed")
_expect(advanced.get("figure") == "curvy", "Advanced filter invalid figure fallback changed")
_expect(advanced.get("no_plus_women") is True, "Advanced filter plus-size exclusion changed")
ethnicity_list = pb.build_ethnicity_list_json(include_french_european=True, include_asian=True, strict_excludes=True)
_expect("french_european" in ethnicity_list["ethnicity"], "Ethnicity list lost regional include")
_expect("asian" in ethnicity_list["ethnicity"], "Ethnicity list lost umbrella Asian include")
_expect("exclude_european" not in ethnicity_list["ethnicity"], "Ethnicity list should protect European when regional Europe is selected")
_expect("exclude_east_asian" not in ethnicity_list["ethnicity"], "Ethnicity list should protect East Asian when Asian is selected")
_expect("filter_config" in ethnicity_list, "Ethnicity list lost filter_config output")
parsed_text = pb._parse_filter_config("french_european")
_expect(parsed_text.get("ethnicity") == "french_european", "Filter parser text shortcut changed")
parsed_bad = filter_config.parse_filter_config({"ethnicity": "bad", "figure": "bad"})
_expect(parsed_bad.get("ethnicity") == "any", "Filter parser invalid ethnicity fallback changed")
_expect(parsed_bad.get("figure") == "curvy", "Filter parser invalid figure fallback changed")
_expect(pb.normalize_ethnicity_filter("random", "any", allow_random=True) == "random", "Ethnicity random normalization changed")
_expect(pb.normalize_ethnicity_filter("random", "any", allow_random=False) == "any", "Ethnicity default normalization changed")
def smoke_category_library_route() -> None:
categories = category_library.load_category_library()
_expect(len(categories) >= 3, "category library should load JSON categories")
@@ -2529,6 +2570,7 @@ SMOKE_CASES: list[tuple[str, Callable[[], None]]] = [
("location_config_policy", smoke_location_config_policy),
("category_cast_config_policy", smoke_category_cast_config_policy),
("generation_profile_config_policy", smoke_generation_profile_config_policy),
("filter_config_policy", smoke_filter_config_policy),
("category_library_route", smoke_category_library_route),
("hardcore_category_routes", smoke_hardcore_category_routes),
("krea_close_foreplay_route", smoke_krea_close_foreplay_route),