瀏覽代碼

test: update mocket get_loudnesses & test _keep_num

main
Rob Hallam 2 月之前
父節點
當前提交
c53704cf7c
共有 1 個文件被更改,包括 20 次插入2 次删除
  1. +20
    -2
      test/test_feature_extractors.py

+ 20
- 2
test/test_feature_extractors.py 查看文件

@@ -220,15 +220,33 @@ class TestLoudAudioFeatureExtractor(unittest.TestCase):
self.assertEqual(len(test_extractor.features), 5)

def test_extract_mocked_get_loudnesses(self):
"""Test extract with mocked loudness detection"""
"""Test extract with mocked loudness detection - 100 loudnesses generated"""
video_source = TestSourceMedia().one_colour_silent_audio()
test_extractor = extractors.LoudAudioFeatureExtractor(input_files=video_source)
test_extractor = extractors.LoudAudioFeatureExtractor(input_files=video_source, num_features=100)
test_extractor._get_loudnesses = self._mock_get_loudnessess
test_extractor.setup()
test_extractor.run()
test_extractor.teardown()
self.assertEqual(len(test_extractor.features), 100)

def test_keep_num(self):
"""Test keep_num correctly keeps 5 / 10"""
video_source = TestSourceMedia().one_colour_silent_audio()
with self.subTest("keep 5 (default)"):
test_extractor = extractors.LoudAudioFeatureExtractor(input_files=video_source)
test_extractor._get_loudnesses = self._mock_get_loudnessess
test_extractor.setup()
test_extractor.run()
test_extractor.teardown()
self.assertEqual(len(test_extractor.features), 5)
with self.subTest("keep 10"):
test_extractor = extractors.LoudAudioFeatureExtractor(input_files=video_source, num_features=10)
test_extractor._get_loudnesses = self._mock_get_loudnessess
test_extractor.setup()
test_extractor.run()
test_extractor.teardown()
self.assertEqual(len(test_extractor.features), 10)

# TODO: add sample video with loud audio to test _loudnessdetect()

class TestVideoActivityFeatureExtractor(unittest.TestCase):


Loading…
取消
儲存