Browse Source

test: add mocked loudnorm to TestLAFE

main
Rob Hallam 3 months ago
parent
commit
fb8f3270e5
1 changed files with 19 additions and 0 deletions
  1. +19
    -0
      test/test_feature_extractors.py

+ 19
- 0
test/test_feature_extractors.py View File

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


class TestLoudAudioFeatureExtractor(unittest.TestCase): class TestLoudAudioFeatureExtractor(unittest.TestCase):
"""Test LoudAudioFeatureExtractor""" """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): def test_init(self):
video_source = TestSourceMedia().one_colour_silent_audio() video_source = TestSourceMedia().one_colour_silent_audio()
test_extractor = extractors.LoudAudioFeatureExtractor(input_files=video_source) test_extractor = extractors.LoudAudioFeatureExtractor(input_files=video_source)
@@ -174,6 +181,18 @@ class TestLoudAudioFeatureExtractor(unittest.TestCase):
test_extractor.teardown() test_extractor.teardown()
self.assertEqual(test_extractor.features, []) 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): class TestVideoActivityFeatureExtractor(unittest.TestCase):
"""Test VideoActivityFeatureExtractor""" """Test VideoActivityFeatureExtractor"""




Loading…
Cancel
Save