Skip to content

Commit 9863630

Browse files
maxnussbaumGERMAN ATTANASIO RUIZ
authored andcommitted
test(tone analyzer): Add more tests for tone analyzer
1 parent 00b30e3 commit 9863630

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/unit/test_tone_analyzer_v3.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,29 @@ def test_tone_with_custom_headers
172172
).tone(tone_input: tone_text, content_type: "application/json")
173173
assert_equal(tone_response, service_response.body)
174174
end
175+
176+
def test_tone_with_application_json
177+
tone_response = JSON.parse(File.read(Dir.getwd + "/resources/tone-v3-expect1.json"))
178+
headers = {
179+
"Content-Type" => "application/json"
180+
}
181+
tone_text = { "text" => "This is the text to be analyzed" }
182+
stub_request(:post, "https://gateway.watsonplatform.net/tone-analyzer/api/v3/tone?version=2017-09-21")
183+
.with(
184+
body: tone_text,
185+
headers: {
186+
"Accept" => "application/json",
187+
"Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
188+
"Content-Type" => "application/json",
189+
"Host" => "gateway.watsonplatform.net"
190+
}
191+
).to_return(status: 200, body: tone_response.to_json, headers: headers)
192+
service = WatsonAPIs::ToneAnalyzerV3.new(
193+
version: "2017-09-21",
194+
username: "username",
195+
password: "password"
196+
)
197+
service_response = service.tone(tone_input: tone_text, content_type: "application/json")
198+
assert_equal(tone_response, service_response.body)
199+
end
175200
end

0 commit comments

Comments
 (0)