Skip to content

Commit 26bfd26

Browse files
committed
Added some more unit tests
1 parent e374652 commit 26bfd26

File tree

4 files changed

+384
-33
lines changed

4 files changed

+384
-33
lines changed

tests/unit/input-unit-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ describe('Unit Tests - Inputs', () => {
130130
.catch(errorHandler.bind(done));
131131
});
132132

133-
it('Updates input', done => {
133+
it('Updates inputs', done => {
134134
mock.onPatch(BASE_URL + '/v2/inputs').reply(200, JSON.parse(`
135135
{
136136
"status": {
@@ -173,7 +173,7 @@ describe('Unit Tests - Inputs', () => {
173173
}]
174174
}
175175
`));
176-
176+
177177
app.inputs.update(
178178
{
179179
id: '@inputID',

tests/unit/models-unit-tests.js

Lines changed: 91 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -225,46 +225,107 @@ describe('Unit Tests - Models', () => {
225225
.catch(errorHandler.bind(done));
226226
});
227227

228-
it('Gets model inputs', done => {
229-
mock.onGet(BASE_URL + '/v2/models/%40modelID/inputs').reply(200, JSON.parse(`
228+
it('Get model outputinfo', done => {
229+
mock.onGet(BASE_URL + '/v2/models/%40modelID/output_info').reply(200, JSON.parse(`
230+
{
231+
"status": {
232+
"code": 10000,
233+
"description": "Ok"
234+
},
235+
"model": {
236+
"id": "@modelID",
237+
"name": "@modelName",
238+
"created_at": "2017-05-16T19:20:38.733764Z",
239+
"app_id": "main",
240+
"output_info": {
241+
"data": {
242+
"concepts": [{
243+
"id": "@conceptID11",
244+
"name": "safe",
245+
"created_at": "2017-05-16T19:20:38.450157Z",
246+
"language": "en",
247+
"app_id": "main"
248+
}]
249+
},
250+
"type": "concept",
251+
"type_ext": "concept"
252+
},
253+
"model_version": {
254+
"id": "@modelVersionID",
255+
"created_at": "2017-05-16T19:20:38.733764Z",
256+
"status": {
257+
"code": 21100,
258+
"description": "Model trained successfully"
259+
},
260+
"active_concept_count": 5
261+
},
262+
"display_name": "Moderation"
263+
}
264+
}
265+
`));
266+
267+
app.models.getOutputInfo('@modelID')
268+
.then(outputinfo => {
269+
expect(mock.history.get.length).toBe(1);
270+
271+
expect(outputinfo.id).toBe("@modelID");
272+
expect(outputinfo.name).toBe("@modelName");
273+
expect(outputinfo.modelVersion.id).toBe("@modelVersionID");
274+
expect(outputinfo.outputInfo.type).toBe("concept");
275+
done();
276+
})
277+
.catch(errorHandler.bind(done));
278+
});
279+
280+
it('Gets model', done => {
281+
mock.onGet(BASE_URL + '/v2/models/%40modelID').reply(200, JSON.parse(`
230282
{
231283
"status": {
232284
"code": 10000,
233285
"description": "Ok"
234286
},
235-
"inputs": [{
236-
"id": "@inputID",
237-
"data": {
238-
"image": {
239-
"url": "@imageURL"
287+
"model": {
288+
"id": "@modelID",
289+
"name": "@modelName",
290+
"created_at": "2017-05-16T19:20:38.733764Z",
291+
"app_id": "main",
292+
"output_info": {
293+
"data": {
294+
"concepts": [{
295+
"id": "@conceptID11",
296+
"name": "safe",
297+
"created_at": "2017-05-16T19:20:38.450157Z",
298+
"language": "en",
299+
"app_id": "main"
300+
}]
240301
},
241-
"concepts": [{
242-
"id": "@conceptID",
243-
"name": "@conceptName",
244-
"value": 1,
245-
"app_id": "@conceptAppID"
246-
}]
302+
"type": "concept",
303+
"type_ext": "concept"
247304
},
248-
"created_at": "2017-10-15T16:30:52.964888Z",
249-
"status": {
250-
"code": 30000,
251-
"description": "Download complete"
252-
}
253-
}]
305+
"model_version": {
306+
"id": "@modelVersionID",
307+
"created_at": "2017-05-16T19:20:38.733764Z",
308+
"status": {
309+
"code": 21100,
310+
"description": "Model trained successfully"
311+
},
312+
"active_concept_count": 5
313+
},
314+
"display_name": "Moderation"
315+
}
254316
}
255317
`));
256318

257-
app.models.initModel('@modelID').then(model => {
258-
return model.getInputs();
259-
}).then(inputsResponse => {
260-
expect(mock.history.get.length).toBe(1);
261-
262-
const input = inputsResponse['inputs'][0];
263-
expect(input.id).toBe('@inputID');
264-
expect(input.data.concepts[0].id).toBe('@conceptID');
265-
266-
done();
267-
}).catch(errorHandler.bind(done));
319+
app.models.get('@modelID').then(model => {
320+
expect(mock.history.get.length).toBe(1);
321+
322+
expect(model.id).toBe('@modelID');
323+
expect(model.name).toBe('@modelName');
324+
expect(model.modelVersion.id).toBe('@modelVersionID');
325+
expect(model.outputInfo.data.concepts[0].id).toBe('@conceptID11');
326+
done();
327+
})
328+
.catch(errorHandler.bind(done));
268329
});
269330

270331
it('Modifies models', done => {

tests/unit/search-inputs-unit-tests.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,4 @@ describe('Unit Tests - Input Search', () => {
218218
})
219219
.catch(errorHandler.bind(done));
220220
});
221-
222221
});

0 commit comments

Comments
 (0)