Files
comfyui_o1key/tests/test_auto_red_cast.py
Jony ba920f2b66 Publish current ComfyUI O1Key code baseline
Replace the prior release tree with the current plugin, frontend, tests, and documentation. Document retired node IDs and the public Gitea update source.
2026-09-24 19:56:48 +08:00

47 lines
1.5 KiB
Python

"""Offline coverage for the native seed on the red-cast correction node."""
import sys
import unittest
from pathlib import Path
import torch
PLUGIN_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(PLUGIN_ROOT.parent))
from comfyui_o1key.nodes.auto_red_cast import O1keyAutoRedCast # noqa: E402
class AutoRedCastSeedTests(unittest.TestCase):
def test_schema_exposes_native_seed_as_final_widget(self):
inputs = O1keyAutoRedCast.INPUT_TYPES()
required = inputs["required"]
self.assertEqual(
list(required),
["强度", "最大校正量", "高饱和保护", "图片路径"],
)
self.assertEqual(
list(inputs["optional"]),
["图像", "灰卡最低亮度", "灰卡最大色度", "seed"],
)
kind, options = inputs["optional"]["seed"]
self.assertEqual(kind, "INT")
self.assertEqual(options["default"], 0)
self.assertEqual(options["max"], 0xFFFFFFFFFFFFFFFF)
self.assertTrue(options["control_after_generate"])
def test_seed_is_accepted_without_changing_deterministic_correction(self):
image = torch.full((1, 40, 40, 3), 0.7)
image[..., 0] = 0.75
node = O1keyAutoRedCast()
first = node.correct(图像=image, seed=0)
second = node.correct(图像=image, seed=1234)
self.assertTrue(torch.equal(first[0], second[0]))
self.assertTrue(torch.equal(first[1], second[1]))
self.assertEqual(first[2], second[2])
if __name__ == "__main__":
unittest.main(verbosity=2)