ibm_watson 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,706 +2,708 @@
2
2
 
3
3
  require_relative("./../test_helper.rb")
4
4
 
5
- # Integration tests for the Watson Assistant V1 Service
6
- class IAMAssistantV1Test < Minitest::Test
7
- def test_create_update_delete_workspace
8
- service = IBMWatson::AssistantV1.new(
9
- url: ENV["ASSISTANT_IAM_URL"],
10
- version: "2018-02-16"
11
- )
12
- service._iam_api_key(iam_api_key: ENV["ASSISTANT_IAM_APIKEY"])
13
- service._iam_api_key(iam_api_key: ENV["ASSISTANT_IAM_APIKEY"])
14
- service.add_default_headers(
15
- headers: {
16
- "X-Watson-Learning-Opt-Out" => "1",
17
- "X-Watson-Test" => "1"
18
- }
19
- )
20
- service_response = service.create_workspace(
21
- name: "Pizza app",
22
- description: "Pizza app",
23
- language: "en",
24
- metadata: {}
25
- )
26
- workspace_id = service_response.result["workspace_id"]
27
- assert((200..299).cover?(service_response.status))
28
-
29
- service_response = service.update_workspace(
30
- workspace_id: workspace_id,
31
- name: "Pizza app",
32
- description: "Pizza app",
33
- language: "en",
34
- metadata: {}
35
- )
36
- assert((200..299).cover?(service_response.status))
37
-
38
- service_response = service.delete_workspace(
39
- workspace_id: workspace_id
40
- )
41
- assert(service_response.nil?)
42
- end
5
+ unless ENV["ASSISTANT_IAM_URL"].nil? || ENV["ASSISTANT_IAM_APIKEY"].nil?
6
+ # Integration tests for the Watson Assistant V1 Service
7
+ class IAMAssistantV1Test < Minitest::Test
8
+ def test_create_update_delete_workspace
9
+ service = IBMWatson::AssistantV1.new(
10
+ url: ENV["ASSISTANT_IAM_URL"],
11
+ version: "2018-02-16"
12
+ )
13
+ service._iam_api_key(iam_api_key: ENV["ASSISTANT_IAM_APIKEY"])
14
+ service._iam_api_key(iam_api_key: ENV["ASSISTANT_IAM_APIKEY"])
15
+ service.add_default_headers(
16
+ headers: {
17
+ "X-Watson-Learning-Opt-Out" => "1",
18
+ "X-Watson-Test" => "1"
19
+ }
20
+ )
21
+ service_response = service.create_workspace(
22
+ name: "Pizza app",
23
+ description: "Pizza app",
24
+ language: "en",
25
+ metadata: {}
26
+ )
27
+ workspace_id = service_response.result["workspace_id"]
28
+ assert((200..299).cover?(service_response.status))
29
+
30
+ service_response = service.update_workspace(
31
+ workspace_id: workspace_id,
32
+ name: "Pizza app",
33
+ description: "Pizza app",
34
+ language: "en",
35
+ metadata: {}
36
+ )
37
+ assert((200..299).cover?(service_response.status))
38
+
39
+ service_response = service.delete_workspace(
40
+ workspace_id: workspace_id
41
+ )
42
+ assert(service_response.nil?)
43
+ end
43
44
 
44
- def test_get_workspace
45
- service = IBMWatson::AssistantV1.new(
46
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
47
- url: ENV["ASSISTANT_IAM_URL"],
48
- version: "2018-02-16"
49
- )
50
- service.add_default_headers(
51
- headers: {
52
- "X-Watson-Learning-Opt-Out" => "1",
53
- "X-Watson-Test" => "1"
54
- }
55
- )
56
- service_response = service.get_workspace(
57
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
58
- export: false
59
- )
60
- assert((200..299).cover?(service_response.status))
61
- end
45
+ def test_get_workspace
46
+ service = IBMWatson::AssistantV1.new(
47
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
48
+ url: ENV["ASSISTANT_IAM_URL"],
49
+ version: "2018-02-16"
50
+ )
51
+ service.add_default_headers(
52
+ headers: {
53
+ "X-Watson-Learning-Opt-Out" => "1",
54
+ "X-Watson-Test" => "1"
55
+ }
56
+ )
57
+ service_response = service.get_workspace(
58
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
59
+ export: false
60
+ )
61
+ assert((200..299).cover?(service_response.status))
62
+ end
62
63
 
63
- def test_list_workspaces
64
- service = IBMWatson::AssistantV1.new(
65
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
66
- url: ENV["ASSISTANT_IAM_URL"],
67
- version: "2018-02-16"
68
- )
69
- service.add_default_headers(
70
- headers: {
71
- "X-Watson-Learning-Opt-Out" => "1",
72
- "X-Watson-Test" => "1"
73
- }
74
- )
75
- service_response = service.list_workspaces
76
- assert((200..299).cover?(service_response.status))
77
- end
64
+ def test_list_workspaces
65
+ service = IBMWatson::AssistantV1.new(
66
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
67
+ url: ENV["ASSISTANT_IAM_URL"],
68
+ version: "2018-02-16"
69
+ )
70
+ service.add_default_headers(
71
+ headers: {
72
+ "X-Watson-Learning-Opt-Out" => "1",
73
+ "X-Watson-Test" => "1"
74
+ }
75
+ )
76
+ service_response = service.list_workspaces
77
+ assert((200..299).cover?(service_response.status))
78
+ end
78
79
 
