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.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/bin/console +1 -0
- data/lib/ibm_watson/iam_token_manager.rb +7 -7
- data/lib/ibm_watson/version.rb +3 -1
- data/lib/ibm_watson/watson_service.rb +2 -2
- data/lib/ibm_watson/websocket/speech_to_text_websocket_listener.rb +3 -3
- data/rakefile +1 -1
- data/test/integration/test_assistant_v1.rb +640 -638
- data/test/integration/test_discovery_v1.rb +173 -170
- data/test/integration/test_iam_assistant_v1.rb +674 -672
- data/test/integration/test_language_translator_v3.rb +68 -66
- data/test/integration/test_natural_language_classifier_v1.rb +57 -55
- data/test/integration/test_natural_language_understanding_v1.rb +89 -87
- data/test/integration/test_personality_insights_v3.rb +87 -85
- data/test/integration/test_speech_to_text_v1.rb +143 -142
- data/test/integration/test_text_to_speech_v1.rb +71 -69
- data/test/integration/test_tone_analyzer_v3.rb +65 -63
- data/test/integration/test_visual_recognition_v3.rb +53 -51
- data/test/test_helper.rb +0 -1
- metadata +4 -18
@@ -3,643 +3,645 @@
|
|
3
3
|
require_relative("./../test_helper.rb")
|
4
4
|
SimpleCov.command_name "test:integration"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
6
|
+
unless ENV["ASSISTANT_USERNAME"].nil? || ENV["ASSISTANT_PASSWORD"].nil?
|
7
|
+
# Integration tests for the Watson Assistant V1 Service
|
8
|
+
class AssistantV1Test < Minitest::Test
|
9
|
+
def test_create_update_delete_workspace
|
10
|
+
service = IBMWatson::AssistantV1.new(
|
11
|
+
username: ENV["ASSISTANT_USERNAME"],
|
12
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
13
|
+
version: "2018-02-16"
|
14
|
+
)
|
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
|
44
|
+
|
45
|
+
def test_get_workspace
|
46
|
+
service = IBMWatson::AssistantV1.new(
|
47
|
+
username: ENV["ASSISTANT_USERNAME"],
|
48
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
59
|
+
export: false
|
60
|
+
)
|
61
|
+
assert((200..299).cover?(service_response.status))
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_list_workspaces
|
65
|
+
service = IBMWatson::AssistantV1.new(
|
66
|
+
username: ENV["ASSISTANT_USERNAME"],
|
67
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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
|
79
|
+
|
80
|
+
def test_create_update_delete_counterexample
|
81
|
+
service = IBMWatson::AssistantV1.new(
|
82
|
+
version: "2018-02-16",
|
83
|
+
username: ENV["ASSISTANT_USERNAME"],
|
84
|
+
password: ENV["ASSISTANT_PASSWORD"]
|
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_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_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_WORKSPACE_ID"],
|
107
|
+
text: "I want a large pizza please."
|
108
|
+
)
|
109
|
+
assert(service_response.nil?)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_get_counterexample
|
113
|
+
service = IBMWatson::AssistantV1.new(
|
114
|
+
username: ENV["ASSISTANT_USERNAME"],
|
115
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
126
|
+
text: "what is your nickname"
|
127
|
+
)
|
128
|
+
assert((200..299).cover?(service_response.status))
|
129
|
+
end
|
130
|
+
|
131
|
+
def test_list_counterexamples
|
132
|
+
service = IBMWatson::AssistantV1.new(
|
133
|
+
username: ENV["ASSISTANT_USERNAME"],
|
134
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"]
|
145
|
+
)
|
146
|
+
assert((200..299).cover?(service_response.status))
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_create_update_delete_entity
|
150
|
+
service = IBMWatson::AssistantV1.new(
|
151
|
+
username: ENV["ASSISTANT_USERNAME"],
|
152
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_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_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_WORKSPACE_ID"],
|
180
|
+
entity: "pizza_toppings"
|
181
|
+
)
|
182
|
+
assert(service_response.nil?)
|
183
|
+
end
|
184
|
+
|
185
|
+
def test_get_entity
|
186
|
+
service = IBMWatson::AssistantV1.new(
|
187
|
+
username: ENV["ASSISTANT_USERNAME"],
|
188
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
199
|
+
entity: "holiday",
|
200
|
+
export: true
|
201
|
+
)
|
202
|
+
assert((200..299).cover?(service_response.status))
|
203
|
+
end
|
204
|
+
|
205
|
+
def test_list_entities
|
206
|
+
service = IBMWatson::AssistantV1.new(
|
207
|
+
username: ENV["ASSISTANT_USERNAME"],
|
208
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
219
|
+
export: true
|
220
|
+
)
|
221
|
+
assert((200..299).cover?(service_response.status))
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_create_update_delete_example
|
225
|
+
service = IBMWatson::AssistantV1.new(
|
226
|
+
username: ENV["ASSISTANT_USERNAME"],
|
227
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_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_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_WORKSPACE_ID"],
|
253
|
+
intent: "Cancel",
|
254
|
+
text: "Gimme a pizza with pepperoni"
|
255
|
+
)
|
256
|
+
assert(service_response.nil?)
|
257
|
+
end
|
258
|
+
|
259
|
+
def test_get_example
|
260
|
+
service = IBMWatson::AssistantV1.new(
|
261
|
+
username: ENV["ASSISTANT_USERNAME"],
|
262
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
273
|
+
intent: "Cancel",
|
274
|
+
text: "forget it"
|
275
|
+
)
|
276
|
+
assert((200..299).cover?(service_response.status))
|
277
|
+
end
|
278
|
+
|
279
|
+
def test_list_examples
|
280
|
+
service = IBMWatson::AssistantV1.new(
|
281
|
+
username: ENV["ASSISTANT_USERNAME"],
|
282
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
293
|
+
intent: "Cancel"
|
294
|
+
)
|
295
|
+
assert((200..299).cover?(service_response.status))
|
296
|
+
end
|
297
|
+
|
298
|
+
def test_create_update_delete_intent
|
299
|
+
service = IBMWatson::AssistantV1.new(
|
300
|
+
username: ENV["ASSISTANT_USERNAME"],
|
301
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_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_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_WORKSPACE_ID"],
|
327
|
+
intent: "pizza_order"
|
328
|
+
)
|
329
|
+
assert(service_response.nil?)
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_get_intent
|
333
|
+
service = IBMWatson::AssistantV1.new(
|
334
|
+
username: ENV["ASSISTANT_USERNAME"],
|
335
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
346
|
+
intent: "Cancel",
|
347
|
+
export: false
|
348
|
+
)
|
349
|
+
assert((200..299).cover?(service_response.status))
|
350
|
+
end
|
351
|
+
|
352
|
+
def test_list_intents
|
353
|
+
service = IBMWatson::AssistantV1.new(
|
354
|
+
username: ENV["ASSISTANT_USERNAME"],
|
355
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
366
|
+
export: false
|
367
|
+
)
|
368
|
+
assert((200..299).cover?(service_response.status))
|
369
|
+
end
|
370
|
+
|
371
|
+
def test_list_logs
|
372
|
+
service = IBMWatson::AssistantV1.new(
|
373
|
+
username: ENV["ASSISTANT_USERNAME"],
|
374
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"]
|
385
|
+
)
|
386
|
+
assert((200..299).cover?(service_response.status))
|
387
|
+
end
|
388
|
+
|
389
|
+
def test_list_all_logs
|
390
|
+
service = IBMWatson::AssistantV1.new(
|
391
|
+
username: ENV["ASSISTANT_USERNAME"],
|
392
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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
|
406
|
+
|
407
|
+
def test_message
|
408
|
+
service = IBMWatson::AssistantV1.new(
|
409
|
+
username: ENV["ASSISTANT_USERNAME"],
|
410
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_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_WORKSPACE_ID"],
|
429
|
+
input: { "text" => "Turn on the lights" },
|
430
|
+
context: context
|
431
|
+
)
|
432
|
+
assert((200..299).cover?(service_response.status))
|
433
|
+
end
|
434
|
+
|
435
|
+
def test_create_update_delete_synonym
|
436
|
+
service = IBMWatson::AssistantV1.new(
|
437
|
+
username: ENV["ASSISTANT_USERNAME"],
|
438
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_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_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_WORKSPACE_ID"],
|
466
|
+
entity: "holiday",
|
467
|
+
value: "labor day",
|
468
|
+
synonym: "a"
|
469
|
+
)
|
470
|
+
assert(service_response.nil?)
|
471
|
+
end
|
472
|
+
|
473
|
+
def test_get_synonym
|
474
|
+
service = IBMWatson::AssistantV1.new(
|
475
|
+
username: ENV["ASSISTANT_USERNAME"],
|
476
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
487
|
+
entity: "holiday",
|
488
|
+
value: "thanksgiving",
|
489
|
+
synonym: "turkey day"
|
490
|
+
)
|
491
|
+
assert((200..299).cover?(service_response.status))
|
492
|
+
end
|
493
|
+
|
494
|
+
def test_list_synonyms
|
495
|
+
service = IBMWatson::AssistantV1.new(
|
496
|
+
username: ENV["ASSISTANT_USERNAME"],
|
497
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
508
|
+
entity: "holiday",
|
509
|
+
value: "new years eve"
|
510
|
+
)
|
511
|
+
assert((200..299).cover?(service_response.status))
|
512
|
+
end
|
513
|
+
|
514
|
+
def test_create_update_delete_value
|
515
|
+
service = IBMWatson::AssistantV1.new(
|
516
|
+
username: ENV["ASSISTANT_USERNAME"],
|
517
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_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_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_WORKSPACE_ID"],
|
545
|
+
entity: "holiday",
|
546
|
+
value: "BBQ sauce"
|
547
|
+
)
|
548
|
+
assert(service_response.nil?)
|
549
|
+
end
|
550
|
+
|
551
|
+
def test_get_value
|
552
|
+
service = IBMWatson::AssistantV1.new(
|
553
|
+
username: ENV["ASSISTANT_USERNAME"],
|
554
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
565
|
+
entity: "holiday",
|
566
|
+
value: "christmas",
|
567
|
+
export: true
|
568
|
+
)
|
569
|
+
assert((200..299).cover?(service_response.status))
|
570
|
+
end
|
571
|
+
|
572
|
+
def test_list_values
|
573
|
+
service = IBMWatson::AssistantV1.new(
|
574
|
+
username: ENV["ASSISTANT_USERNAME"],
|
575
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_WORKSPACE_ID"],
|
586
|
+
entity: "holiday",
|
587
|
+
export: true
|
588
|
+
)
|
589
|
+
assert((200..299).cover?(service_response.status))
|
590
|
+
end
|
591
|
+
|
592
|
+
def test_dialog_nodes
|
593
|
+
service = IBMWatson::AssistantV1.new(
|
594
|
+
username: ENV["ASSISTANT_USERNAME"],
|
595
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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_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_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_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_WORKSPACE_ID"]
|
625
|
+
)
|
626
|
+
assert((200..299).cover?(service_response.status))
|
627
|
+
end
|
628
|
+
|
629
|
+
def test_delete_user_data
|
630
|
+
service = IBMWatson::AssistantV1.new(
|
631
|
+
username: ENV["ASSISTANT_USERNAME"],
|
632
|
+
password: ENV["ASSISTANT_PASSWORD"],
|
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
|
644
646
|
end
|
645
647
|
end
|