|
|
@@ -10,6 +10,7 @@ import pytest |
|
|
|
import pipeline.feature_extractors as extractors |
|
|
|
|
|
|
|
from pipeline.utils import Source, SourceMedia # technically makes this an integration test, but... |
|
|
|
from test.mocks import MockFeature, MockInterval |
|
|
|
|
|
|
|
class TestSource(): |
|
|
|
"""Provide utils.Source for testing""" |
|
|
@@ -265,6 +266,21 @@ class TestLoudAudioFeatureExtractor(unittest.TestCase): |
|
|
|
for feature in test_extractor.features: |
|
|
|
self.assertGreaterEqual(feature.interval.duration, min_duration) |
|
|
|
|
|
|
|
# test trim_overlap |
|
|
|
with self.subTest("trim_overlap"): |
|
|
|
test_extractor = extractors.LoudAudioFeatureExtractor(input_files=video_source, |
|
|
|
min_duration=0, |
|
|
|
num_features=10) |
|
|
|
|
|
|
|
feature1 = MockFeature(interval=MockInterval(start=25, end=75)) |
|
|
|
# mock feature1's interval .overlaps() method to always return True |
|
|
|
feature1.interval.overlaps = lambda x: True |
|
|
|
feature2 = MockFeature(interval=MockInterval(start=50, end=100)) # overlap |
|
|
|
feature2.interval.overlaps = lambda x: True |
|
|
|
features = [feature1, feature2] |
|
|
|
keep_features = test_extractor._keep_num(features,num=5, trim_overlap=True) |
|
|
|
self.assertEqual(len(keep_features), 1) |
|
|
|
|
|
|
|
# TODO: add sample video with loud audio to test _loudnessdetect() |
|
|
|
|
|
|
|
class TestVideoActivityFeatureExtractor(unittest.TestCase): |
|
|
|