Skip to content
This repository has been archived by the owner on Aug 6, 2021. It is now read-only.

Commit

Permalink
implemented retrieval of all models per experiment; see #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Schulze committed May 28, 2016
1 parent a3384a2 commit 675827a
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions api/v1/experiment/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,28 @@ module.exports = function(io) {
});
});

app.get('/api/v1/experiment/:expId/model', function(req, res) {
Experiment.findById(req.params.expId, function(err, doc) {
if (err) {
return res
.status(500)
.json({
'message': err
});
}

if (!doc) {
return res
.status(404)
.json({
message: 'No such experiment'
});
}

return res.status(200).json(doc.models);
});
});

app.get('/api/v1/experiment/:expId/model/:mId', function(req, res) {
Experiment.findById(req.params.expId, function(err, doc) {
if (err) {
Expand Down
20 changes: 20 additions & 0 deletions tests/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,26 @@
done(err);
});
});

it('should get all models, including the just created one', function(done) {
request(app)
.get('/api/v1/experiment/' + exp_id + '/model')
.expect(200)
.end(function(err, res) {
var notFail = false;

for (var i = 0; i < res.body.length; i++) {
if (res.body[i]._id == model_id) {
notFail = true;
break;
}
}

expect(notFail).to.be.ok;

done(err);
});
});
});

describe('Change Model: PUT /experiment/:id/model/:id', function() {
Expand Down

0 comments on commit 675827a

Please sign in to comment.