ibm_watson 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ibm_watson/assistant_v1.rb +791 -736
  3. data/lib/ibm_watson/assistant_v2.rb +12 -8
  4. data/lib/ibm_watson/common.rb +2 -1
  5. data/lib/ibm_watson/compare_comply_v1.rb +171 -169
  6. data/lib/ibm_watson/discovery_v1.rb +778 -689
  7. data/lib/ibm_watson/language_translator_v3.rb +65 -63
  8. data/lib/ibm_watson/natural_language_classifier_v1.rb +36 -35
  9. data/lib/ibm_watson/natural_language_understanding_v1.rb +28 -25
  10. data/lib/ibm_watson/personality_insights_v3.rb +10 -10
  11. data/lib/ibm_watson/speech_to_text_v1.rb +764 -702
  12. data/lib/ibm_watson/text_to_speech_v1.rb +215 -200
  13. data/lib/ibm_watson/tone_analyzer_v3.rb +10 -9
  14. data/lib/ibm_watson/version.rb +1 -1
  15. data/lib/ibm_watson/visual_recognition_v3.rb +94 -95
  16. data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +1 -1
  17. data/test/integration/test_assistant_v1.rb +18 -289
  18. data/test/integration/test_assistant_v2.rb +21 -31
  19. data/test/integration/test_discovery_v1.rb +21 -18
  20. data/test/integration/test_language_translator_v3.rb +3 -3
  21. data/test/integration/test_natural_language_classifier_v1.rb +3 -3
  22. data/test/integration/test_natural_language_understanding_v1.rb +16 -20
  23. data/test/integration/test_personality_insights_v3.rb +12 -40
  24. data/test/integration/test_speech_to_text_v1.rb +3 -3
  25. data/test/integration/test_text_to_speech_v1.rb +3 -3
  26. data/test/integration/test_tone_analyzer_v3.rb +14 -31
  27. data/test/integration/test_visual_recognition_v3.rb +3 -3
  28. data/test/unit/test_compare_comply_v1.rb +3 -7
  29. data/test/unit/test_discovery_v1.rb +21 -7
  30. data/test/unit/test_language_translator_v3.rb +1 -3
  31. data/test/unit/test_natural_language_classifier_v1.rb +1 -3
  32. data/test/unit/test_speech_to_text_v1.rb +25 -7
  33. data/test/unit/test_text_to_speech_v1.rb +0 -4
  34. data/test/unit/test_visual_recognition_v3.rb +2 -6
  35. metadata +2 -2
@@ -2,23 +2,29 @@
2
2
 
3
3
  require_relative("./../test_helper.rb")
4
4
  SimpleCov.command_name "test:integration"
5
+ require("minitest/hooks/test")
5
6
 
6
- if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
7
+ if !ENV["ASSISTANT_APIKEY"].nil? && !ENV["ASSISTANT_URL"].nil?
7
8
  # Integration tests for the Watson Assistant V1 Service
8
9
  class AssistantV1Test < Minitest::Test
