Extract row text field resolution
This commit is contained in:
@@ -1714,6 +1714,37 @@ def smoke_row_rendering_policy() -> None:
|
||||
row_rendering.prompt_template_for({}, {}, {}, "group") == row_rendering.GROUP_TEMPLATE,
|
||||
"Row rendering default group template changed",
|
||||
)
|
||||
category_text = {
|
||||
"name": "Category Label",
|
||||
"negative_prompt": "category negative",
|
||||
"positive_suffix": "category suffix",
|
||||
"style": "category style",
|
||||
"item_label": "Category Item",
|
||||
}
|
||||
subcategory_text = {
|
||||
"negative_prompt": "subcategory negative",
|
||||
"positive_suffix": "subcategory suffix",
|
||||
"style": "subcategory style",
|
||||
}
|
||||
item_text = {
|
||||
"negative_prompt": "item negative",
|
||||
"style": "item style",
|
||||
}
|
||||
_expect(
|
||||
pb._row_text_fields(category_text, subcategory_text, item_text)
|
||||
== row_rendering.resolve_row_text_fields(category_text, subcategory_text, item_text),
|
||||
"Prompt builder row text field wrapper should delegate to row_rendering",
|
||||
)
|
||||
text_fields = row_rendering.resolve_row_text_fields(category_text, subcategory_text, item_text)
|
||||
_expect(text_fields.negative_prompt == "item negative", "Row text fields did not prefer item negative prompt")
|
||||
_expect(text_fields.positive_suffix == "subcategory suffix", "Row text fields did not prefer subcategory suffix")
|
||||
_expect(text_fields.style == "item style", "Row text fields did not prefer item style")
|
||||
_expect(text_fields.item_label == "Category Item", "Row text fields did not fall back to category item label")
|
||||
default_text_fields = row_rendering.resolve_row_text_fields({"name": "Default Category"}, {}, {})
|
||||
_expect(default_text_fields.negative_prompt, "Row text fields lost default negative prompt")
|
||||
_expect(default_text_fields.positive_suffix == row_rendering.GENERIC_POSITIVE_SUFFIX, "Row text fields lost suffix default")
|
||||
_expect(default_text_fields.style == row_rendering.DEFAULT_STYLE, "Row text fields lost style default")
|
||||
_expect(default_text_fields.item_label == "Default Category", "Row text fields lost category-name label default")
|
||||
|
||||
context = {
|
||||
"trigger": Trigger,
|
||||
|
||||
Reference in New Issue
Block a user