def test_requests_timeout(self, mock_requests): """ Test mocked requests post raises timeout """ with self.assertRaises(requests.exceptions.Timeout): _synthesize_text_from_audio_file( self.folder_id, self.token, self.audio_file )
def test_requests_404(self): """ Test mocked resp returns 404 """ with patch("src.yandex_tts.requests") as mock_requests: mock_requests.status_code = 404 with self.assertRaises(RuntimeError): _synthesize_text_from_audio_file( self.folder_id, self.token, self.audio_file )
def test_empty_text(self): """ Test with empty source_file """ with self.assertRaises(FileNotFoundError): result_audio = _synthesize_text_from_audio_file( folder_id=self.folder_id, iam_token=self.token, source_file="" )
def test_without_text(self): """ Test without source_file """ with self.assertRaises(TypeError): result_audio = _synthesize_text_from_audio_file( folder_id=self.folder_id, iam_token=self.token )
def test_without_folder_id(self): """ Test without folder id """ with self.assertRaises(TypeError): result_audio = _synthesize_text_from_audio_file( iam_token=self.token, source_file=self.audio_file )
def test_normal_case(self): """ Test normal case """ result_text = _synthesize_text_from_audio_file( self.folder_id, self.token, self.audio_file ) self.assertTrue( result_text in ["One two three fore uno dos tres quatro", "1234 in a dos truskawkowa"] )