Skip to content

Commit 3013f0b

Browse files
committed
breaking up integration tests & misc. improvements
* added some smaller audio files for the stt integration tests, * enabled a few skipped tests * dropped unnecessary vr v3 wrapper * some other misc. cleanup
1 parent e14d77b commit 3013f0b

43 files changed

Lines changed: 1581 additions & 1109 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ npm-debug.log.*
44
coverage
55
.DS_Store
66
test/resources/auth.js
7-
test/integration/
87
test/resources/tts-output.ogg
98
.idea
109
doc/

auth.js.enc

0 Bytes
Binary file not shown.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,9 @@
103103
"prepare": "npm test && npm version patch",
104104
"doc": "jsdoc -c jsdoc/config.json",
105105
"watch-doc": "nodemon --watch ./ --ext js,tmpl,json --ignore dist/ --ignore doc/ --ignore test/ --ignore examples/ --exec npm run doc",
106-
"codecov": "istanbul cover ./node_modules/.bin/mocha && codecov",
107-
"test-integration": "mocha test/test.zz.integration-all-services.js",
108-
"test-unit": "npm run lint && mocha --fgrep integration --invert",
106+
"codecov": "istanbul cover mocha test/unit test/integration && codecov",
107+
"test-integration": "mocha test/integration",
108+
"test-unit": "npm run lint && mocha test/unit/",
109109
"test-browser": "karma start --single-run",
110110
"watch": "npm run test-unit -- --watch",
111111
"browserify": "browserify index.js --standalone Watson --outfile dist/watson.js",

