test(tts): Update  text to speech unit tests
import responses
import ibm_watson
import json
-
+from ibm_cloud_sdk_core.authenticators import BasicAuthenticator
@responses.activate
def test_success():
@@ -88,8 +88,8 @@ def test_success():
content_type='application/json',
match_querystring=True)
- text_to_speech = ibm_watson.TextToSpeechV1(
- username="username", password="password")
+ authenticator = BasicAuthenticator('username', 'password')
+ text_to_speech = ibm_watson.TextToSpeechV1(authenticator=authenticator)
text_to_speech.list_voices()
assert responses.calls[0].request.url == voices_url
@@ -116,8 +116,8 @@ def test_get_pronunciation():
status=200,
content_type='application_json')
- text_to_speech = ibm_watson.TextToSpeechV1(
- username="username", password="password")
+ authenticator = BasicAuthenticator('username', 'password')
+ text_to_speech = ibm_watson.TextToSpeechV1(authenticator=authenticator)
text_to_speech.get_pronunciation(text="this is some text")
text_to_speech.get_pronunciation(text="yo", voice="VoiceEnUsLisa")
@@ -160,8 +160,9 @@ def test_custom_voice_models():
status=200,
content_type='application_json')
- text_to_speech = ibm_watson.TextToSpeechV1(
- username="username", password="password")
+ authenticator = BasicAuthenticator('username', 'password')
+ text_to_speech = ibm_watson.TextToSpeechV1(authenticator=authenticator)
+
text_to_speech.list_voice_models()
text_to_speech.list_voice_models(language="en-US")
assert len(responses.calls) == 2
@@ -215,8 +216,8 @@ def test_custom_words():
status=200,
content_type='application_json')
- text_to_speech = ibm_watson.TextToSpeechV1(
- username="username", password="password")
+ authenticator = BasicAuthenticator('username', 'password')
+ text_to_speech = ibm_watson.TextToSpeechV1(authenticator=authenticator)
text_to_speech.list_words(customization_id="custid")
text_to_speech.add_words(
@@ -239,7 +240,9 @@ def test_delete_user_data():
status=204,
content_type='application_json')
- text_to_speech = ibm_watson.TextToSpeechV1(username="username", password="password")
+ authenticator = BasicAuthenticator('username', 'password')
+ text_to_speech = ibm_watson.TextToSpeechV1(authenticator=authenticator)
+
response = text_to_speech.delete_user_data('id').get_result()
assert response is None
assert len(responses.calls) == 1
