ibm_watson 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ibm_watson
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Nussbaum
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-15 00:00:00.000000000 Z
11
+ date: 2020-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '1.1'
75
+ version: 1.1.1
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '1.1'
82
+ version: 1.1.1
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: jwt
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -322,7 +322,6 @@ files:
322
322
  - test/unit/test_speech_to_text_v1.rb
323
323
  - test/unit/test_text_to_speech_v1.rb
324
324
  - test/unit/test_tone_analyzer_v3.rb
325
- - test/unit/test_vcap_using_personality_insights.rb
326
325
  - test/unit/test_visual_recognition_v3.rb
327
326
  - test/unit/test_visual_recognition_v4.rb
328
327
  homepage: https://www.github.com/watson-developer-cloud
@@ -1,161 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require("json")
4
- require_relative("./../test_helper.rb")
5
- require("webmock/minitest")
6
-
7
- WebMock.disable_net_connect!(allow_localhost: true)
8
-
9
- ENV["VCAP_SERVICES"] = JSON.parse(File.read(Dir.getwd + "/resources/vcap-testing.json")).to_json
10
-
11
- # Unit tests for VCAP Services using the Personality Insights V3 Service
12
- class VcapPersonalityInsightsV3Test < Minitest::Test
13
- def test_plain_to_json
14
- profile_response = File.read(Dir.getwd + "/resources/personality-v3-expect1.txt")
15
- personality_text = File.read(Dir.getwd + "/resources/personality-v3.txt")
16
- headers = {
17
- "Content-Type" => "application/json"
18
- }
19
- expected_response = IBMWatson::DetailedResponse.new(status: 200, body: JSON.parse(profile_response), headers: headers)
20
- stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
21
- .with(
22
- body: personality_text,
23
- headers: {
24
- "Accept" => "application/json",
25
- "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
26
- "Content-Type" => "text/plain;charset=utf-8",
27
- "Host" => "gateway.watsonplatform.net"
28
- }
29
- ).to_return(status: 200, body: profile_response, headers: headers)
30
- authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
31
- service = IBMWatson::PersonalityInsightsV3.new(
32
- version: "2017-10-13",
33
- authenticator: authenticator
34
- )
35
- service_response = service.profile(
36
- accept: "application/json",
37
- content: personality_text,
38
- content_type: "text/plain;charset=utf-8"
39
- )
40
- assert_equal(expected_response.status, service_response.status)
41
- assert_equal(expected_response.result, service_response.result)
42
- expected_response.headers.each_key do |key|
43
- assert(service_response.headers.key?(key))
44
- assert(expected_response.headers[key] == service_response.headers[key])
45
- end
46
- end
47
-
48
- def test_json_to_json
49
- profile_response = File.read(Dir.getwd + "/resources/personality-v3-expect2.txt")
50
- personality_text = File.read(Dir.getwd + "/resources/personality-v3.json")
51
- headers = {
52
- "Content-Type" => "applicaiton/json"
53
- }
54
- expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
55
- stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&raw_scores=true&version=2017-10-13")
56
- .with(
57
- body: personality_text,
58
- headers: {
59
- "Accept" => "application/json",
60
- "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
61
- "Content-Type" => "application/json",
62
- "Host" => "gateway.watsonplatform.net"
63
- }
64
- ).to_return(status: 200, body: profile_response, headers: headers)
65
- authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
66
- service = IBMWatson::PersonalityInsightsV3.new(
67
- version: "2017-10-13",
68
- authenticator: authenticator
69
- )
70
- service_response = service.profile(
71
- accept: "application/json",
72
- content: personality_text,
73
- content_type: "application/json",
74
- raw_scores: true,
75
- consumption_preferences: true
76
- )
77
- assert_equal(expected_response.status, service_response.status)
78
- assert_equal(expected_response.result, service_response.result)
79
- expected_response.headers.each_key do |key|
80
- assert(service_response.headers.key?(key))
81
- assert(expected_response.headers[key] == service_response.headers[key])
82
- end
83
- end
84
-
85
- def test_json_to_csv
86
- profile_response = File.read(Dir.getwd + "/resources/personality-v3-expect3.txt")
87
- personality_text = File.read(Dir.getwd + "/resources/personality-v3.json")
88
- headers = {
89
- "Content-Type" => "text/csv"
90
- }
91
- expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
92
- stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?consumption_preferences=true&csv_headers=true&raw_scores=true&version=2017-10-13")
93
- .with(
94
- body: personality_text,
95
- headers: {
96
- "Accept" => "text/csv",
97
- "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
98
- "Content-Type" => "application/json",
99
- "Host" => "gateway.watsonplatform.net"
100
- }
101
- ).to_return(status: 200, body: profile_response, headers: headers)
102
- authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
103
- service = IBMWatson::PersonalityInsightsV3.new(
104
- version: "2017-10-13",
105
- authenticator: authenticator
106
- )
107
- service_response = service.profile(
108
- content: personality_text,
109
- content_type: "application/json",
110
- accept: "text/csv",
111
- csv_headers: true,
112
- raw_scores: true,
113
- consumption_preferences: true
114
- )
115
- assert_equal(expected_response.status, service_response.status)
116
- assert_equal(expected_response.result, service_response.result)
117
- expected_response.headers.each_key do |key|
118
- assert(service_response.headers.key?(key))
119
- assert(expected_response.headers[key] == service_response.headers[key])
120
- end
121
- end
122
-
123
- def test_plain_to_json_es
124
- profile_response = JSON.parse(File.read(Dir.getwd + "/resources/personality-v3-expect4.txt"))
125
- personality_text = File.read(Dir.getwd + "/resources/personality-v3-es.txt")
126
- headers = {
127
- "Content-Type" => "application/json"
128
- }
129
- expected_response = IBMWatson::DetailedResponse.new(status: 200, body: profile_response, headers: headers)
130
- stub_request(:post, "https://gateway.watsonplatform.net/personality-insights/api/v3/profile?version=2017-10-13")
131
- .with(
132
- body: personality_text,
133
- headers: {
134
- "Accept" => "application/json",
135
- "Accept-Language" => "es",
136
- "Authorization" => "Basic dXNlcm5hbWU6cGFzc3dvcmQ=",
137
- "Content-Language" => "es",
138
- "Content-Type" => "text/plain;charset=utf-8",
139
- "Host" => "gateway.watsonplatform.net"
140
- }
141
- ).to_return(status: 200, body: profile_response.to_json, headers: headers)
142
- authenticator = IBMWatson::Authenticators::ConfigBasedAuthenticatorFactory.new.get_authenticator(service_name: "sample_service")
143
- service = IBMWatson::PersonalityInsightsV3.new(
144
- version: "2017-10-13",
145
- authenticator: authenticator
146
- )
147
- service_response = service.profile(
148
- accept: "application/json",
149
- content: personality_text,
150
- content_type: "text/plain;charset=utf-8",
151
- content_language: "es",
152
- accept_language: "es"
153
- )
154
- assert_equal(expected_response.status, service_response.status)
155
- assert_equal(expected_response.result, service_response.result)
156
- expected_response.headers.each_key do |key|
157
- assert(service_response.headers.key?(key))
158
- assert(expected_response.headers[key] == service_response.headers[key])
159
- end
160
- end
161
- end