- Added test_descript.py to test the DecodeTranscriptNode class.
- Added test_video.py to test the ImageStackToVideoFile class. - Both tests ensure the functionality and correctness of the respective classes.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
from unittest import TestCase
|
||||
|
||||
|
||||
class TestDecodeTranscriptNode(TestCase):
|
||||
def test_func(self):
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.descript import DecodeTranscriptNode
|
||||
node = DecodeTranscriptNode()
|
||||
string = """[00:00:00] jackie: Let's talk about a
|
||||
|
||||
[00:00:01] jackie: thing\n\n[00:00:05] jackie: Let's talk about an apple
|
||||
|
||||
"""
|
||||
speakers, durations, paragraphs = node.func(string)
|
||||
self.assertEqual(speakers, ["jackie", "jackie", "jackie"])
|
||||
self.assertEqual(durations, [1, 4, 2])
|
||||
self.assertEqual(paragraphs, ["Let's talk about a", 'thing', "Let's talk about an apple"])
|
||||
@@ -0,0 +1,28 @@
|
||||
from unittest import TestCase
|
||||
import os
|
||||
import torch
|
||||
|
||||
|
||||
class TestImageStackToVideoFile(TestCase):
|
||||
def test_handler(self):
|
||||
# test with random frames of noise
|
||||
import numpy as np
|
||||
from custom_nodes.EternalKernelLiteGraphNodes.video import ImageStackToVideoFile
|
||||
|
||||
# create a random stack of images
|
||||
stack = np.random.randint(0, 255, (100, 100, 100, 3), dtype=np.uint8)
|
||||
# it expects a tensor
|
||||
stack = torch.from_numpy(stack)
|
||||
# create the node
|
||||
node = ImageStackToVideoFile()
|
||||
# run the node
|
||||
node.handler(image_stack=stack, video_out="test.mp4")
|
||||
# check that the file exists
|
||||
# find the actual filepath for the generated file, will be ../../../video/test.mp4
|
||||
test_video_file_fullpath = os.path.join(
|
||||
os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))), "video",
|
||||
"test.mp4")
|
||||
|
||||
self.assertTrue(os.path.exists(test_video_file_fullpath))
|
||||
# remove the file
|
||||
os.remove(test_video_file_fullpath)
|
||||
Reference in New Issue
Block a user