9
- def test_create_update_delete_workspace
10
- skip "Skip to allow for concurrent travis jobs"
11
- service = IBMWatson::AssistantV1.new(
12
- username: ENV["ASSISTANT_USERNAME"],
13
- password: ENV["ASSISTANT_PASSWORD"],
10
+ include Minitest::Hooks
11
+ attr_accessor :service
12
+ def before_all
13
+ @service = IBMWatson::AssistantV1.new(
14
+ iam_apikey: ENV["ASSISTANT_APIKEY"],
15
+ url: ENV["ASSISTANT_URL"],
14
16
  version: "2018-02-16"
15
17
  )
16
- service.add_default_headers(
18
+ @service.add_default_headers(
17
19
  headers: {
18
20
  "X-Watson-Learning-Opt-Out" => "1",
19
21
  "X-Watson-Test" => "1"
20
22
  }
21
23
  )
24
+ end
25
+
26
+ def test_create_update_delete_workspace
27
+ skip "Skip to allow for concurrent travis jobs"
22
28
  service_response = service.create_workspace(
23
29
  name: "Pizza app",
24
30
  description: "Pizza app",
@@ -44,17 +50,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
44
50
  end
45
51
 
46
52
  def test_get_workspace
47
- service = IBMWatson::AssistantV1.new(
48
- username: ENV["ASSISTANT_USERNAME"],
49
- password: ENV["ASSISTANT_PASSWORD"],
50
- version: "2018-02-16"
51
- )
52
- service.add_default_headers(
53
- headers: {
54
- "X-Watson-Learning-Opt-Out" => "1",
55
- "X-Watson-Test" => "1"
56
- }
57
- )
58
53
  service_response = service.get_workspace(
59
54
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
60
55
  export: false
@@ -63,34 +58,12 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
63
58
  end
64
59
 
65
60
  def test_list_workspaces
66
- service = IBMWatson::AssistantV1.new(
67
- username: ENV["ASSISTANT_USERNAME"],
68
- password: ENV["ASSISTANT_PASSWORD"],
69
- version: "2018-02-16"
70
- )
71
- service.add_default_headers(
72
- headers: {
73
- "X-Watson-Learning-Opt-Out" => "1",
74
- "X-Watson-Test" => "1"
75
- }
76
- )
77
61
  service_response = service.list_workspaces
78
62
  assert((200..299).cover?(service_response.status))
79
63
  end
80
64
 
81
65
  def test_create_update_delete_counterexample
82
66
  skip "Skip to allow for concurrent travis jobs"
83
- service = IBMWatson::AssistantV1.new(
84
- version: "2018-02-16",
85
- username: ENV["ASSISTANT_USERNAME"],
86
- password: ENV["ASSISTANT_PASSWORD"]
87
- )
88
- service.add_default_headers(
89
- headers: {
90
- "X-Watson-Learning-Opt-Out" => "1",
91
- "X-Watson-Test" => "1"
92
- }
93
- )
94
67
  service_response = service.create_counterexample(
95
68
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
96
69
  text: "I want a large pizza please."
@@ -104,44 +77,20 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
104
77
  )
105
78
  assert((200..299).cover?(service_response.status))
106
79
 
107
- service_response = service.delete_counterexample(
80
+ service_response = service.get_counterexample(
108
81
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
109
82
  text: "I want a large pizza please."
110
83
  )
111
- assert(service_response.nil?)
112
- end
84
+ assert((200..299).cover?(service_response.status))
113
85
 
114
- def test_get_counterexample
115
- service = IBMWatson::AssistantV1.new(
116
- username: ENV["ASSISTANT_USERNAME"],
117
- password: ENV["ASSISTANT_PASSWORD"],
118
- version: "2018-02-16"
119
- )
120
- service.add_default_headers(
121
- headers: {
122
- "X-Watson-Learning-Opt-Out" => "1",
123
- "X-Watson-Test" => "1"
124
- }
125
- )
126
- service_response = service.get_counterexample(
86
+ service_response = service.delete_counterexample(
127
87
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
128
- text: "what is your nickname"
88
+ text: "I want a large pizza please."
129
89
  )
130
- assert((200..299).cover?(service_response.status))
90
+ assert(service_response.nil?)
131
91
  end
132
92
 
133
93
  def test_list_counterexamples
134
- service = IBMWatson::AssistantV1.new(
135
- username: ENV["ASSISTANT_USERNAME"],
136
- password: ENV["ASSISTANT_PASSWORD"],
137
- version: "2018-02-16"
138
- )
139
- service.add_default_headers(
140
- headers: {
141
- "X-Watson-Learning-Opt-Out" => "1",
142
- "X-Watson-Test" => "1"
143
- }
144
- )
145
94
  service_response = service.list_counterexamples(
146
95
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"]
147
96
  )
@@ -150,17 +99,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
150
99
 
151
100
  def test_create_update_delete_entity
152
101
  skip "Skip to allow for concurrent travis jobs"
153
- service = IBMWatson::AssistantV1.new(
154
- username: ENV["ASSISTANT_USERNAME"],
155
- password: ENV["ASSISTANT_PASSWORD"],
156
- version: "2018-02-16"
157
- )
158
- service.add_default_headers(
159
- headers: {
160
- "X-Watson-Learning-Opt-Out" => "1",
161
- "X-Watson-Test" => "1"
162
- }
163
- )
164
102
  service_response = service.create_entity(
165
103
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
166
104
  entity: "pizza_toppings",
@@ -186,17 +124,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
186
124
  end
187
125
 
188
126
  def test_get_entity
189
- service = IBMWatson::AssistantV1.new(
190
- username: ENV["ASSISTANT_USERNAME"],
191
- password: ENV["ASSISTANT_PASSWORD"],
192
- version: "2018-02-16"
193
- )
194
- service.add_default_headers(
195
- headers: {
196
- "X-Watson-Learning-Opt-Out" => "1",
197
- "X-Watson-Test" => "1"
198
- }
199
- )
200
127
  service_response = service.get_entity(
201
128
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
202
129
  entity: "holiday",
@@ -206,17 +133,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
206
133
  end
207
134
 
208
135
  def test_list_entities
209
- service = IBMWatson::AssistantV1.new(
210
- username: ENV["ASSISTANT_USERNAME"],
211
- password: ENV["ASSISTANT_PASSWORD"],
212
- version: "2018-02-16"
213
- )
214
- service.add_default_headers(
215
- headers: {
216
- "X-Watson-Learning-Opt-Out" => "1",
217
- "X-Watson-Test" => "1"
218
- }
219
- )
220
136
  service_response = service.list_entities(
221
137
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
222
138
  export: true
@@ -226,17 +142,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
226
142
 
227
143
  def test_create_update_delete_example
228
144
  skip "Skip to allow for concurrent travis jobs"
229
- service = IBMWatson::AssistantV1.new(
230
- username: ENV["ASSISTANT_USERNAME"],
231
- password: ENV["ASSISTANT_PASSWORD"],
232
- version: "2018-02-16"
233
- )
234
- service.add_default_headers(
235
- headers: {
236
- "X-Watson-Learning-Opt-Out" => "1",
237
- "X-Watson-Test" => "1"
238
- }
239
- )
240
145
  service_response = service.create_example(
241
146
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
242
147
  intent: "Cancel",
@@ -261,17 +166,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
261
166
  end
262
167
 
263
168
  def test_get_example
264
- service = IBMWatson::AssistantV1.new(
265
- username: ENV["ASSISTANT_USERNAME"],
266
- password: ENV["ASSISTANT_PASSWORD"],
267
- version: "2018-02-16"
268
- )
269
- service.add_default_headers(
270
- headers: {
271
- "X-Watson-Learning-Opt-Out" => "1",
272
- "X-Watson-Test" => "1"
273
- }
274
- )
275
169
  service_response = service.get_example(
276
170
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
277
171
  intent: "Cancel",
@@ -281,17 +175,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
281
175
  end
282
176
 
283
177
  def test_list_examples
284
- service = IBMWatson::AssistantV1.new(
285
- username: ENV["ASSISTANT_USERNAME"],
286
- password: ENV["ASSISTANT_PASSWORD"],
287
- version: "2018-02-16"
288
- )
289
- service.add_default_headers(
290
- headers: {
291
- "X-Watson-Learning-Opt-Out" => "1",
292
- "X-Watson-Test" => "1"
293
- }
294
- )
295
178
  service_response = service.list_examples(
296
179
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
297
180
  intent: "Cancel"
@@ -301,17 +184,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
301
184
 
302
185
  def test_create_update_delete_intent
303
186
  skip "Skip to allow for concurrent travis jobs"
304
- service = IBMWatson::AssistantV1.new(
305
- username: ENV["ASSISTANT_USERNAME"],
306
- password: ENV["ASSISTANT_PASSWORD"],
307
- version: "2018-02-16"
308
- )
309
- service.add_default_headers(
310
- headers: {
311
- "X-Watson-Learning-Opt-Out" => "1",
312
- "X-Watson-Test" => "1"
313
- }
314
- )
315
187
  service_response = service.create_intent(
316
188
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
317
189
  intent: "pizza_order",
@@ -335,17 +207,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
335
207
  end
336
208
 
337
209
  def test_get_intent
338
- service = IBMWatson::AssistantV1.new(
339
- username: ENV["ASSISTANT_USERNAME"],
340
- password: ENV["ASSISTANT_PASSWORD"],
341
- version: "2018-02-16"
342
- )
343
- service.add_default_headers(
344
- headers: {
345
- "X-Watson-Learning-Opt-Out" => "1",
346
- "X-Watson-Test" => "1"
347
- }
348
- )
349
210
  service_response = service.get_intent(
350
211
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
351
212
  intent: "Cancel",
@@ -355,17 +216,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
355
216
  end
356
217
 
357
218
  def test_list_intents
358
- service = IBMWatson::AssistantV1.new(
359
- username: ENV["ASSISTANT_USERNAME"],
360
- password: ENV["ASSISTANT_PASSWORD"],
361
- version: "2018-02-16"
362
- )
363
- service.add_default_headers(
364
- headers: {
365
- "X-Watson-Learning-Opt-Out" => "1",
366
- "X-Watson-Test" => "1"
367
- }
368
- )
369
219
  service_response = service.list_intents(
370
220
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
371
221
  export: false
@@ -374,17 +224,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
374
224
  end
375
225
 
376
226
  def test_list_logs
377
- service = IBMWatson::AssistantV1.new(
378
- username: ENV["ASSISTANT_USERNAME"],
379
- password: ENV["ASSISTANT_PASSWORD"],
380
- version: "2018-02-16"
381
- )
382
- service.add_default_headers(
383
- headers: {
384
- "X-Watson-Learning-Opt-Out" => "1",
385
- "X-Watson-Test" => "1"
386
- }
387
- )
388
227
  service_response = service.list_logs(
389
228
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"]
390
229
  )
@@ -392,17 +231,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
392
231
  end
393
232
 
394
233
  def test_list_all_logs
395
- service = IBMWatson::AssistantV1.new(
396
- username: ENV["ASSISTANT_USERNAME"],
397
- password: ENV["ASSISTANT_PASSWORD"],
398
- version: "2018-02-16"
399
- )
400
- service.add_default_headers(
401
- headers: {
402
- "X-Watson-Learning-Opt-Out" => "1",
403
- "X-Watson-Test" => "1"
404
- }
405
- )
406
234
  service_response = service.list_all_logs(
407
235
  filter: "language::en,request.context.metadata.deployment::deployment_1"
408
236
  )
@@ -410,17 +238,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
410
238
  end
411
239
 
412
240
  def test_message
413
- service = IBMWatson::AssistantV1.new(
414
- username: ENV["ASSISTANT_USERNAME"],
415
- password: ENV["ASSISTANT_PASSWORD"],
416
- version: "2018-02-16"
417
- )
418
- service.add_default_headers(
419
- headers: {
420
- "X-Watson-Learning-Opt-Out" => "1",
421
- "X-Watson-Test" => "1"
422
- }
423
- )
424
241
  service_response = service.message(
425
242
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
426
243
  input: { "text" => "Turn on the lights" },
@@ -439,17 +256,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
439
256
 
440
257
  def test_create_update_delete_synonym
441
258
  skip "Skip to allow for concurrent travis jobs"
442
- service = IBMWatson::AssistantV1.new(
443
- username: ENV["ASSISTANT_USERNAME"],
444
- password: ENV["ASSISTANT_PASSWORD"],
445
- version: "2018-02-16"
446
- )
447
- service.add_default_headers(
448
- headers: {
449
- "X-Watson-Learning-Opt-Out" => "1",
450
- "X-Watson-Test" => "1"
451
- }
452
- )
453
259
  service_response = service.create_synonym(
454
260
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
455
261
  entity: "holiday",
@@ -477,17 +283,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
477
283
  end
478
284
 
479
285
  def test_get_synonym
480
- service = IBMWatson::AssistantV1.new(
481
- username: ENV["ASSISTANT_USERNAME"],
482
- password: ENV["ASSISTANT_PASSWORD"],
483
- version: "2018-02-16"
484
- )
485
- service.add_default_headers(
486
- headers: {
487
- "X-Watson-Learning-Opt-Out" => "1",
488
- "X-Watson-Test" => "1"
489
- }
490
- )
491
286
  service_response = service.get_synonym(
492
287
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
493
288
  entity: "holiday",
@@ -498,17 +293,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
498
293
  end
499
294
 
500
295
  def test_list_synonyms
501
- service = IBMWatson::AssistantV1.new(
502
- username: ENV["ASSISTANT_USERNAME"],
503
- password: ENV["ASSISTANT_PASSWORD"],
504
- version: "2018-02-16"
505
- )
506
- service.add_default_headers(
507
- headers: {
508
- "X-Watson-Learning-Opt-Out" => "1",
509
- "X-Watson-Test" => "1"
510
- }
511
- )
512
296
  service_response = service.list_synonyms(
513
297
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
514
298
  entity: "holiday",
@@ -519,17 +303,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
519
303
 
520
304
  def test_create_update_delete_value
521
305
  skip "Skip to allow for concurrent travis jobs"
522
- service = IBMWatson::AssistantV1.new(
523
- username: ENV["ASSISTANT_USERNAME"],
524
- password: ENV["ASSISTANT_PASSWORD"],
525
- version: "2018-02-16"
526
- )
527
- service.add_default_headers(
528
- headers: {
529
- "X-Watson-Learning-Opt-Out" => "1",
530
- "X-Watson-Test" => "1"
531
- }
532
- )
533
306
  service_response = service.create_value(
534
307
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
535
308
  entity: "holiday",
@@ -556,17 +329,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
556
329
  end
557
330
 
558
331
  def test_get_value
559
- service = IBMWatson::AssistantV1.new(
560
- username: ENV["ASSISTANT_USERNAME"],
561
- password: ENV["ASSISTANT_PASSWORD"],
562
- version: "2018-02-16"
563
- )
564
- service.add_default_headers(
565
- headers: {
566
- "X-Watson-Learning-Opt-Out" => "1",
567
- "X-Watson-Test" => "1"
568
- }
569
- )
570
332
  service_response = service.get_value(
571
333
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
572
334
  entity: "holiday",
@@ -577,17 +339,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
577
339
  end
578
340
 
579
341
  def test_list_values
580
- service = IBMWatson::AssistantV1.new(
581
- username: ENV["ASSISTANT_USERNAME"],
582
- password: ENV["ASSISTANT_PASSWORD"],
583
- version: "2018-02-16"
584
- )
585
- service.add_default_headers(
586
- headers: {
587
- "X-Watson-Learning-Opt-Out" => "1",
588
- "X-Watson-Test" => "1"
589
- }
590
- )
591
342
  service_response = service.list_values(
592
343
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
593
344
  entity: "holiday",
@@ -598,17 +349,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
598
349
 
599
350
  def test_dialog_nodes
600
351
  skip "Skip to allow for concurrent travis jobs"
601
- service = IBMWatson::AssistantV1.new(
602
- username: ENV["ASSISTANT_USERNAME"],
603
- password: ENV["ASSISTANT_PASSWORD"],
604
- version: "2018-02-16"
605
- )
606
- service.add_default_headers(
607
- headers: {
608
- "X-Watson-Learning-Opt-Out" => "1",
609
- "X-Watson-Test" => "1"
610
- }
611
- )
612
352
 
613
353
  service_response = service.create_dialog_node(
614
354
  workspace_id: ENV["ASSISTANT_WORKSPACE_ID"],
@@ -635,17 +375,6 @@ if !ENV["ASSISTANT_USERNAME"].nil? && !ENV["ASSISTANT_PASSWORD"].nil?
635
375
  end
636
376
 
637
377
  def test_delete_user_data
638
- service = IBMWatson::AssistantV1.new(
639
- username: ENV["ASSISTANT_USERNAME"],
640
- password: ENV["ASSISTANT_PASSWORD"],
641
- version: "2018-02-16"
642
- )
643
- service.add_default_headers(
644
- headers: {
645
- "X-Watson-Learning-Opt-Out" => "1",
646
- "X-Watson-Test" => "1"
647
- }
648
- )
649
378
  service_response = service.delete_user_data(
650
379
  customer_id: "id"
651
380
  )
@@ -3,17 +3,17 @@
3
3
  require_relative("./../test_helper.rb")
4
4
  SimpleCov.command_name "test:integration"
5
5
 
6
- if !ENV["ASSISTANT_V2_USERNAME"].nil? && !ENV["ASSISTANT_V2_PASSWORD"].nil?
6
+ if !ENV["ASSISTANT_APIKEY"].nil? && !ENV["ASSISTANT_URL"].nil?
7
7
  # Integration tests for the Watson Assistant V2 Service
8
8
  class AssistantV2Test < Minitest::Test
9
- def test_create_delete_session
10
- # skip "Skip to allow for concurrent travis jobs"
11
- service = IBMWatson::AssistantV2.new(
9
+ include Minitest::Hooks
10
+ attr_accessor :service
11
+ def before_all
12
+ @service = IBMWatson::AssistantV2.new(
12
13
  version: "2018-12-31",
13
- username: ENV["ASSISTANT_V2_USERNAME"],
14
- password: ENV["ASSISTANT_V2_PASSWORD"],
15
- url: ENV["ASSISTANT_V2_URL"],
16
- assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"]
14
+ iam_apikey: ENV["ASSISTANT_APIKEY"],
15
+ url: ENV["ASSISTANT_URL"],
16
+ assistant_id: ENV["ASSISTANT_ASSISTANT_ID"]
17
17
  )
18
18
  service.add_default_headers(
19
19
  headers: {
@@ -21,33 +21,18 @@ if !ENV["ASSISTANT_V2_USERNAME"].nil? && !ENV["ASSISTANT_V2_PASSWORD"].nil?
21
21
  "X-Watson-Test" => "1"
22
22
  }
23
23
  )
24
+ end
25
+
26
+ def test_create_delete_session_and_message
24
27
  service_response = service.create_session(
25
- assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"]
28
+ assistant_id: ENV["ASSISTANT_ASSISTANT_ID"]
26
29
  )
27
30
  session_id = service_response.result["session_id"]
28
31
  assert((200..299).cover?(service_response.status))
29
- service.delete_session(
30
- assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"],
31
- session_id: session_id
32
- )
33
- end
34
32
 
35
- def test_message
36
- service = IBMWatson::AssistantV2.new(
37
- username: ENV["ASSISTANT_V2_USERNAME"],
38
- password: ENV["ASSISTANT_V2_PASSWORD"],
39
- version: "2018-02-16",
40
- url: ENV["ASSISTANT_V2_URL"]
41
- )
42
- service.add_default_headers(
43
- headers: {
44
- "X-Watson-Learning-Opt-Out" => "1",
45
- "X-Watson-Test" => "1"
46
- }
47
- )
48
33
  service_response = service.message(
49
- assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"],
50
- session_id: ENV["ASSISTANT_V2_SESSION_ID"],
34
+ assistant_id: ENV["ASSISTANT_ASSISTANT_ID"],
35
+ session_id: session_id,
51
36
  input: { "text" => "Turn on the lights" },
52
37
  context: nil
53
38
  )
@@ -55,12 +40,17 @@ if !ENV["ASSISTANT_V2_USERNAME"].nil? && !ENV["ASSISTANT_V2_PASSWORD"].nil?
55
40
 
56
41
  context = service_response.result["context"]
57
42
  service_response = service.message(
58
- assistant_id: ENV["ASSISTANT_V2_ASSISTANT_ID"],
59
- session_id: ENV["ASSISTANT_V2_SESSION_ID"],
43
+ assistant_id: ENV["ASSISTANT_ASSISTANT_ID"],
44
+ session_id: session_id,
60
45
  input: { "text" => "Turn on the lights" },
61
46
  context: context
62
47
  )
63
48
  assert((200..299).cover?(service_response.status))
49
+
50
+ service.delete_session(
51
+ assistant_id: ENV["ASSISTANT_ASSISTANT_ID"],
52
+ session_id: session_id
53
+ )
64
54
  end
65
55
  end
66
56
  end
@@ -3,7 +3,7 @@
3
3
  require_relative("./../test_helper.rb")
4
4
  require("minitest/hooks/test")
5
5
 
6
- if !ENV["DISCOVERY_USERNAME"].nil? && !ENV["DISCOVERY_PASSWORD"].nil?
6
+ if !ENV["DISCOVERY_APIKEY"].nil? && !ENV["DISCOVERY_URL"].nil?
7
7
  # Integration tests for the Discovery V1 Service
8
8
  class DiscoveryV1Test < Minitest::Test
9
9
  include Minitest::Hooks
@@ -11,8 +11,8 @@ if !ENV["DISCOVERY_USERNAME"].nil? && !ENV["DISCOVERY_PASSWORD"].nil?
11
11
 
12
12
  def before_all
13
13
  @service = IBMWatson::DiscoveryV1.new(
14
- username: ENV["DISCOVERY_USERNAME"],
15
- password: ENV["DISCOVERY_PASSWORD"],
14
+ iam_apikey: ENV["DISCOVERY_APIKEY"],
15
+ url: ENV["DISCOVERY_URL"],
16
16
  version: "2018-03-05"
17
17
  )
18
18
  @environment_id = ENV["DISCOVERY_ENVIRONMENT_ID"]
@@ -32,11 +32,6 @@ if !ENV["DISCOVERY_USERNAME"].nil? && !ENV["DISCOVERY_PASSWORD"].nil?
32
32
  environment_id: envs["environments"][0]["environment_id"]
33
33
  )
34
34
  refute(env.nil?)
35
- fields = @service.list_fields(
36
- environment_id: @environment_id,
37
- collection_ids: [@collection_id]
38
- )
39
- refute(fields.nil?)
40
35
  end
41
36
 
42
37
  def test_configurations
@@ -75,7 +70,7 @@ if !ENV["DISCOVERY_USERNAME"].nil? && !ENV["DISCOVERY_PASSWORD"].nil?
75
70
  assert_equal("deleted", deleted_config["status"])
76
71
  end
77
72
 
78
- def test_collections_and_expansions
73
+ def test_collections_fields_query_and_expansions
79
74
  skip "Time consuming"
80
75
  name = "Example collection for ruby" + ("A".."Z").to_a.sample
81
76
  new_collection_id = @service.create_collection(
@@ -104,6 +99,20 @@ if !ENV["DISCOVERY_USERNAME"].nil? && !ENV["DISCOVERY_PASSWORD"].nil?
104
99
  updated_collection = updated_collection
105
100
  assert_equal("Updating description", updated_collection["description"])
106
101
 
102
+ fields = @service.list_fields(
103
+ environment_id: @environment_id,
104
+ collection_ids: [new_collection_id]
105
+ )
106
+ refute(fields.nil?)
107
+
108
+ query_results = @service.query(
109
+ environment_id: @environment_id,
110
+ collection_id: new_collection_id,
111
+ filter: "extracted_metadata.sha1::9181d244*",
112
+ return_fields: "extracted_metadata.sha1"
113
+ ).result
114
+ refute(query_results.nil?)
115
+
107
116
  @service.create_expansions(
108
117
  environment_id: @environment_id,
109
118
  collection_id: new_collection_id,
@@ -191,15 +200,8 @@ if !ENV["DISCOVERY_USERNAME"].nil? && !ENV["DISCOVERY_PASSWORD"].nil?
191
200
  assert_equal("deleted", delete_doc["status"])
192
201
  end
193
202
 
194
- def test_queries
195
- query_results = @service.query(
196
- environment_id: @environment_id,
197
- collection_id: @collection_id,
198
- filter: "extracted_metadata.sha1::9181d244*",
199
- return_fields: "extracted_metadata.sha1"
200
- ).result
201
- refute(query_results.nil?)
202
- end
203
+ # def test_queries
204
+ # end
203
205
 
204
206
  def test_list_credentials
205
207
  credentials = @service.list_credentials(
@@ -216,6 +218,7 @@ if !ENV["DISCOVERY_USERNAME"].nil? && !ENV["DISCOVERY_PASSWORD"].nil?
216
218
  end
217
219
 
218
220
  def test_create_get_delete_gateways
221
+ skip
219
222
  gateway = @service.create_gateway(
220
223
  environment_id: @environment_id,
221
224
  name: "test"
@@ -4,15 +4,15 @@ require("json")
4
4
  require_relative("./../test_helper.rb")
5
5
  require("minitest/hooks/test")
6
6
 
7
- if !ENV["LANGUAGE_TRANSLATOR_V3_USERNAME"].nil? && !ENV["LANGUAGE_TRANSLATOR_V3_PASSWORD"].nil?
7
+ if !ENV["LANGUAGE_TRANSLATOR_APIKEY"].nil? && !ENV["LANGUAGE_TRANSLATOR_URL"].nil?
8
8
  # Integration tests for the Language Translator V3 Service
9
9
  class LanguageTranslatorV3Test < Minitest::Test
10
10
  include Minitest::Hooks
11
11
  attr_accessor :service
12
12
  def before_all
13
13
  @service = IBMWatson::LanguageTranslatorV3.new(
14
- username: ENV["LANGUAGE_TRANSLATOR_V3_USERNAME"],
15
- password: ENV["LANGUAGE_TRANSLATOR_V3_PASSWORD"],
14
+ iam_apikey: ENV["LANGUAGE_TRANSLATOR_APIKEY"],
15
+ url: ENV["LANGUAGE_TRANSLATOR_URL"],
16
16
  version: "2018-05-01"
17
17
  )
18
18
  @service.add_default_headers(