Compare commits

..
Author SHA1 Message Date
asagi4 c39605eec4 Gah, tests broke.
I hate mocking
2025-03-10 21:38:03 +02:00
asagi4 dc62e638ed How on earth does this syntax work 2025-03-10 20:30:38 +02:00
asagi4 109cac16ef ... 2025-03-10 20:27:07 +02:00
asagi4 cf6c2b3e6a Fix github actions 2025-03-10 20:22:36 +02:00
4 changed files with 22 additions and 18 deletions
+2 -2
View File
@@ -10,8 +10,8 @@ on:
jobs:
tests:
uses: ./.github/workflows/tests.yml
tests_with_comfy:
uses: ./.github/workflows/tests_with_comfy.yml
#tests_with_comfy:
# uses: ./.github/workflows/tests_with_comfy.yml
publish-node:
name: Publish Custom Node to registry
runs-on: ubuntu-latest
+6 -6
View File
@@ -1,11 +1,11 @@
name: Run tests requiring ComfyUI
on:
- workflow_call
- workflow_dispatch
- push:
paths:
- prompt_control/nodes_lazy.py
- prompt_control/utils.py
workflow_call:
workflow_dispatch:
push:
paths:
- prompt_control/nodes_lazy.py
- prompt_control/utils.py
jobs:
+2 -1
View File
@@ -1,6 +1,7 @@
import logging
from .parser import parse_prompt_schedules
from comfy_execution.graph_utils import GraphBuilder, is_link
from comfy_execution.graph import ExecutionBlocker
from .utils import get_function
@@ -155,9 +156,9 @@ class PCLazyLoraLoaderAdvanced:
def INPUT_TYPES(s):
return {
"required": {
"text": ("STRING", {"multiline": True}),
"model": ("MODEL", {"rawLink": True}),
"clip": ("CLIP", {"rawLink": True}),
"text": ("STRING", {"multiline": True}),
},
"optional": {
"apply_hooks": ("BOOLEAN", {"default": True}),
+12 -9
View File
@@ -1,5 +1,8 @@
import unittest
import unittest.mock as mock
import logging
log = logging.getLogger("comfyui-prompt-control")
def find_file(name):
@@ -7,10 +10,11 @@ def find_file(name):
return names.get(name)
@mock.patch("prompt_control.utils.lora_name_to_file", find_file)
@mock.patch.dict("sys.modules", nodes=mock.MagicMock())
class GraphTests(unittest.TestCase):
maxDiff = 4096
@mock.patch("prompt_control.utils.lora_name_to_file", find_file)
def test_textencode(self):
clip = [0, 0]
from .nodes_lazy import PCLazyTextEncode, PCLazyTextEncodeAdvanced
@@ -73,18 +77,17 @@ class GraphTests(unittest.TestCase):
model = [0, 1]
clip = [0, 0]
with self.assertLogs("comfyui-prompt-control", level="WARNING") as cm:
result = PCLazyLoraLoader().apply(model, clip, "prompt here <lora:nonexistent:1.0:0.5>", "UID")["expand"]
with self.assertLogs(log, level="WARNING") as cm:
result = PCLazyLoraLoader().apply("UID", model, clip, "prompt here <lora:nonexistent:1.0:0.5>")["expand"]
result_adv = PCLazyLoraLoaderAdvanced().apply(model, clip, "prompt here <lora:nonexistent:1.0:0.5>", "UID")[
"expand"
]
self.assertIn("LoRA 'nonexistent' not found", cm.output[0])
self.assertIn("LoRA 'nonexistent' not found", cm.output[1])
self.assertEqual(result, {})
self.assertEqual(result_adv, {})
result = PCLazyLoraLoader().apply(model, clip, "<lora:test:1>", "UID")["expand"]
result2 = PCLazyLoraLoader().apply(model, clip, "prompt here <lora:test:1.0:0.5><lora:test:0:0.5>", "UID")[
result = PCLazyLoraLoader().apply("UID", model, clip, "<lora:test:1>")["expand"]
result2 = PCLazyLoraLoader().apply("UID", model, clip, "prompt here <lora:test:1.0:0.5><lora:test:0:0.5>")[
"expand"
]
result3 = PCLazyLoraLoaderAdvanced().apply(
@@ -107,7 +110,7 @@ class GraphTests(unittest.TestCase):
}
},
)
result = PCLazyLoraLoader().apply(model, clip, "<lora:test:1><lora:other:0.5>", "UID")["expand"]
result = PCLazyLoraLoader().apply("UID", model, clip, "<lora:test:1><lora:other:0.5>")["expand"]
self.assertEqual(
result,
{
@@ -134,7 +137,7 @@ class GraphTests(unittest.TestCase):
},
)
result = PCLazyLoraLoader().apply(model, clip, "prompt here <lora:test:1.0:0.5>", "UID")["expand"]
result = PCLazyLoraLoader().apply("UID", model, clip, "prompt here <lora:test:1.0:0.5>")["expand"]
self.assertEqual(
result,
{
@@ -151,7 +154,7 @@ class GraphTests(unittest.TestCase):
},
)
result = PCLazyLoraLoader().apply(model, clip, "prompt [<lora:test:0.5>:0.5]", "UID")["expand"]
result = PCLazyLoraLoader().apply("UID", model, clip, "prompt [<lora:test:0.5>:0.5]")["expand"]
result2 = PCLazyLoraLoaderAdvanced().apply(model, clip, "prompt [<lora:test:0.5>:0.5]", "UID")["expand"]
self.assertEqual(result, result2)
expected = {