79
- def test_create_update_delete_counterexample
80
- service = IBMWatson::AssistantV1.new(
81
- version: "2018-02-16",
82
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
83
- url: ENV["ASSISTANT_IAM_URL"]
84
- )
85
- service.add_default_headers(
86
- headers: {
87
- "X-Watson-Learning-Opt-Out" => "1",
88
- "X-Watson-Test" => "1"
89
- }
90
- )
91
- service_response = service.create_counterexample(
92
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
93
- text: "I want a large pizza please."
94
- )
95
- assert((200..299).cover?(service_response.status))
96
-
97
- service_response = service.update_counterexample(
98
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
99
- text: "I want a large pizza please.",
100
- new_text: "I want a large pizza please."
101
- )
102
- assert((200..299).cover?(service_response.status))
103
-
104
- service_response = service.delete_counterexample(
105
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
106
- text: "I want a large pizza please."
107
- )
108
- assert(service_response.nil?)
109
- end
80
+ def test_create_update_delete_counterexample
81
+ service = IBMWatson::AssistantV1.new(
82
+ version: "2018-02-16",
83
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
84
+ url: ENV["ASSISTANT_IAM_URL"]
85
+ )
86
+ service.add_default_headers(
87
+ headers: {
88
+ "X-Watson-Learning-Opt-Out" => "1",
89
+ "X-Watson-Test" => "1"
90
+ }
91
+ )
92
+ service_response = service.create_counterexample(
93
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
94
+ text: "I want a large pizza please."
95
+ )
96
+ assert((200..299).cover?(service_response.status))
97
+
98
+ service_response = service.update_counterexample(
99
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
100
+ text: "I want a large pizza please.",
101
+ new_text: "I want a large pizza please."
102
+ )
103
+ assert((200..299).cover?(service_response.status))
104
+
105
+ service_response = service.delete_counterexample(
106
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
107
+ text: "I want a large pizza please."
108
+ )
109
+ assert(service_response.nil?)
110
+ end
110
111
 
111
- def test_get_counterexample
112
- service = IBMWatson::AssistantV1.new(
113
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
114
- url: ENV["ASSISTANT_IAM_URL"],
115
- version: "2018-02-16"
116
- )
117
- service.add_default_headers(
118
- headers: {
119
- "X-Watson-Learning-Opt-Out" => "1",
120
- "X-Watson-Test" => "1"
121
- }
122
- )
123
- service_response = service.get_counterexample(
124
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
125
- text: "what is your nickname"
126
- )
127
- assert((200..299).cover?(service_response.status))
128
- end
112
+ def test_get_counterexample
113
+ service = IBMWatson::AssistantV1.new(
114
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
115
+ url: ENV["ASSISTANT_IAM_URL"],
116
+ version: "2018-02-16"
117
+ )
118
+ service.add_default_headers(
119
+ headers: {
120
+ "X-Watson-Learning-Opt-Out" => "1",
121
+ "X-Watson-Test" => "1"
122
+ }
123
+ )
124
+ service_response = service.get_counterexample(
125
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
126
+ text: "what is your nickname"
127
+ )
128
+ assert((200..299).cover?(service_response.status))
129
+ end
129
130
 
130
- def test_list_counterexamples
131
- service = IBMWatson::AssistantV1.new(
132
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
133
- url: ENV["ASSISTANT_IAM_URL"],
134
- version: "2018-02-16"
135
- )
136
- service.add_default_headers(
137
- headers: {
138
- "X-Watson-Learning-Opt-Out" => "1",
139
- "X-Watson-Test" => "1"
140
- }
141
- )
142
- service_response = service.list_counterexamples(
143
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"]
144
- )
145
- assert((200..299).cover?(service_response.status))
146
- end
131
+ def test_list_counterexamples
132
+ service = IBMWatson::AssistantV1.new(
133
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
134
+ url: ENV["ASSISTANT_IAM_URL"],
135
+ version: "2018-02-16"
136
+ )
137
+ service.add_default_headers(
138
+ headers: {
139
+ "X-Watson-Learning-Opt-Out" => "1",
140
+ "X-Watson-Test" => "1"
141
+ }
142
+ )
143
+ service_response = service.list_counterexamples(
144
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"]
145
+ )
146
+ assert((200..299).cover?(service_response.status))
147
+ end
147
148
 
148
- def test_create_update_delete_entity
149
- service = IBMWatson::AssistantV1.new(
150
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
151
- url: ENV["ASSISTANT_IAM_URL"],
152
- version: "2018-02-16"
153
- )
154
- service.add_default_headers(
155
- headers: {
156
- "X-Watson-Learning-Opt-Out" => "1",
157
- "X-Watson-Test" => "1"
158
- }
159
- )
160
- service_response = service.create_entity(
161
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
162
- entity: "pizza_toppings",
163
- description: "Tasty pizza toppings",
164
- metadata: { "property" => "value" },
165
- values: nil,
166
- fuzzy_match: nil
167
- )
168
- assert((200..299).cover?(service_response.status))
169
-
170
- service_response = service.update_entity(
171
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
172
- entity: "pizza_toppings",
173
- new_entity: "pizza_toppings"
174
- )
175
- assert((200..299).cover?(service_response.status))
176
-
177
- service_response = service.delete_entity(
178
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
179
- entity: "pizza_toppings"
180
- )
181
- assert(service_response.nil?)
182
- end
149
+ def test_create_update_delete_entity
150
+ service = IBMWatson::AssistantV1.new(
151
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
152
+ url: ENV["ASSISTANT_IAM_URL"],
153
+ version: "2018-02-16"
154
+ )
155
+ service.add_default_headers(
156
+ headers: {
157
+ "X-Watson-Learning-Opt-Out" => "1",
158
+ "X-Watson-Test" => "1"
159
+ }
160
+ )
161
+ service_response = service.create_entity(
162
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
163
+ entity: "pizza_toppings",
164
+ description: "Tasty pizza toppings",
165
+ metadata: { "property" => "value" },
166
+ values: nil,
167
+ fuzzy_match: nil
168
+ )
169
+ assert((200..299).cover?(service_response.status))
170
+
171
+ service_response = service.update_entity(
172
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
173
+ entity: "pizza_toppings",
174
+ new_entity: "pizza_toppings"
175
+ )
176
+ assert((200..299).cover?(service_response.status))
177
+
178
+ service_response = service.delete_entity(
179
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
180
+ entity: "pizza_toppings"
181
+ )
182
+ assert(service_response.nil?)
183
+ end
183
184
 
