|
@@ -337,8 +337,8 @@ class TestWordFeatureExtractor(unittest.TestCase): |
|
|
test_extractor.teardown() |
|
|
test_extractor.teardown() |
|
|
self.assertEqual(test_extractor.features, []) |
|
|
self.assertEqual(test_extractor.features, []) |
|
|
|
|
|
|
|
|
def test_extract_mocked_transcribe(self): |
|
|
|
|
|
"""Mock out the actual call to transcribe""" |
|
|
|
|
|
|
|
|
def test_extract_mocked_transcribe_matching_words(self): |
|
|
|
|
|
"""Mock out the actual call to transcribe but match all words in the sentence""" |
|
|
video_source = TestSourceMedia().one_colour_silent_audio() |
|
|
video_source = TestSourceMedia().one_colour_silent_audio() |
|
|
test_extractor = extractors.WordFeatureExtractor(input_files=video_source) |
|
|
test_extractor = extractors.WordFeatureExtractor(input_files=video_source) |
|
|
# mock _transcribe and mock out model and batched pipeline for speed |
|
|
# mock _transcribe and mock out model and batched pipeline for speed |
|
@@ -352,3 +352,33 @@ class TestWordFeatureExtractor(unittest.TestCase): |
|
|
|
|
|
|
|
|
self.assertEqual(len(test_extractor.features), 9) |
|
|
self.assertEqual(len(test_extractor.features), 9) |
|
|
|
|
|
|
|
|
|
|
|
def test_extract_mocked_transcribe_no_matching_words(self): |
|
|
|
|
|
"""Mock out the actual call to transcribe but match no words in the sentence""" |
|
|
|
|
|
video_source = TestSourceMedia().one_colour_silent_audio() |
|
|
|
|
|
test_extractor = extractors.WordFeatureExtractor(input_files=video_source) |
|
|
|
|
|
# mock _transcribe and mock out model and batched pipeline for speed |
|
|
|
|
|
test_extractor._transcribe = self.mock_transcribe |
|
|
|
|
|
test_extractor._model = MagicMock() |
|
|
|
|
|
test_extractor._batched_model = MagicMock() |
|
|
|
|
|
# set up and run the extractor |
|
|
|
|
|
test_extractor.setup(words=["nonexistentword"]) |
|
|
|
|
|
test_extractor.run() |
|
|
|
|
|
test_extractor.teardown() |
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(len(test_extractor.features), 0) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_extract_mocked_transcribe_some_matching_words(self): |
|
|
|
|
|
"""Mock out the actual call to transcribe but match some words in the sentence""" |
|
|
|
|
|
video_source = TestSourceMedia().one_colour_silent_audio() |
|
|
|
|
|
test_extractor = extractors.WordFeatureExtractor(input_files=video_source) |
|
|
|
|
|
# mock _transcribe and mock out model and batched pipeline for speed |
|
|
|
|
|
test_extractor._transcribe = self.mock_transcribe |
|
|
|
|
|
test_extractor._model = MagicMock() |
|
|
|
|
|
test_extractor._batched_model = MagicMock() |
|
|
|
|
|
# set up and run the extractor |
|
|
|
|
|
test_extractor.setup(words=["quick", "jumps", "dog"]) |
|
|
|
|
|
test_extractor.run() |
|
|
|
|
|
test_extractor.teardown() |
|
|
|
|
|
|
|
|
|
|
|
self.assertEqual(len(test_extractor.features), 3) |