Extract row subject route policy
This commit is contained in:
@@ -60,6 +60,7 @@ import row_location # noqa: E402
|
||||
import row_pools # noqa: E402
|
||||
import row_rendering # noqa: E402
|
||||
import row_route_metadata # noqa: E402
|
||||
import row_subject_route # noqa: E402
|
||||
import server_routes # noqa: E402
|
||||
import sdxl_formatter # noqa: E402
|
||||
import sdxl_presets # noqa: E402
|
||||
@@ -1061,6 +1062,84 @@ def smoke_category_cast_config_policy() -> None:
|
||||
_expect((empty_cast.get("women_count"), empty_cast.get("men_count")) == (1, 0), "Empty custom cast was not corrected")
|
||||
|
||||
|
||||
def smoke_row_subject_route_policy() -> None:
|
||||
seed_cfg = seed_config.parse_seed_config({})
|
||||
slot_cast = pb.build_character_slot_json(
|
||||
subject_type="woman",
|
||||
label="A",
|
||||
age="32-year-old adult",
|
||||
ethnicity="western_european",
|
||||
figure="balanced",
|
||||
body="slim",
|
||||
hair="short silver bob",
|
||||
eyes="gray eyes",
|
||||
descriptor_detail="full",
|
||||
)["character_cast"]
|
||||
profile = {
|
||||
"profile_type": "character",
|
||||
"subject_type": "woman",
|
||||
"age": "45-year-old adult",
|
||||
"body": "average",
|
||||
"body_phrase": "average figure",
|
||||
"skin": "profile skin",
|
||||
"hair": "profile hair",
|
||||
"eyes": "profile eyes",
|
||||
}
|
||||
route = row_subject_route.resolve_subject_route(
|
||||
subject_type="woman",
|
||||
seed_config=seed_cfg,
|
||||
seed=501,
|
||||
row_number=1,
|
||||
ethnicity="any",
|
||||
figure="balanced",
|
||||
no_plus_women=False,
|
||||
no_black=False,
|
||||
women_count=1,
|
||||
men_count=0,
|
||||
character_profile=profile,
|
||||
character_cast=slot_cast,
|
||||
)
|
||||
delegated = pb._subject_route(
|
||||
subject_type="woman",
|
||||
seed_config=seed_cfg,
|
||||
seed=501,
|
||||
row_number=1,
|
||||
ethnicity="any",
|
||||
figure="balanced",
|
||||
no_plus_women=False,
|
||||
no_black=False,
|
||||
women_count=1,
|
||||
men_count=0,
|
||||
character_profile=profile,
|
||||
character_cast=slot_cast,
|
||||
)
|
||||
_expect(delegated == route, "Prompt builder subject route should delegate to row_subject_route")
|
||||
_expect(route["subject_type"] == "woman", "Subject route changed single-woman subject type")
|
||||
_expect(route["character_slot_status"] == "applied:Woman A", "Subject route did not apply matching Woman A slot")
|
||||
_expect(route["character_profile_status"] == "skipped_character_slot", "Subject route should skip profile when slot applies")
|
||||
_expect(route["context"].get("age") == "32-year-old adult", "Subject route lost slot age override")
|
||||
_expect(route["context"].get("hair") == "short silver bob", "Subject route lost slot hair override")
|
||||
_expect(route["applied_profile"] == {}, "Subject route should not apply profile over matching slot")
|
||||
|
||||
cast_route = row_subject_route.resolve_subject_route(
|
||||
subject_type="configured_cast",
|
||||
seed_config=seed_cfg,
|
||||
seed=502,
|
||||
row_number=1,
|
||||
ethnicity="western_european",
|
||||
figure="balanced",
|
||||
no_plus_women=False,
|
||||
no_black=False,
|
||||
women_count=1,
|
||||
men_count=1,
|
||||
character_cast=_character_cast(pov_man=True),
|
||||
)
|
||||
_expect(cast_route["subject_type"] == "configured_cast", "Configured-cast subject route changed subject type")
|
||||
_expect(cast_route["pov_character_labels"] == ["Man A"], "Subject route lost configured-cast POV man label")
|
||||
_expect("Woman A:" in cast_route["cast_descriptor_text"], "Subject route lost visible woman descriptor")
|
||||
_expect("Man A:" not in cast_route["cast_descriptor_text"], "Subject route should not describe POV man as visible cast")
|
||||
|
||||
|
||||
def smoke_generation_profile_config_policy() -> None:
|
||||
_expect(
|
||||
pb.GENERATION_PROFILE_PRESETS is generation_profile_config.GENERATION_PROFILE_PRESETS,
|
||||
@@ -4313,6 +4392,7 @@ SMOKE_CASES: list[tuple[str, Callable[[], None]]] = [
|
||||
("row_generation_policy", smoke_row_generation_policy),
|
||||
("category_extensions_policy", smoke_category_extensions_policy),
|
||||
("category_cast_config_policy", smoke_category_cast_config_policy),
|
||||
("row_subject_route_policy", smoke_row_subject_route_policy),
|
||||
("generation_profile_config_policy", smoke_generation_profile_config_policy),
|
||||
("filter_config_policy", smoke_filter_config_policy),
|
||||
("character_config_policy", smoke_character_config_policy),
|
||||
|
||||
Reference in New Issue
Block a user