184
- def test_get_entity
185
- service = IBMWatson::AssistantV1.new(
186
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
187
- url: ENV["ASSISTANT_IAM_URL"],
188
- version: "2018-02-16"
189
- )
190
- service.add_default_headers(
191
- headers: {
192
- "X-Watson-Learning-Opt-Out" => "1",
193
- "X-Watson-Test" => "1"
194
- }
195
- )
196
- service_response = service.get_entity(
197
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
198
- entity: "holiday",
199
- export: true
200
- )
201
- assert((200..299).cover?(service_response.status))
202
- end
185
+ def test_get_entity
186
+ service = IBMWatson::AssistantV1.new(
187
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
188
+ url: ENV["ASSISTANT_IAM_URL"],
189
+ version: "2018-02-16"
190
+ )
191
+ service.add_default_headers(
192
+ headers: {
193
+ "X-Watson-Learning-Opt-Out" => "1",
194
+ "X-Watson-Test" => "1"
195
+ }
196
+ )
197
+ service_response = service.get_entity(
198
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
199
+ entity: "holiday",
200
+ export: true
201
+ )
202
+ assert((200..299).cover?(service_response.status))
203
+ end
203
204
 
204
- def test_list_entities
205
- service = IBMWatson::AssistantV1.new(
206
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
207
- url: ENV["ASSISTANT_IAM_URL"],
208
- version: "2018-02-16"
209
- )
210
- service.add_default_headers(
211
- headers: {
212
- "X-Watson-Learning-Opt-Out" => "1",
213
- "X-Watson-Test" => "1"
214
- }
215
- )
216
- service_response = service.list_entities(
217
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
218
- export: true
219
- )
220
- assert((200..299).cover?(service_response.status))
221
- end
205
+ def test_list_entities
206
+ service = IBMWatson::AssistantV1.new(
207
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
208
+ url: ENV["ASSISTANT_IAM_URL"],
209
+ version: "2018-02-16"
210
+ )
211
+ service.add_default_headers(
212
+ headers: {
213
+ "X-Watson-Learning-Opt-Out" => "1",
214
+ "X-Watson-Test" => "1"
215
+ }
216
+ )
217
+ service_response = service.list_entities(
218
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
219
+ export: true
220
+ )
221
+ assert((200..299).cover?(service_response.status))
222
+ end
222
223
 
223
- def test_create_update_delete_example
224
- service = IBMWatson::AssistantV1.new(
225
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
226
- url: ENV["ASSISTANT_IAM_URL"],
227
- version: "2018-02-16"
228
- )
229
- service.add_default_headers(
230
- headers: {
231
- "X-Watson-Learning-Opt-Out" => "1",
232
- "X-Watson-Test" => "1"
233
- }
234
- )
235
- service_response = service.create_example(
236
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
237
- intent: "Cancel",
238
- text: "Gimme a pizza with pepperoni"
239
- )
240
- assert((200..299).cover?(service_response.status))
241
-
242
- service_response = service.update_example(
243
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
244
- intent: "Cancel",
245
- text: "Gimme a pizza with pepperoni",
246
- new_text: "Gimme a pizza with pepperoni"
247
- )
248
- assert((200..299).cover?(service_response.status))
249
-
250
- service_response = service.delete_example(
251
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
252
- intent: "Cancel",
253
- text: "Gimme a pizza with pepperoni"
254
- )
255
- assert(service_response.nil?)
256
- end
224
+ def test_create_update_delete_example
225
+ service = IBMWatson::AssistantV1.new(
226
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
227
+ url: ENV["ASSISTANT_IAM_URL"],
228
+ version: "2018-02-16"
229
+ )
230
+ service.add_default_headers(
231
+ headers: {
232
+ "X-Watson-Learning-Opt-Out" => "1",
233
+ "X-Watson-Test" => "1"
234
+ }
235
+ )
236
+ service_response = service.create_example(
237
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
238
+ intent: "Cancel",
239
+ text: "Gimme a pizza with pepperoni"
240
+ )
241
+ assert((200..299).cover?(service_response.status))
242
+
243
+ service_response = service.update_example(
244
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
245
+ intent: "Cancel",
246
+ text: "Gimme a pizza with pepperoni",
247
+ new_text: "Gimme a pizza with pepperoni"
248
+ )
249
+ assert((200..299).cover?(service_response.status))
250
+
251
+ service_response = service.delete_example(
252
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
253
+ intent: "Cancel",
254
+ text: "Gimme a pizza with pepperoni"
255
+ )
256
+ assert(service_response.nil?)
257
+ end
257
258
 
