@@ -106,49 +106,48 @@ def test_custom_model():
106106
107107 assert len (responses .calls ) == 5
108108
109- @responses .activate
110109def test_custom_corpora ():
111110
112111 corpora_url = 'https://stream.watsonplatform.net/speech-to-text/api/v1/customizations/{0}/corpora'
113112 get_corpora_url = '{0}/{1}' .format (corpora_url .format ('customid' ),'corpus' )
114113
115- responses .add (responses .GET , corpora_url .format ('customid' ),
116- body = '{"get response": "yep"}' , status = 200 ,
117- content_type = 'application/json' )
114+ with responses .RequestsMock (assert_all_requests_are_fired = True ) as rsps :
115+ rsps .add (responses .GET , corpora_url .format ('customid' ),
116+ body = '{"get response": "yep"}' , status = 200 ,
117+ content_type = 'application/json' )
118118
119- responses .add (responses .POST , get_corpora_url ,
119+ rsps .add (responses .POST , get_corpora_url ,
120120 body = '{"get response": "yep"}' ,
121121 status = 200 ,
122122 content_type = 'application/json' )
123123
124- responses .add (responses .GET , get_corpora_url ,
124+ rsps .add (responses .GET , get_corpora_url ,
125125 body = '{"get response": "yep"}' ,
126126 status = 200 ,
127127 content_type = 'application/json' )
128128
129- responses .add (responses .DELETE , get_corpora_url ,
130- body = '{"get response": "yep"}' ,
131- status = 200 ,
132- content_type = 'application/json' )
129+ rsps .add (responses .DELETE , get_corpora_url ,
130+ body = '{"get response": "yep"}' ,
131+ status = 200 ,
132+ content_type = 'application/json' )
133133
134- speech_to_text = watson_developer_cloud .SpeechToTextV1 (
135- username = "username" , password = "password" )
134+ speech_to_text = watson_developer_cloud .SpeechToTextV1 (
135+ username = "username" , password = "password" )
136136
137- speech_to_text .list_corpora (customization_id = 'customid' )
137+ speech_to_text .list_corpora (customization_id = 'customid' )
138138
139- file_path = '../resources/speech_to_text/corpus-short-1.txt'
140- full_path = os .path .join (os .path .dirname (__file__ ), file_path )
141- with open (full_path ) as corpus_file :
142- speech_to_text .add_corpus (customization_id = 'customid' ,
143- corpus_name = "corpus" , file_data = corpus_file )
139+ file_path = '../resources/speech_to_text/corpus-short-1.txt'
140+ full_path = os .path .join (os .path .dirname (__file__ ), file_path )
141+ with open (full_path ) as corpus_file :
142+ speech_to_text .add_corpus (customization_id = 'customid' ,
143+ corpus_name = "corpus" , file_data = corpus_file )
144144
145- speech_to_text .get_corpus (customization_id = 'customid' ,
146- corpus_name = 'corpus' )
145+ speech_to_text .get_corpus (customization_id = 'customid' ,
146+ corpus_name = 'corpus' )
147147
148- speech_to_text .delete_corpus (customization_id = 'customid' ,
149- corpus_name = 'corpus' )
148+ speech_to_text .delete_corpus (customization_id = 'customid' ,
149+ corpus_name = 'corpus' )
150150
151- assert len (responses .calls ) == 4
152151
153152@responses .activate
154153def test_custom_words ():
0 commit comments