test/integration/auth_helper.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
var fs = require('fs');
2+
var path = require('path');
3+
var authPath = path.join(__dirname, '../resources/auth.js');
4+
5+
var hasAuth = fs.existsSync(authPath);
6+
7+
if (hasAuth) {
8+
exports.describe = describe;
9+
} else {
10+
exports.describe = describe.skip.bind(describe);
11+
exports.describe.skip = exports.describe;
12+
}
13+
exports.auth = hasAuth ? require(authPath) : null;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
'use strict';
2+
3+
var nock = require('nock');
4+
var watson = require('../../index');
5+
var authHelper = require('./auth_helper.js');
6+
var auth = authHelper.auth;
7+
var describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
8+
9+
var FIVE_SECONDS = 5000;
10+
var TWO_SECONDS = 2000;
11+
12+
13+
describe('alchemy_data_news_integration', function() {
14+
this.timeout(FIVE_SECONDS);
15+
this.slow(TWO_SECONDS); // this controls when the tests get a colored warning for taking too long
16+
17+
this.retries(1);
18+
19+
var alchemy_data_news;
20+
21+
22+
before(function() {
23+
alchemy_data_news = watson.alchemy_data_news(auth.alchemy);
24+
nock.enableNetConnect();
25+
});
26+
27+
after(function() {
28+
nock.disableNetConnect();
29+
});
30+
31+
32+
it('getNews()', function(done) {
33+
alchemy_data_news.getNews({
34+
start: 'now-1d',
35+
end: 'now',
36+
count: 100,
37+
'q.enriched.url.enrichedTitle.relations.relation': '|action.verb.text=acquire,object.entities.entity.type=Company|',
38+
return: 'enriched.url.title'
39+
}, done);
40+
});
41+
});
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
'use strict';
2+
3+
var fs = require('fs');
4+
var nock = require('nock');
5+
var watson = require('../../index');
6+
var authHelper = require('./auth_helper.js');
7+
var auth = authHelper.auth;
8+
var describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
9+
10+
var FIVE_SECONDS = 5000;
11+
var TWO_SECONDS = 2000;
12+
13+
14+
describe('alchemy_language_integration', function() {
15+
this.timeout(FIVE_SECONDS);
16+
this.slow(TWO_SECONDS); // this controls when the tests get a colored warning for taking too long
17+
18+
this.retries(1);
19+
20+
var alchemy_language;
21+
var text;
22+
23+
before(function() {
24+
alchemy_language = watson.alchemy_language(auth.alchemy);
25+
text = fs.readFileSync(__dirname + '/../resources/alchemy-text.txt', 'utf8');
26+
nock.enableNetConnect();
27+
});
28+
29+
after(function() {
30+
nock.disableNetConnect();
31+
});
32+
33+
34+
it('entities()', function(done) {
35+
alchemy_language.entities({
36+
text: text
37+
}, done);
38+
});
39+
40+
it('keywords()', function(done) {
41+
alchemy_language.keywords({
42+
text: text
43+
}, done);
44+
});
45+
46+
47+
it('concepts()', function(done) {
48+
alchemy_language.concepts({
49+
text: text
50+
}, done);
51+
});
52+
53+
it('emotion()', function(done) {
54+
alchemy_language.emotion({
55+
text: text
56+
}, done);
57+
});
58+
59+
it('sentiment()', function(done) {
60+
alchemy_language.sentiment({
61+
text: text
62+
}, done);
63+
});
64+
65+
it('sentiment_targeted()', function(done) {
66+
alchemy_language.sentiment({
67+
text: text,
68+
target: 'Peter Higgs'
69+
}, done);
70+
});
71+
72+
it('sentiment_multiple_targets_with_pipe()', function(done) {
73+
alchemy_language.sentiment({
74+
text: text,
75+
targets: 'United States|Peter Higgs'
76+
}, done);
77+
});
78+
79+
it('sentiment_multiple_targets_with_array()', function(done) {
80+
alchemy_language.sentiment({
81+
text: text,
82+
targets: ['United States','Peter Higgs']
83+
}, done);
84+
});
85+
86+
it('category()', function(done) {
87+
alchemy_language.category({
88+
text: text
89+
}, done);
90+
});
91+
92+
it('publicationDate()', function(done) {
93+
alchemy_language.publicationDate({
94+
html: text
95+
}, done);
96+
});
97+
98+
it('relations()', function(done) {
99+
alchemy_language.relations({
100+
text: text
101+
}, done);
102+
});
103+
104+
it('language()', function(done) {
105+
alchemy_language.language({
106+
text: text
107+
}, done);
108+
});
109+
110+
it('text()', function(done) {
111+
alchemy_language.text({
112+
html: text
113+
}, done);
114+
});
115+
116+
it('text_raw()', function(done) {
117+
alchemy_language.text({
118+
html: text,
119+
raw: true
120+
}, done);
121+
});
122+
123+
it('authors()', function(done) {
124+
alchemy_language.authors({
125+
html: text
126+
}, done);
127+
});
128+
129+
it('feeds()', function(done) {
130+
alchemy_language.feeds({
131+
url: 'https://developer.ibm.com/watson/blog/'
132+
}, done);
133+
});
134+
135+
it('microformats()', function(done) {
136+
alchemy_language.microformats({
137+
url: 'http://www.alchemyapi.com/products/alchemylanguage/microformats-parsing'
138+
}, done);
139+
});
140+
141+
it('taxonomy()', function(done) {
142+
alchemy_language.taxonomy({
143+
html: text
144+
}, done);
145+
});
146+
147+
it('combined()', function(done) {
148+
alchemy_language.combined({
149+
text: text
150+
}, done);
151+
});
152+
153+
describe('typedRelations()', function() {
154+
it('should process html', function(done) {
155+
alchemy_language.typedRelations({
156+
html: text
157+
}, done);
158+
});
159+
160+
it('should process text', function(done) {
161+
alchemy_language.typedRelations({
162+
text: text
163+
}, done);
164+
});
165+
});
166+
});
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
'use strict';
2+
3+
var fs = require('fs');
4+
var nock = require('nock');
5+
var watson = require('../../index');
6+
var path = require('path');
7+
var authHelper = require('./auth_helper.js');
8+
var auth = authHelper.auth;
9+
var describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
10+
11+
var TWENTY_SECONDS = 20000;
12+
var TWO_SECONDS = 2000;
13+
14+
describe('alchemy_vision_integration', function() {
15+
this.timeout(TWENTY_SECONDS);
16+
this.slow(TWO_SECONDS); // this controls when the tests get a colored warning for taking too long
17+
this.retries(1);
18+
19+
var alchemy_vision;
20+
var imageFile;
21+
22+
before(function() {
23+
alchemy_vision = watson.alchemy_vision(auth.alchemy);
24+
imageFile = fs.createReadStream(path.join(__dirname, '../resources/obama.jpg'));
25+
nock.enableNetConnect();
26+
});
27+
28+
after(function() {
29+
nock.disableNetConnect();
30+
});
31+
32+
it('getImageLinks() with url', function(done) {
33+
alchemy_vision.getImageLinks({
34+
url: 'http://www.alchemyapi.com/products/alchemylanguage/microformats-parsing'
35+
}, done);
36+
});
37+
38+
it('getImageLinks() with html', function(done) {
39+
alchemy_vision.getImageLinks({
40+
html: '<div><img src="https://watson-test-resources.mybluemix.net/resources/obama.jpg" /></div>'
41+
}, done);
42+
});
43+
44+
it('getImageKeywordsWithFile()', function(done) {
45+
alchemy_vision.getImageKeywords({image: imageFile}, done);
46+
});
47+
48+
it('getImageKeywordsWithUrl()', function(done) {
49+
alchemy_vision.getImageKeywords({
50+
url: 'https://watson-test-resources.mybluemix.net/resources/obama.jpg'
51+
}, done);
52+
});
53+
54+
// this service endpoint is super-flaky, disabling the test for now
55+
it.skip('recognizeFacesWithFile()', function(done) {
56+
this.timeout(TWENTY_SECONDS * 6);
57+
this.retries(5);
58+
alchemy_vision.recognizeFaces({image: imageFile}, done);
59+
});
60+
61+
it('recognizeFacesWithUrl()', function(done) {
62+
alchemy_vision.recognizeFaces({
63+
url: 'https://watson-test-resources.mybluemix.net/resources/obama.jpg'
64+
}, done);
65+
});
66+
67+
it('getImageSceneText()', function(done) {
68+
alchemy_vision.getImageSceneText({
69+
url: 'https://watson-test-resources.mybluemix.net/resources/open.png'
70+
}, done);
71+
});
72+
});
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
3+
var nock = require('nock');
4+
var watson = require('../../index');
5+
var assert = require('assert');
6+
var authHelper = require('./auth_helper.js');
7+
var auth = authHelper.auth;
8+
var describe = authHelper.describe; // this runs describe.skip if there is no auth.js file :)
9+
10+
var TEN_SECONDS = 10000;
11+
var TWO_SECONDS = 2000;
12+
13+
14+
describe('conversation_integration', function() {
15+
this.timeout(TEN_SECONDS);
16+
this.slow(TWO_SECONDS); // this controls when the tests get a colored warning for taking too long
17+
this.retries(1);
18+
19+
var conversation;
20+
21+
before(function() {
22+
conversation = watson.conversation(auth.conversation);
23+
nock.enableNetConnect();
24+
});
25+
26+
after(function() {
27+
nock.disableNetConnect();
28+
});
29+
30+
// disabling until https://github.ibm.com/watson-engagement-advisor/wea-backlog/issues/2388 is resolved
31+
it.skip('message()', function(done) {
32+
var params = {
33+
input: {
34+
text: 'Turn on the lights'
35+
},
36+
alternate_intents: true,
37+
workspace_id: auth.conversation.workspace_id
38+
};
39+
40+
conversation.message(params, function(err, result) {
41+
if (err) {
42+
return done(err);
43+
}
44+
assert.equal(result.alternate_intents, true);
45+
done();
46+
});
47+
});
48+
});

0 commit comments

Comments
 (0)