258
- def test_get_example
259
- service = IBMWatson::AssistantV1.new(
260
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
261
- url: ENV["ASSISTANT_IAM_URL"],
262
- version: "2018-02-16"
263
- )
264
- service.add_default_headers(
265
- headers: {
266
- "X-Watson-Learning-Opt-Out" => "1",
267
- "X-Watson-Test" => "1"
268
- }
269
- )
270
- service_response = service.get_example(
271
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
272
- intent: "Cancel",
273
- text: "forget it"
274
- )
275
- assert((200..299).cover?(service_response.status))
276
- end
259
+ def test_get_example
260
+ service = IBMWatson::AssistantV1.new(
261
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
262
+ url: ENV["ASSISTANT_IAM_URL"],
263
+ version: "2018-02-16"
264
+ )
265
+ service.add_default_headers(
266
+ headers: {
267
+ "X-Watson-Learning-Opt-Out" => "1",
268
+ "X-Watson-Test" => "1"
269
+ }
270
+ )
271
+ service_response = service.get_example(
272
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
273
+ intent: "Cancel",
274
+ text: "forget it"
275
+ )
276
+ assert((200..299).cover?(service_response.status))
277
+ end
277
278
 
278
- def test_list_examples
279
- service = IBMWatson::AssistantV1.new(
280
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
281
- url: ENV["ASSISTANT_IAM_URL"],
282
- version: "2018-02-16"
283
- )
284
- service.add_default_headers(
285
- headers: {
286
- "X-Watson-Learning-Opt-Out" => "1",
287
- "X-Watson-Test" => "1"
288
- }
289
- )
290
- service_response = service.list_examples(
291
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
292
- intent: "Cancel"
293
- )
294
- assert((200..299).cover?(service_response.status))
295
- end
279
+ def test_list_examples
280
+ service = IBMWatson::AssistantV1.new(
281
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
282
+ url: ENV["ASSISTANT_IAM_URL"],
283
+ version: "2018-02-16"
284
+ )
285
+ service.add_default_headers(
286
+ headers: {
287
+ "X-Watson-Learning-Opt-Out" => "1",
288
+ "X-Watson-Test" => "1"
289
+ }
290
+ )
291
+ service_response = service.list_examples(
292
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
293
+ intent: "Cancel"
294
+ )
295
+ assert((200..299).cover?(service_response.status))
296
+ end
296
297
 
297
- def test_create_update_delete_intent
298
- service = IBMWatson::AssistantV1.new(
299
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
300
- url: ENV["ASSISTANT_IAM_URL"],
301
- version: "2018-02-16"
302
- )
303
- service.add_default_headers(
304
- headers: {
305
- "X-Watson-Learning-Opt-Out" => "1",
306
- "X-Watson-Test" => "1"
307
- }
308
- )
309
- service_response = service.create_intent(
310
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
311
- intent: "pizza_order",
312
- description: "User wants to start a new pizza order"
313
- )
314
- assert((200..299).cover?(service_response.status))
315
-
316
- service_response = service.update_intent(
317
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
318
- intent: "pizza_order",
319
- new_intent: "pizza_order",
320
- new_description: "User wants to start a new pizza order"
321
- )
322
- assert((200..299).cover?(service_response.status))
323
-
324
- service_response = service.delete_intent(
325
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
326
- intent: "pizza_order"
327
- )
328
- assert(service_response.nil?)
329
- end
298
+ def test_create_update_delete_intent
299
+ service = IBMWatson::AssistantV1.new(
300
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
301
+ url: ENV["ASSISTANT_IAM_URL"],
302
+ version: "2018-02-16"
303
+ )
304
+ service.add_default_headers(
305
+ headers: {
306
+ "X-Watson-Learning-Opt-Out" => "1",
307
+ "X-Watson-Test" => "1"
308
+ }
309
+ )
310
+ service_response = service.create_intent(
311
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
312
+ intent: "pizza_order",
313
+ description: "User wants to start a new pizza order"
314
+ )
315
+ assert((200..299).cover?(service_response.status))
316
+
317
+ service_response = service.update_intent(
318
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
319
+ intent: "pizza_order",
320
+ new_intent: "pizza_order",
321
+ new_description: "User wants to start a new pizza order"
322
+ )
323
+ assert((200..299).cover?(service_response.status))
324
+
325
+ service_response = service.delete_intent(
326
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
327
+ intent: "pizza_order"
328
+ )
329
+ assert(service_response.nil?)
330
+ end
330
331
 
331
- def test_get_intent
332
- service = IBMWatson::AssistantV1.new(
333
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
334
- url: ENV["ASSISTANT_IAM_URL"],
335
- version: "2018-02-16"
336
- )
337
- service.add_default_headers(
338
- headers: {
339
- "X-Watson-Learning-Opt-Out" => "1",
340
- "X-Watson-Test" => "1"
341
- }
342
- )
343
- service_response = service.get_intent(
344
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
345
- intent: "Cancel",
346
- export: false
347
- )
348
- assert((200..299).cover?(service_response.status))
349
- end
332
+ def test_get_intent
333
+ service = IBMWatson::AssistantV1.new(
334
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
335
+ url: ENV["ASSISTANT_IAM_URL"],
336
+ version: "2018-02-16"
337
+ )
338
+ service.add_default_headers(
339
+ headers: {
340
+ "X-Watson-Learning-Opt-Out" => "1",
341
+ "X-Watson-Test" => "1"
342
+ }
343
+ )
344
+ service_response = service.get_intent(
345
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
346
+ intent: "Cancel",
347
+ export: false
348
+ )
349
+ assert((200..299).cover?(service_response.status))
350
+ end
350
351
 
