-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest_main.py
More file actions
43 lines (32 loc) · 1.36 KB
/
test_main.py
File metadata and controls
43 lines (32 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import shutil
import pytest
from config import *
from main import extract_frames, extract_audio
@pytest.fixture(scope="module")
def video_path():
return os.path.join(DOWNLOAD_PATH, VIDEO_FILENAME)
@pytest.fixture(autouse=True)
def cleanup():
TEST_ROOT = 'test'
# Clean up test directory before testing
if os.path.exists(TEST_ROOT):
shutil.rmtree(TEST_ROOT)
yield
# Clean up after testing
if os.path.exists(TEST_ROOT):
shutil.rmtree(TEST_ROOT)
def test_extract_frames_1s(video_path):
extract_frames(video_path, TEST_FRAMES_DIR, 1)
assert os.path.exists(TEST_FRAMES_DIR)
frames = [f for f in os.listdir(TEST_FRAMES_DIR) if f.endswith('.jpg') or f.endswith('.png')]
assert len(frames) == 25, "Incorrect number of frames for 1s interval"
def test_extract_frames_5s(video_path):
extract_frames(video_path, TEST_FRAMES_DIR, 5)
assert os.path.exists(TEST_FRAMES_DIR)
frames = [f for f in os.listdir(TEST_FRAMES_DIR) if f.endswith('.jpg') or f.endswith('.png')]
assert len(frames) == 5, "Incorrect number of frames for 5s interval"
def test_extract_audio(video_path):
output_path = os.path.join(TEST_AUDIO_DIR, AUDIO_FILENAME)
extract_audio(video_path, output_path)
assert os.path.exists(output_path), "Audio file not created"
assert os.path.getsize(output_path) > 0, "Audio file is empty"