Test locally installed roles instead of asserting bundled role names (review F1)

Role files are user-provided and gitignored; the old TestShippedRoles
failed on any checkout without the private role set. Bump to 1.3.3.
This commit is contained in:
BRADSEC
2026-07-03 10:48:39 +10:00
parent 441659c936
commit 5924d8ce43
3 changed files with 13 additions and 12 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ cd ComfyUI_LLMSetRole
python -m unittest test_set_role -v
```
Expect 17 passing tests (title parsing, filename prettify, label-collision disambiguation, path-traversal rejection, missing-file error, edit hot-reload, bad-encoding tolerance, role resolution, shipped-role discovery).
Expect 16 tests (title parsing, filename prettify, label-collision disambiguation, path-traversal rejection, missing-file error, edit hot-reload, bad-encoding tolerance, role resolution, local-role validation). The local-role test skips when roles/ has no .md files.
### In ComfyUI
+1 -1
View File
@@ -1,7 +1,7 @@
[project]
name = "comfyui_llmsetrole"
description = "Pick an LLM role (system prompt) from a dropdown and output it as a STRING for an LLM node's system_prompt. Use the role widget's control_after_generate to step (increment wrap) or randomize roles across a batch. Roles are plain Markdown files in roles/; add a .md file and restart to add a role. Node name: Set Role. Located under Add Node > LLM."
version = "1.3.2"
version = "1.3.3"
license = { file = "LICENSE" }
requires-python = ">=3.10"
dependencies = []
+11 -10
View File
@@ -152,18 +152,19 @@ class TestResolve(unittest.TestCase):
core.resolve("Definitely Not A Real Role")
class TestShippedRoles(unittest.TestCase):
def test_shipped_roles_present(self):
core._load_cached.cache_clear()
labels = dict((lbl, fn) for lbl, fn in core.list_roles())
self.assertIn("Photo Professional", labels)
self.assertIn("Photo Selfie", labels)
class TestLocalRoles(unittest.TestCase):
"""Role files are user-provided (roles/ is gitignored); validate whatever
is installed locally instead of asserting specific bundled names."""
def test_apply_returns_body_and_title(self):
def test_installed_roles_all_apply(self):
core._load_cached.cache_clear()
body, title = core.apply_role("Photo Professional")
self.assertEqual(title, "Photo Professional")
self.assertTrue(body.strip())
roles = core.list_roles()
if not roles:
self.skipTest("no role files installed in roles/")
for label, _fn in roles:
body, title = core.apply_role(label)
self.assertEqual(title, label)
self.assertTrue(body.strip(), f"role {label!r} has empty body")
if __name__ == "__main__":