351
- def test_list_intents
352
- service = IBMWatson::AssistantV1.new(
353
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
354
- url: ENV["ASSISTANT_IAM_URL"],
355
- version: "2018-02-16"
356
- )
357
- service.add_default_headers(
358
- headers: {
359
- "X-Watson-Learning-Opt-Out" => "1",
360
- "X-Watson-Test" => "1"
361
- }
362
- )
363
- service_response = service.list_intents(
364
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
365
- export: false
366
- )
367
- assert((200..299).cover?(service_response.status))
368
- end
352
+ def test_list_intents
353
+ service = IBMWatson::AssistantV1.new(
354
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
355
+ url: ENV["ASSISTANT_IAM_URL"],
356
+ version: "2018-02-16"
357
+ )
358
+ service.add_default_headers(
359
+ headers: {
360
+ "X-Watson-Learning-Opt-Out" => "1",
361
+ "X-Watson-Test" => "1"
362
+ }
363
+ )
364
+ service_response = service.list_intents(
365
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
366
+ export: false
367
+ )
368
+ assert((200..299).cover?(service_response.status))
369
+ end
369
370
 
370
- def test_list_logs
371
- service = IBMWatson::AssistantV1.new(
372
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
373
- url: ENV["ASSISTANT_IAM_URL"],
374
- version: "2018-02-16"
375
- )
376
- service.add_default_headers(
377
- headers: {
378
- "X-Watson-Learning-Opt-Out" => "1",
379
- "X-Watson-Test" => "1"
380
- }
381
- )
382
- service_response = service.list_logs(
383
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"]
384
- )
385
- assert((200..299).cover?(service_response.status))
386
- end
371
+ def test_list_logs
372
+ service = IBMWatson::AssistantV1.new(
373
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
374
+ url: ENV["ASSISTANT_IAM_URL"],
375
+ version: "2018-02-16"
376
+ )
377
+ service.add_default_headers(
378
+ headers: {
379
+ "X-Watson-Learning-Opt-Out" => "1",
380
+ "X-Watson-Test" => "1"
381
+ }
382
+ )
383
+ service_response = service.list_logs(
384
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"]
385
+ )
386
+ assert((200..299).cover?(service_response.status))
387
+ end
387
388
 
388
- def test_list_all_logs
389
- service = IBMWatson::AssistantV1.new(
390
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
391
- url: ENV["ASSISTANT_IAM_URL"],
392
- version: "2018-02-16"
393
- )
394
- service.add_default_headers(
395
- headers: {
396
- "X-Watson-Learning-Opt-Out" => "1",
397
- "X-Watson-Test" => "1"
398
- }
399
- )
400
- service_response = service.list_all_logs(
401
- filter: "language::en,request.context.metadata.deployment::deployment_1"
402
- )
403
- assert((200..299).cover?(service_response.status))
404
- end
389
+ def test_list_all_logs
390
+ service = IBMWatson::AssistantV1.new(
391
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
392
+ url: ENV["ASSISTANT_IAM_URL"],
393
+ version: "2018-02-16"
394
+ )
395
+ service.add_default_headers(
396
+ headers: {
397
+ "X-Watson-Learning-Opt-Out" => "1",
398
+ "X-Watson-Test" => "1"
399
+ }
400
+ )
401
+ service_response = service.list_all_logs(
402
+ filter: "language::en,request.context.metadata.deployment::deployment_1"
403
+ )
404
+ assert((200..299).cover?(service_response.status))
405
+ end
405
406
 
406
- def test_message
407
- service = IBMWatson::AssistantV1.new(
408
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
409
- url: ENV["ASSISTANT_IAM_URL"],
410
- version: "2018-02-16"
411
- )
412
- service.add_default_headers(
413
- headers: {
414
- "X-Watson-Learning-Opt-Out" => "1",
415
- "X-Watson-Test" => "1"
416
- }
417
- )
418
- service_response = service.message(
419
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
420
- input: { "text" => "Turn on the lights" },
421
- context: nil
422
- )
423
- assert((200..299).cover?(service_response.status))
424
-
425
- context = service_response.result["context"]
426
- service_response = service.message(
427
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
428
- input: { "text" => "Turn on the lights" },
429
- context: context
430
- )
431
- assert((200..299).cover?(service_response.status))
432
- end
407
+ def test_message
408
+ service = IBMWatson::AssistantV1.new(
409
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
410
+ url: ENV["ASSISTANT_IAM_URL"],
411
+ version: "2018-02-16"
412
+ )
413
+ service.add_default_headers(
414
+ headers: {
415
+ "X-Watson-Learning-Opt-Out" => "1",
416
+ "X-Watson-Test" => "1"
417
+ }
418
+ )
419
+ service_response = service.message(
420
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
421
+ input: { "text" => "Turn on the lights" },
422
+ context: nil
423
+ )
424
+ assert((200..299).cover?(service_response.status))
425
+
426
+ context = service_response.result["context"]
427
+ service_response = service.message(
428
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
429
+ input: { "text" => "Turn on the lights" },
430
+ context: context
431
+ )
432
+ assert((200..299).cover?(service_response.status))
433
+ end
433
434
 
