Wire H3 long videos to plan scene refs
This commit is contained in:
@@ -18,6 +18,11 @@ class DumasH3LongVideosHelperTests(unittest.TestCase):
|
||||
"comfy.nested_tensor",
|
||||
"comfy.model_management",
|
||||
"node_helpers",
|
||||
"numpy",
|
||||
"PIL",
|
||||
"PIL.Image",
|
||||
"folder_paths",
|
||||
"dumas_image_nodes",
|
||||
"dumas_h3_longvideos",
|
||||
)
|
||||
}
|
||||
@@ -26,6 +31,17 @@ class DumasH3LongVideosHelperTests(unittest.TestCase):
|
||||
cuda=types.SimpleNamespace(OutOfMemoryError=RuntimeError),
|
||||
float32="float32",
|
||||
)
|
||||
fake_numpy = types.SimpleNamespace(
|
||||
clip=lambda array, _low, _high: array,
|
||||
uint8="uint8",
|
||||
)
|
||||
fake_pil_image_module = types.SimpleNamespace(fromarray=lambda _array: None)
|
||||
fake_pil_module = types.SimpleNamespace(Image=fake_pil_image_module)
|
||||
fake_folder_paths = types.SimpleNamespace(
|
||||
get_temp_directory=lambda: "/tmp",
|
||||
get_output_directory=lambda: "/tmp",
|
||||
get_save_image_path=lambda prefix, _out, _width, _height: ("/tmp", prefix, 1, "", prefix),
|
||||
)
|
||||
fake_nodes = types.SimpleNamespace(common_ksampler=lambda *args, **kwargs: ({},))
|
||||
fake_comfy_samplers = types.SimpleNamespace(
|
||||
KSampler=types.SimpleNamespace(SAMPLERS=("res_multistep",), SCHEDULERS=("simple",))
|
||||
@@ -48,6 +64,10 @@ class DumasH3LongVideosHelperTests(unittest.TestCase):
|
||||
)
|
||||
|
||||
sys.modules["torch"] = fake_torch
|
||||
sys.modules["numpy"] = fake_numpy
|
||||
sys.modules["PIL"] = fake_pil_module
|
||||
sys.modules["PIL.Image"] = fake_pil_image_module
|
||||
sys.modules["folder_paths"] = fake_folder_paths
|
||||
sys.modules["nodes"] = fake_nodes
|
||||
sys.modules["comfy"] = fake_comfy
|
||||
sys.modules["comfy.utils"] = fake_comfy_utils
|
||||
@@ -56,6 +76,7 @@ class DumasH3LongVideosHelperTests(unittest.TestCase):
|
||||
sys.modules["comfy.model_management"] = fake_mm
|
||||
sys.modules["node_helpers"] = types.SimpleNamespace()
|
||||
|
||||
cls.image_module = importlib.import_module("dumas_image_nodes")
|
||||
cls.module = importlib.import_module("dumas_h3_longvideos")
|
||||
|
||||
@classmethod
|
||||
@@ -176,6 +197,33 @@ class DumasH3LongVideosHelperTests(unittest.TestCase):
|
||||
|
||||
for index in range(1, 10):
|
||||
self.assertIn(f"ref_image_{index}", optional)
|
||||
self.assertIn("plan", optional)
|
||||
self.assertIn("plan_scene_index", optional)
|
||||
|
||||
def test_plan_scene_refs_reads_bound_images(self):
|
||||
attach = self.image_module.DumasH3PlanAttachSceneImagesNode()
|
||||
plan = {"shots": [{"id": "one"}, {"id": "two"}]}
|
||||
image2 = object()
|
||||
image7 = object()
|
||||
|
||||
plan, _ = attach.attach(plan=plan, scene_index=2, image2=image2, image7=image7)
|
||||
refs = self.module._plan_scene_refs(plan, 2)
|
||||
|
||||
self.assertEqual(len(refs), 9)
|
||||
self.assertIsNone(refs[0])
|
||||
self.assertIs(refs[1], image2)
|
||||
self.assertIs(refs[6], image7)
|
||||
|
||||
def test_merge_ref_slots_prefers_direct_refs_over_plan_refs(self):
|
||||
merged = self.module._merge_ref_slots(
|
||||
(None, "direct2", None, None, "direct5", None, None, None, None),
|
||||
("plan1", "plan2", "plan3", None, "plan5", None, "plan7", None, None),
|
||||
)
|
||||
|
||||
self.assertEqual(
|
||||
merged,
|
||||
("plan1", "direct2", "plan3", None, "direct5", None, "plan7", None, None),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user