Pārlūkot izejas kodu

test: [WFE] Negative and aprtial tests

Ensure:
 - no words are correctly not matched
 - some words are matched
main
Rob Hallam pirms 2 mēnešiem
vecāks
revīzija
a288d97b14
1 mainītis faili ar 32 papildinājumiem un 2 dzēšanām
  1. +32
    -2
      test/test_feature_extractors.py

+ 32
- 2
test/test_feature_extractors.py Parādīt failu

@@ -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)

Notiek ielāde…
Atcelt
Saglabāt