434
- def test_create_update_delete_synonym
435
- service = IBMWatson::AssistantV1.new(
436
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
437
- url: ENV["ASSISTANT_IAM_URL"],
438
- version: "2018-02-16"
439
- )
440
- service.add_default_headers(
441
- headers: {
442
- "X-Watson-Learning-Opt-Out" => "1",
443
- "X-Watson-Test" => "1"
444
- }
445
- )
446
- service_response = service.create_synonym(
447
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
448
- entity: "holiday",
449
- value: "labor day",
450
- synonym: "a"
451
- )
452
- assert((200..299).cover?(service_response.status))
453
-
454
- service_response = service.update_synonym(
455
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
456
- entity: "holiday",
457
- value: "labor day",
458
- synonym: "a",
459
- new_synonym: "a"
460
- )
461
- assert((200..299).cover?(service_response.status))
462
-
463
- service_response = service.delete_synonym(
464
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
465
- entity: "holiday",
466
- value: "labor day",
467
- synonym: "a"
468
- )
469
- assert(service_response.nil?)
470
- end
435
+ def test_create_update_delete_synonym
436
+ service = IBMWatson::AssistantV1.new(
437
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
438
+ url: ENV["ASSISTANT_IAM_URL"],
439
+ version: "2018-02-16"
440
+ )
441
+ service.add_default_headers(
442
+ headers: {
443
+ "X-Watson-Learning-Opt-Out" => "1",
444
+ "X-Watson-Test" => "1"
445
+ }
446
+ )
447
+ service_response = service.create_synonym(
448
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
449
+ entity: "holiday",
450
+ value: "labor day",
451
+ synonym: "a"
452
+ )
453
+ assert((200..299).cover?(service_response.status))
454
+
455
+ service_response = service.update_synonym(
456
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
457
+ entity: "holiday",
458
+ value: "labor day",
459
+ synonym: "a",
460
+ new_synonym: "a"
461
+ )
462
+ assert((200..299).cover?(service_response.status))
463
+
464
+ service_response = service.delete_synonym(
465
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
466
+ entity: "holiday",
467
+ value: "labor day",
468
+ synonym: "a"
469
+ )
470
+ assert(service_response.nil?)
471
+ end
471
472
 
472
- def test_get_synonym
473
- service = IBMWatson::AssistantV1.new(
474
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
475
- url: ENV["ASSISTANT_IAM_URL"],
476
- version: "2018-02-16"
477
- )
478
- service.add_default_headers(
479
- headers: {
480
- "X-Watson-Learning-Opt-Out" => "1",
481
- "X-Watson-Test" => "1"
482
- }
483
- )
484
- service_response = service.get_synonym(
485
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
486
- entity: "holiday",
487
- value: "thanksgiving",
488
- synonym: "turkey day"
489
- )
490
- assert((200..299).cover?(service_response.status))
491
- end
473
+ def test_get_synonym
474
+ service = IBMWatson::AssistantV1.new(
475
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
476
+ url: ENV["ASSISTANT_IAM_URL"],
477
+ version: "2018-02-16"
478
+ )
479
+ service.add_default_headers(
480
+ headers: {
481
+ "X-Watson-Learning-Opt-Out" => "1",
482
+ "X-Watson-Test" => "1"
483
+ }
484
+ )
485
+ service_response = service.get_synonym(
486
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
487
+ entity: "holiday",
488
+ value: "thanksgiving",
489
+ synonym: "turkey day"
490
+ )
491
+ assert((200..299).cover?(service_response.status))
492
+ end
492
493
 
493
- def test_list_synonyms
494
- service = IBMWatson::AssistantV1.new(
495
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
496
- url: ENV["ASSISTANT_IAM_URL"],
497
- version: "2018-02-16"
498
- )
499
- service.add_default_headers(
500
- headers: {
501
- "X-Watson-Learning-Opt-Out" => "1",
502
- "X-Watson-Test" => "1"
503
- }
504
- )
505
- service_response = service.list_synonyms(
506
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
507
- entity: "holiday",
508
- value: "new years eve"
509
- )
510
- assert((200..299).cover?(service_response.status))
511
- end
494
+ def test_list_synonyms
495
+ service = IBMWatson::AssistantV1.new(
496
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
497
+ url: ENV["ASSISTANT_IAM_URL"],
498
+ version: "2018-02-16"
499
+ )
500
+ service.add_default_headers(
501
+ headers: {
502
+ "X-Watson-Learning-Opt-Out" => "1",
503
+ "X-Watson-Test" => "1"
504
+ }
505
+ )
506
+ service_response = service.list_synonyms(
507
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
508
+ entity: "holiday",
509
+ value: "new years eve"
510
+ )
511
+ assert((200..299).cover?(service_response.status))
512
+ end
512
513
 
513
- def test_create_update_delete_value
514
- service = IBMWatson::AssistantV1.new(
515
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
516
- url: ENV["ASSISTANT_IAM_URL"],
517
- version: "2018-02-16"
518
- )
519
- service.add_default_headers(
520
- headers: {
521
- "X-Watson-Learning-Opt-Out" => "1",
522
- "X-Watson-Test" => "1"
523
- }
524
- )
525
- service_response = service.create_value(
526
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
527
- entity: "holiday",
528
- value: "aeiou"
529
- )
530
- assert((200..299).cover?(service_response.status))
531
-
532
- service_response = service.update_value(
533
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
534
- entity: "holiday",
535
- value: "aeiou",
536
- new_value: "BBQ sauce",
537
- new_metadata: { "code" => 1422 },
538
- new_synonyms: nil
539
- )
540
- assert((200..299).cover?(service_response.status))
541
-
542
- service_response = service.delete_value(
543
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
544
- entity: "holiday",
545
- value: "BBQ sauce"
546
- )
547
- assert(service_response.nil?)
548
- end
514
+ def test_create_update_delete_value
515
+ service = IBMWatson::AssistantV1.new(
516
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
517
+ url: ENV["ASSISTANT_IAM_URL"],
518
+ version: "2018-02-16"
519
+ )
520
+ service.add_default_headers(
521
+ headers: {
522
+ "X-Watson-Learning-Opt-Out" => "1",
523
+ "X-Watson-Test" => "1"
524
+ }
525
+ )
526
+ service_response = service.create_value(
527
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
528
+ entity: "holiday",
529
+ value: "aeiou"
530
+ )
531
+ assert((200..299).cover?(service_response.status))
532
+
533
+ service_response = service.update_value(
534
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
535
+ entity: "holiday",
536
+ value: "aeiou",
537
+ new_value: "BBQ sauce",
538
+ new_metadata: { "code" => 1422 },
539
+ new_synonyms: nil
540
+ )
541
+ assert((200..299).cover?(service_response.status))
542
+
543
+ service_response = service.delete_value(
544
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
545
+ entity: "holiday",
546
+ value: "BBQ sauce"
547
+ )
548
+ assert(service_response.nil?)
549
+ end
549
550
 
