@@ -35,16 +35,15 @@ def test_predict(self):
3535 predict_output = mock_model .predict (predict_input )
3636 output_dict = predict_output ["predictions" ][0 ]
3737
38- assert output_dict [ " data" ] == "This is a test transcription"
39- assert output_dict [ " details" ][ " text" ] == "This is a test transcription"
40- assert output_dict [ " details" ][ " confidence" ] == 0.7
38+ assert output_dict . data == "This is a test transcription"
39+ assert output_dict . details . text == "This is a test transcription"
40+ assert output_dict . details . confidence == 0.7
4141
4242class MockModel (SpeechRecognitionModel ):
43- def run_model (self , api_input : Dict [str , List [SpeechRecognitionInput ]], headers : Dict [str , str ] = None ) -> Dict [str , List [SpeechRecognitionOutput ]]:
44- instances = api_input ["instances" ]
43+ def run_model (self , api_input : List [SpeechRecognitionInput ], headers : Dict [str , str ] = None ) -> List [SpeechRecognitionOutput ]:
4544 predictions_list = []
4645 # There's only 1 instance in this case.
47- for instance in instances :
46+ for instance in api_input :
4847 instance_data = instance .dict ()
4948 model_instance = Mock ()
5049 model_instance .process_data .return_value = ("This is a test transcription" , 0.7 )
@@ -61,5 +60,4 @@ def run_model(self, api_input: Dict[str, List[SpeechRecognitionInput]], headers:
6160 }
6261 speech_recognition_output = SpeechRecognitionOutput (** output_dict )
6362 predictions_list .append (speech_recognition_output )
64- predict_output = {"predictions" : predictions_list }
65- return predict_output
63+ return predictions_list
0 commit comments