Skip to content

Commit 789af68

Browse files
authored
test: update tests for new auth.js format and remove detect faces tests (watson-developer-cloud#964)
1 parent 93eb677 commit 789af68

13 files changed

+71
-105
lines changed

secrets.tar.enc

0 Bytes
Binary file not shown.

test/integration/assistant.v1.test.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const AssistantV1 = require('../../assistant/v1');
44
const authHelper = require('../resources/auth_helper.js');
5-
const auth = authHelper.auth;
65
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
76
const assign = require('object.assign'); // for node v0.12 compatibility
87
const serviceErrorUtils = require('../resources/service_error_util');
@@ -100,10 +99,16 @@ const test_dialog_node_update = 'updated_node';
10099
// changing language is forbidden starting with VERSION_DATE_2017_05_26
101100
const workspace1 = extend(true, {}, workspace, intents, { language: workspace.language });
102101

102+
// extract service params from auth.js
103+
103104
describe('assistant_integration', function() {
104105
jest.setTimeout(TEN_SECONDS);
105-
auth.assistant.version = '2019-03-27';
106-
const assistant = new AssistantV1(auth.assistant);
106+
const auth = authHelper.auth.assistant;
107+
const { workspaceId } = auth;
108+
109+
auth.version = '2019-03-27';
110+
auth.iam_apikey = auth.apikey;
111+
const assistant = new AssistantV1(auth);
107112

108113
describe('message()', function() {
109114
it('alternate_intents with custom headers', function(done) {
@@ -112,7 +117,7 @@ describe('assistant_integration', function() {
112117
text: 'Turn on the lights',
113118
},
114119
alternate_intents: true,
115-
workspace_id: auth.assistant.workspace_id,
120+
workspace_id: workspaceId,
116121
headers: {
117122
customheader: 'custom',
118123
},
@@ -133,7 +138,7 @@ describe('assistant_integration', function() {
133138
});
134139

135140
it('dialog_stack with 2017-02-03 version', function(done) {
136-
const constructorParams = assign({}, auth.assistant, {
141+
const constructorParams = assign({}, auth, {
137142
version: '2017-02-03',
138143
});
139144
const assistant = new AssistantV1(constructorParams);
@@ -142,7 +147,7 @@ describe('assistant_integration', function() {
142147
input: {
143148
text: 'Turn on the lights',
144149
},
145-
workspace_id: auth.assistant.workspace_id,
150+
workspace_id: workspaceId,
146151
};
147152

148153
assistant.message(
@@ -160,7 +165,7 @@ describe('assistant_integration', function() {
160165
});
161166

162167
it('dialog_stack with 2016-09-20 version', function(done) {
163-
const constructorParams = assign({}, auth.assistant, {
168+
const constructorParams = assign({}, auth, {
164169
version: '2016-09-20',
165170
});
166171
const assistant = new AssistantV1(constructorParams);
@@ -169,7 +174,7 @@ describe('assistant_integration', function() {
169174
input: {
170175
text: 'Turn on the lights',
171176
},
172-
workspace_id: auth.assistant.workspace_id,
177+
workspace_id: workspaceId,
173178
};
174179

175180
assistant.message(
@@ -187,7 +192,7 @@ describe('assistant_integration', function() {
187192
});
188193

189194
it('dialog_stack with 2016-07-11 version', function(done) {
190-
const constructorParams = assign({}, auth.assistant, {
195+
const constructorParams = assign({}, auth, {
191196
version: '2016-07-11',
192197
});
193198
const assistant = new AssistantV1(constructorParams);
@@ -196,7 +201,7 @@ describe('assistant_integration', function() {
196201
input: {
197202
text: 'Turn on the lights',
198203
},
199-
workspace_id: auth.assistant.workspace_id,
204+
workspace_id: workspaceId,
200205
};
201206

202207
assistant.message(

test/integration/assistant.v2.test.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22

33
const AssistantV2 = require('../../assistant/v2');
44
const authHelper = require('../resources/auth_helper.js');
5-
const auth = authHelper.auth;
65
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
76
const serviceErrorUtils = require('../resources/service_error_util');
87

98
describe('assistant v2 integration', function() {
10-
auth.assistant.version = '2019-03-27';
11-
const assistant = new AssistantV2(auth.assistant);
12-
const assistant_id = auth.assistant.assistant_id;
9+
const auth = authHelper.auth.assistant;
10+
auth.version = '2019-03-27';
11+
auth.iam_apikey = auth.apikey;
12+
const assistant = new AssistantV2(auth);
13+
const assistant_id = auth.assistantId;
1314
let session_id;
1415

1516
it('should createSession', function(done) {
@@ -95,7 +96,7 @@ describe('assistant v2 integration', function() {
9596
}
9697

9798
const params = {
98-
assistant_id: auth.assistant.assistant_id,
99+
assistant_id,
99100
session_id,
100101
};
101102
assistant.deleteSession(

test/integration/compare_comply.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
const fs = require('fs');
44
const CompareComply = require('../../compare-comply/v1');
55
const authHelper = require('../resources/auth_helper.js');
6-
const auth = authHelper.auth;
76
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
87
const serviceErrorUtils = require('../resources/service_error_util');
98

109
describe('compare_comply_integration', () => {
11-
const compare_comply = new CompareComply(auth.compare_comply);
10+
const auth = authHelper.auth.compare_comply;
11+
auth.iam_apikey = auth.apikey;
12+
const compare_comply = new CompareComply(auth);
1213
describe('html conversion @slow', () => {
1314
test('convertToHtml', done => {
1415
const params = {

test/integration/discovery.test.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
const DiscoveryV1 = require('../../discovery/v1');
44
const authHelper = require('../resources/auth_helper.js');
5-
const auth = authHelper.auth;
65
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
76
const async = require('async');
87
const fs = require('fs');
@@ -14,14 +13,17 @@ const THIRTY_SECONDS = 30000;
1413
describe('discovery_integration', function() {
1514
jest.setTimeout(THIRTY_SECONDS);
1615

17-
const environment_id = auth.discovery.environment_id;
18-
const configuration_id = auth.discovery.configuration_id;
19-
const collection_id = auth.discovery.collection_id;
20-
const collection_id2 = auth.discovery.collection_id_2;
21-
const japanese_collection_id = auth.discovery.japanese_collection_id;
16+
const auth = authHelper.auth.discovery;
17+
const environment_id = auth.environmentId;
18+
const configuration_id = auth.configurationId;
19+
const collection_id = auth.collectionId;
20+
const collection_id2 = auth.collectionId2;
21+
const japanese_collection_id = auth.japaneseCollectionId;
22+
23+
auth.iam_apikey = auth.apikey;
2224

2325
const discovery = new DiscoveryV1(
24-
Object.assign({}, auth.discovery, {
26+
Object.assign({}, auth, {
2527
version: '2019-03-27',
2628
})
2729
);

test/integration/language_translator.v3.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const fs = require('fs');
44
const LanguageTranslatorV3 = require('../../language-translator/v3');
55
const authHelper = require('../resources/auth_helper.js');
6-
const auth = authHelper.auth;
76
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
87
const TWENTY_SECONDS = 20000;
98
const serviceErrorUtils = require('../resources/service_error_util');
@@ -12,8 +11,10 @@ const serviceErrorUtils = require('../resources/service_error_util');
1211
describe('language_translator_integration', function() {
1312
jest.setTimeout(TWENTY_SECONDS * 2);
1413

15-
auth.language_translator.version = '2019-03-27';
16-
const language_translator = new LanguageTranslatorV3(auth.language_translator);
14+
const auth = authHelper.auth.language_translator;
15+
auth.version = '2019-03-27';
16+
auth.iam_apikey = auth.apikey;
17+
const language_translator = new LanguageTranslatorV3(auth);
1718

1819
it('listModels()', function(done) {
1920
language_translator.listModels(null, serviceErrorUtils.checkErrorCode(200, done));

test/integration/natural_language_classifier.test.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,22 @@
22

33
const NaturalLanguageClassifierV1 = require('../../natural-language-classifier/v1');
44
const authHelper = require('../resources/auth_helper.js');
5-
const auth = authHelper.auth;
65
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
76
const TWENTY_SECONDS = 20000;
87
const serviceErrorUtils = require('../resources/service_error_util');
98

109
describe('natural_language_classifier_integration', function() {
1110
jest.setTimeout(TWENTY_SECONDS);
1211

13-
const natural_language_classifier = new NaturalLanguageClassifierV1(
14-
auth.natural_language_classifier
15-
);
12+
const auth = authHelper.auth.natural_language_classifier;
13+
auth.iam_apikey = auth.apikey;
14+
const natural_language_classifier = new NaturalLanguageClassifierV1(auth);
15+
16+
const classifier_id = auth.classifierId;
1617

1718
it('getClassifier', function(done) {
1819
const params = {
19-
classifier_id: auth.natural_language_classifier.classifier_id,
20+
classifier_id,
2021
};
2122
natural_language_classifier.getClassifier(
2223
params,
@@ -29,7 +30,7 @@ describe('natural_language_classifier_integration', function() {
2930

3031
it('classifyCollection', function(done) {
3132
const params = {
32-
classifier_id: auth.natural_language_classifier.classifier_id,
33+
classifier_id,
3334
collection: [{ text: 'string' }],
3435
};
3536
natural_language_classifier.classifyCollection(

test/integration/personality_insights.v3.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const fs = require('fs');
44
const PersonalityInsightsV3 = require('../../personality-insights/v3');
55
const path = require('path');
66
const authHelper = require('../resources/auth_helper.js');
7-
const auth = authHelper.auth;
87
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
98
const TWENTY_SECONDS = 20000;
109
const serviceErrorUtils = require('../resources/service_error_util');
@@ -13,8 +12,10 @@ describe('personality_insights_v3_integration', function() {
1312
jest.setTimeout(TWENTY_SECONDS);
1413

1514
const mobydick = fs.readFileSync(path.join(__dirname, '../resources/mobydick.txt'), 'utf8');
16-
auth.personality_insights.version = '2019-03-27';
17-
const personality_insights = new PersonalityInsightsV3(auth.personality_insights);
15+
const auth = authHelper.auth.personality_insights;
16+
auth.version = '2019-03-27';
17+
auth.iam_apikey = auth.apikey;
18+
const personality_insights = new PersonalityInsightsV3(auth);
1819

1920
it('profile with text content', function(done) {
2021
const params = {

test/integration/speech_to_text.test.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

33
const authHelper = require('../resources/auth_helper.js');
4-
const auth = authHelper.auth;
54
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
65
const SpeechToTextV1 = require('../../speech-to-text/v1');
76
const fs = require('fs');
@@ -16,7 +15,9 @@ const TWO_MINUTES = 2 * 60 * 1000;
1615
describe('speech_to_text_integration', function() {
1716
jest.setTimeout(TWENTY_SECONDS);
1817

19-
const speech_to_text = new SpeechToTextV1(auth.speech_to_text);
18+
const auth = authHelper.auth.speech_to_text;
19+
auth.iam_apikey = auth.apikey;
20+
const speech_to_text = new SpeechToTextV1(auth);
2021

2122
it('recognize()', function(done) {
2223
const params = {
@@ -109,8 +110,8 @@ describe('speech_to_text_integration', function() {
109110
});
110111

111112
it('transcribes audio over a websocket, credentials from environment', function(done) {
112-
process.env.SPEECH_TO_TEXT_IAM_APIKEY = auth.speech_to_text.iam_apikey;
113-
process.env.SPEECH_TO_TEXT_URL = auth.speech_to_text.url;
113+
process.env.SPEECH_TO_TEXT_IAM_APIKEY = auth.apikey;
114+
process.env.SPEECH_TO_TEXT_URL = auth.url;
114115
const speech_to_text_env = new SpeechToTextV1({});
115116
const recognizeStream = speech_to_text_env.recognizeUsingWebSocket();
116117
recognizeStream.setEncoding('utf8');
@@ -133,8 +134,8 @@ describe('speech_to_text_integration', function() {
133134
speech_to_text: [
134135
{
135136
credentials: {
136-
iam_apikey: auth.speech_to_text.iam_apikey,
137-
url: auth.speech_to_text.url,
137+
iam_apikey: auth.apikey,
138+
url: auth.url,
138139
},
139140
},
140141
],
@@ -211,7 +212,7 @@ describe('speech_to_text_integration', function() {
211212
}
212213

213214
beforeAll(function(done) {
214-
const speech_to_text = new SpeechToTextV1(auth.speech_to_text);
215+
const speech_to_text = new SpeechToTextV1(auth);
215216
speech_to_text.listLanguageModels({}, function(err, result) {
216217
if (err) {
217218
// eslint-disable-next-line no-console

test/integration/text_to_speech.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
const TextToSpeechV1 = require('../../text-to-speech/v1');
44
const wav = require('wav');
55
const authHelper = require('../resources/auth_helper.js');
6-
const auth = authHelper.auth;
76
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
87
const TWENTY_SECONDS = 20000;
98
const serviceErrorUtils = require('../resources/service_error_util');
109

1110
describe('text_to_speech_integration', function() {
1211
jest.setTimeout(TWENTY_SECONDS);
1312

14-
const text_to_speech = new TextToSpeechV1(auth.text_to_speech);
13+
const auth = authHelper.auth.text_to_speech;
14+
auth.iam_apikey = auth.apikey;
15+
const text_to_speech = new TextToSpeechV1(auth);
1516

1617
it('listVoices()', function(done) {
1718
text_to_speech.listVoices(null, serviceErrorUtils.checkErrorCode(200, done));

test/integration/tone_analyzer.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,17 @@ const fs = require('fs');
44
const ToneAnalyzerV3 = require('../../tone-analyzer/v3');
55
const path = require('path');
66
const authHelper = require('../resources/auth_helper.js');
7-
const auth = authHelper.auth;
87
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
98
const TWENTY_SECONDS = 20000;
109
const serviceErrorUtils = require('../resources/service_error_util');
1110

1211
describe('tone_analyzer_integration', function() {
1312
jest.setTimeout(TWENTY_SECONDS);
1413

15-
auth.tone_analyzer.version = '2019-03-27';
16-
const tone_analyzer = new ToneAnalyzerV3(auth.tone_analyzer);
14+
const auth = authHelper.auth.tone_analyzer;
15+
auth.version = '2019-03-27';
16+
auth.iam_apikey = auth.apikey;
17+
const tone_analyzer = new ToneAnalyzerV3(auth);
1718

1819
it('tone()', function(done) {
1920
const mobydick = fs.readFileSync(path.join(__dirname, '../resources/tweet.txt'), 'utf8');

test/integration/visual_recognition.custom_classifiers.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const fs = require('fs');
33
const VisualRecognitionV3 = require('../../visual-recognition/v3');
44
const path = require('path');
55
const authHelper = require('../resources/auth_helper.js');
6-
const auth = authHelper.auth;
76
const describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
87
const async = require('async');
98

@@ -18,8 +17,11 @@ describe.skip('visual_recognition_integration_custom_classifiers @slow', functio
1817
// ugh.
1918
jest.setTimeout(THIRTY_SECONDS * 8);
2019

20+
const auth = authHelper.auth.visual_recognition;
21+
auth.iam_apikey = auth.apikey;
22+
2123
const visual_recognition = new VisualRecognitionV3(
22-
Object.assign({}, auth.visual_recognition_rc.v3, {
24+
Object.assign({}, auth, {
2325
version: '2019-03-27',
2426
})
2527
);

0 commit comments

Comments
 (0)