From 5924d8ce439932b262aad9b3f7bcb68faac1cf46 Mon Sep 17 00:00:00 2001 From: BRADSEC <7948876+bradsec@users.noreply.github.com> Date: Fri, 3 Jul 2026 10:48:39 +1000 Subject: [PATCH] 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. --- README.md | 2 +- pyproject.toml | 2 +- test_set_role.py | 21 +++++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 3eefeba..9f1cab5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 9456507..f7e9d1f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 = [] diff --git a/test_set_role.py b/test_set_role.py index 3ee82a6..c616a59 100644 --- a/test_set_role.py +++ b/test_set_role.py @@ -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__":