Ver código fonte

test: add mocked loudnorm to TestLAFE

main
Rob Hallam 3 meses atrás
pai
commit
fb8f3270e5
1 arquivos alterados com 19 adições e 0 exclusões
  1. +19
    -0
      test/test_feature_extractors.py

+ 19
- 0
test/test_feature_extractors.py Ver arquivo

@@ -155,6 +155,13 @@ class TestRandomFeatureExtractor(unittest.TestCase):

class TestLoudAudioFeatureExtractor(unittest.TestCase):
"""Test LoudAudioFeatureExtractor"""
def _mock_loudnorm(self, *args, **kwargs):
"""Mock _loudnorm

It returns a list of 2-tuple floats (time, loudness) representing loud audio instances
"""
return [(0.0, 0.0), (1.0, 1.0), (2.0, 2.0), (3.0, 3.0), (4.0, 4.0)]

def test_init(self):
video_source = TestSourceMedia().one_colour_silent_audio()
test_extractor = extractors.LoudAudioFeatureExtractor(input_files=video_source)
@@ -174,6 +181,18 @@ class TestLoudAudioFeatureExtractor(unittest.TestCase):
test_extractor.teardown()
self.assertEqual(test_extractor.features, [])

def test_extract_mocked_loudnorm(self):
"""Test extract with mocked loudness detection"""
video_source = TestSourceMedia().one_colour_silent_audio()
test_extractor = extractors.LoudAudioFeatureExtractor(input_files=video_source)
test_extractor._loudnorm = self._mock_loudnorm
test_extractor.setup()
test_extractor.run()
test_extractor.teardown()
self.assertEqual(len(test_extractor.features), 5)

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

class TestVideoActivityFeatureExtractor(unittest.TestCase):
"""Test VideoActivityFeatureExtractor"""



Carregando…
Cancelar
Salvar