ソースを参照

test: [WFE] Negative and aprtial tests

Ensure:
 - no words are correctly not matched
 - some words are matched
main
Rob Hallam 1ヶ月前
コミット
a288d97b14
1個のファイルの変更32行の追加2行の削除
  1. +32
    -2
      test/test_feature_extractors.py

+ 32
- 2
test/test_feature_extractors.py ファイルの表示

@@ -337,8 +337,8 @@ class TestWordFeatureExtractor(unittest.TestCase):
test_extractor.teardown()
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()
test_extractor = extractors.WordFeatureExtractor(input_files=video_source)
# 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)

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)

読み込み中…
キャンセル
保存