550
- def test_get_value
551
- service = IBMWatson::AssistantV1.new(
552
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
553
- url: ENV["ASSISTANT_IAM_URL"],
554
- version: "2018-02-16"
555
- )
556
- service.add_default_headers(
557
- headers: {
558
- "X-Watson-Learning-Opt-Out" => "1",
559
- "X-Watson-Test" => "1"
560
- }
561
- )
562
- service_response = service.get_value(
563
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
564
- entity: "holiday",
565
- value: "christmas",
566
- export: true
567
- )
568
- assert((200..299).cover?(service_response.status))
569
- end
551
+ def test_get_value
552
+ service = IBMWatson::AssistantV1.new(
553
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
554
+ url: ENV["ASSISTANT_IAM_URL"],
555
+ version: "2018-02-16"
556
+ )
557
+ service.add_default_headers(
558
+ headers: {
559
+ "X-Watson-Learning-Opt-Out" => "1",
560
+ "X-Watson-Test" => "1"
561
+ }
562
+ )
563
+ service_response = service.get_value(
564
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
565
+ entity: "holiday",
566
+ value: "christmas",
567
+ export: true
568
+ )
569
+ assert((200..299).cover?(service_response.status))
570
+ end
570
571
 
571
- def test_list_values
572
- service = IBMWatson::AssistantV1.new(
573
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
574
- url: ENV["ASSISTANT_IAM_URL"],
575
- version: "2018-02-16"
576
- )
577
- service.add_default_headers(
578
- headers: {
579
- "X-Watson-Learning-Opt-Out" => "1",
580
- "X-Watson-Test" => "1"
581
- }
582
- )
583
- service_response = service.list_values(
584
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
585
- entity: "holiday",
586
- export: true
587
- )
588
- assert((200..299).cover?(service_response.status))
589
- end
572
+ def test_list_values
573
+ service = IBMWatson::AssistantV1.new(
574
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
575
+ url: ENV["ASSISTANT_IAM_URL"],
576
+ version: "2018-02-16"
577
+ )
578
+ service.add_default_headers(
579
+ headers: {
580
+ "X-Watson-Learning-Opt-Out" => "1",
581
+ "X-Watson-Test" => "1"
582
+ }
583
+ )
584
+ service_response = service.list_values(
585
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
586
+ entity: "holiday",
587
+ export: true
588
+ )
589
+ assert((200..299).cover?(service_response.status))
590
+ end
590
591
 
591
- def test_dialog_nodes
592
- service = IBMWatson::AssistantV1.new(
593
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
594
- url: ENV["ASSISTANT_IAM_URL"],
595
- version: "2018-02-16"
596
- )
597
- service.add_default_headers(
598
- headers: {
599
- "X-Watson-Learning-Opt-Out" => "1",
600
- "X-Watson-Test" => "1"
601
- }
602
- )
603
-
604
- service_response = service.create_dialog_node(
605
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
606
- dialog_node: "location-done"
607
- )
608
- assert((200..299).cover?(service_response.status))
609
-
610
- service_response = service.delete_dialog_node(
611
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
612
- dialog_node: "location-done"
613
- )
614
- assert(service_response.nil?)
615
-
616
- service_response = service.get_dialog_node(
617
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
618
- dialog_node: "Hours of Operation"
619
- )
620
- assert((200..299).cover?(service_response.status))
621
-
622
- service_response = service.list_dialog_nodes(
623
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"]
624
- )
625
- assert((200..299).cover?(service_response.status))
626
- end
592
+ def test_dialog_nodes
593
+ service = IBMWatson::AssistantV1.new(
594
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
595
+ url: ENV["ASSISTANT_IAM_URL"],
596
+ version: "2018-02-16"
597
+ )
598
+ service.add_default_headers(
599
+ headers: {
600
+ "X-Watson-Learning-Opt-Out" => "1",
601
+ "X-Watson-Test" => "1"
602
+ }
603
+ )
604
+
605
+ service_response = service.create_dialog_node(
606
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
607
+ dialog_node: "location-done"
608
+ )
609
+ assert((200..299).cover?(service_response.status))
610
+
611
+ service_response = service.delete_dialog_node(
612
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
613
+ dialog_node: "location-done"
614
+ )
615
+ assert(service_response.nil?)
616
+
617
+ service_response = service.get_dialog_node(
618
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
619
+ dialog_node: "Hours of Operation"
620
+ )
621
+ assert((200..299).cover?(service_response.status))
622
+
623
+ service_response = service.list_dialog_nodes(
624
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"]
625
+ )
626
+ assert((200..299).cover?(service_response.status))
627
+ end
627
628
 
