From 906fec459ef837b31bc459a7fcbe09cc25ffe8d4 Mon Sep 17 00:00:00 2001 From: Tasha Upchurch Date: Sun, 18 Jun 2023 20:33:31 -0400 Subject: [PATCH] - 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. --- tests/test_descript.py | 16 ++++++++++++++++ tests/test_video.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 tests/test_descript.py create mode 100644 tests/test_video.py diff --git a/tests/test_descript.py b/tests/test_descript.py new file mode 100644 index 0000000..14e0925 --- /dev/null +++ b/tests/test_descript.py @@ -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"]) \ No newline at end of file diff --git a/tests/test_video.py b/tests/test_video.py new file mode 100644 index 0000000..dc02998 --- /dev/null +++ b/tests/test_video.py @@ -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)