628
- def test_delete_user_data
629
- service = IBMWatson::AssistantV1.new(
630
- iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
631
- url: ENV["ASSISTANT_IAM_URL"],
632
- version: "2018-02-16"
633
- )
634
- service.add_default_headers(
635
- headers: {
636
- "X-Watson-Learning-Opt-Out" => "1",
637
- "X-Watson-Test" => "1"
638
- }
639
- )
640
- service_response = service.delete_user_data(
641
- customer_id: "id"
642
- )
643
- assert(service_response.nil?)
644
- end
629
+ def test_delete_user_data
630
+ service = IBMWatson::AssistantV1.new(
631
+ iam_api_key: ENV["ASSISTANT_IAM_APIKEY"],
632
+ url: ENV["ASSISTANT_IAM_URL"],
633
+ version: "2018-02-16"
634
+ )
635
+ service.add_default_headers(
636
+ headers: {
637
+ "X-Watson-Learning-Opt-Out" => "1",
638
+ "X-Watson-Test" => "1"
639
+ }
640
+ )
641
+ service_response = service.delete_user_data(
642
+ customer_id: "id"
643
+ )
644
+ assert(service_response.nil?)
645
+ end
645
646
 
646
- def test_get_workspace_with_iam_user_pass_params
647
- service = IBMWatson::AssistantV1.new(
648
- username: "apikey",
649
- password: ENV["ASSISTANT_IAM_APIKEY"],
650
- url: ENV["ASSISTANT_IAM_URL"],
651
- version: "2018-02-16"
652
- )
653
- service.add_default_headers(
654
- headers: {
655
- "X-Watson-Learning-Opt-Out" => "1",
656
- "X-Watson-Test" => "1"
657
- }
658
- )
659
- service_response = service.get_workspace(
660
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
661
- export: false
662
- )
663
- assert((200..299).cover?(service_response.status))
664
- end
647
+ def test_get_workspace_with_iam_user_pass_params
648
+ service = IBMWatson::AssistantV1.new(
649
+ username: "apikey",
650
+ password: ENV["ASSISTANT_IAM_APIKEY"],
651
+ url: ENV["ASSISTANT_IAM_URL"],
652
+ version: "2018-02-16"
653
+ )
654
+ service.add_default_headers(
655
+ headers: {
656
+ "X-Watson-Learning-Opt-Out" => "1",
657
+ "X-Watson-Test" => "1"
658
+ }
659
+ )
660
+ service_response = service.get_workspace(
661
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
662
+ export: false
663
+ )
664
+ assert((200..299).cover?(service_response.status))
665
+ end
665
666
 
666
- def test_get_workspace_with_iam_user_pass_non_params
667
- service = IBMWatson::AssistantV1.new(
668
- url: ENV["ASSISTANT_IAM_URL"],
669
- version: "2018-02-16"
670
- )
671
- service.add_default_headers(
672
- headers: {
673
- "X-Watson-Learning-Opt-Out" => "1",
674
- "X-Watson-Test" => "1"
675
- }
676
- )
677
- service.username = "apikey"
678
- service.password = ENV["ASSISTANT_IAM_APIKEY"]
679
- service_response = service.get_workspace(
680
- workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
681
- export: false
682
- )
683
- assert((200..299).cover?(service_response.status))
684
- end
667
+ def test_get_workspace_with_iam_user_pass_non_params
668
+ service = IBMWatson::AssistantV1.new(
669
+ url: ENV["ASSISTANT_IAM_URL"],
670
+ version: "2018-02-16"
671
+ )
672
+ service.add_default_headers(
673
+ headers: {
674
+ "X-Watson-Learning-Opt-Out" => "1",
675
+ "X-Watson-Test" => "1"
676
+ }
677
+ )
678
+ service.username = "apikey"
679
+ service.password = ENV["ASSISTANT_IAM_APIKEY"]
680
+ service_response = service.get_workspace(
681
+ workspace_id: ENV["ASSISTANT_IAM_WORKSPACE_ID"],
682
+ export: false
683
+ )
684
+ assert((200..299).cover?(service_response.status))
685
+ end
685
686
 
686
- def test_receive_error
687
- service = IBMWatson::AssistantV1.new(
688
- url: ENV["ASSISTANT_IAM_URL"],
689
- version: "2018-02-16"
690
- )
691
- service.add_default_headers(
692
- headers: {
693
- "X-Watson-Learning-Opt-Out" => "1",
694
- "X-Watson-Test" => "1"
695
- }
696
- )
697
- error_received = false
698
- begin
699
- service._iam_api_key(iam_api_key: "bogus_api_key")
700
- service.list_workspaces
701
- rescue WatsonApiException => e
702
- assert_equal("Provided API key could not be found", e.info["errorMessage"])
703
- error_received = true
687
+ def test_receive_error
688
+ service = IBMWatson::AssistantV1.new(
689
+ url: ENV["ASSISTANT_IAM_URL"],
690
+ version: "2018-02-16"
691
+ )
692
+ service.add_default_headers(
693
+ headers: {
694
+ "X-Watson-Learning-Opt-Out" => "1",
695
+ "X-Watson-Test" => "1"
696
+ }
697
+ )
698
+ error_received = false
699
+ begin
700
+ service._iam_api_key(iam_api_key: "bogus_api_key")
701
+ service.list_workspaces
702
+ rescue WatsonApiException => e
703
+ assert_equal("Provided API key could not be found", e.info["errorMessage"])
704
+ error_received = true
705
+ end
706
+ assert(error_received)
704
707
  end
705
- assert(error_received)
706
708
  end
707
709
  end