Skip to content
Snippets Groups Projects
Commit 2541d274 authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Merge branch 'idhme_hotfix' into development

Related: !71
parents b65db1d6 294027c0
No related branches found
No related tags found
1 merge request!116Release v1.0.0
Pipeline #
......@@ -131,7 +131,7 @@ idhmeApp.get('/', rqf.parse(), (req, res, next) => {
.group('adh_idh.idhm_e')
.group('adh_idh.ano_censo')
.group('adh_idh.municipio_id');
} else {
} else if (("state" in req.filter) || ("state" in req.dims)) {
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm_e', 'total')
.field('adh_idh_uf.ano_censo', 'year')
......@@ -139,6 +139,12 @@ idhmeApp.get('/', rqf.parse(), (req, res, next) => {
.group('adh_idh_uf.idhm_e')
.group('adh_idh_uf.ano_censo')
.group('adh_idh_uf.estado_id');
} else {
res.status(400);
next({
status: 400,
message: 'Wrong/No filter specified'
});
}
next();
}, rqf.build(), query, id2str.transform(), response('idhme'));
......
......@@ -131,7 +131,7 @@ idhmlApp.get('/', rqf.parse(), (req, res, next) => {
.group('adh_idh.idhm_l')
.group('adh_idh.ano_censo')
.group('adh_idh.municipio_id');
} else {
} else if (("state" in req.filter) || ("state" in req.dims)) {
req.sql.from('adh_idh_uf')
.field('adh_idh_uf.idhm_l', 'total')
.field('adh_idh_uf.ano_censo', 'year')
......@@ -139,6 +139,12 @@ idhmlApp.get('/', rqf.parse(), (req, res, next) => {
.group('adh_idh_uf.idhm_l')
.group('adh_idh_uf.ano_censo')
.group('adh_idh_uf.estado_id');
} else {
res.status(400);
next({
status: 400,
message: 'Wrong/No filter specified'
});
}
next();
}, rqf.build(), query, id2str.transform(), response('idhme'));
......
......@@ -70,19 +70,17 @@ describe('request idhme', () => {
chai.request(server)
.get('/api/v1/idhme?filter=foo:2010,bar:41')
.end((err, res) => {
res.should.have.status(200);
res.should.have.status(400);
res.should.be.json;
res.body.result.should.be.a('array');
res.body.result[0].should.have.property('total');
res.body.result[0].should.have.property('year');
res.body.result[0].should.have.property('state_id');
res.body.should.have.property('error');
res.body.error.should.be.equal('Wrong/No filter specified');
done();
});
});
it('should list idhme with valid dimensions', (done) => {
chai.request(server)
.get('/api/v1/idhme?dims=state')
.get('/api/v1/idhme?dims=state&filter=min_year:2010')
.end((err, res) => {
res.should.have.status(200);
res.should.be.json;
......@@ -112,17 +110,14 @@ describe('request idhme', () => {
});
});
it('should list idhme from all states with all years available with no argument dimensions and filters', (done) => {
it('should return 400 with no filters', (done) => {
chai.request(server)
.get('/api/v1/idhme')
.end((err, res) => {
res.should.have.status(200);
res.should.have.status(400);
res.should.be.json;
res.body.should.have.property('result');
res.body.result.should.be.a('array');
res.body.result[0].should.have.property('total');
res.body.result[0].should.have.property('year');
res.body.result[0].should.have.property('state_id');
res.body.should.have.property('error');
res.body.error.should.be.equal('Wrong/No filter specified');
done();
});
});
......
......@@ -70,19 +70,17 @@ describe('request idhml', () => {
chai.request(server)
.get('/api/v1/idhml?filter=foo:2010,bar:41')
.end((err, res) => {
res.should.have.status(200);
res.should.have.status(400);
res.should.be.json;
res.body.result.should.be.a('array');
res.body.result[0].should.have.property('total');
res.body.result[0].should.have.property('year');
res.body.result[0].should.have.property('state_id');
res.body.should.have.property('error');
res.body.error.should.be.equal('Wrong/No filter specified');
done();
});
});
it('should list idhml with valid dimensions', (done) => {
chai.request(server)
.get('/api/v1/idhml?dims=state')
.get('/api/v1/idhml?dims=state&filter=min_year:2010')
.end((err, res) => {
res.should.have.status(200);
res.should.be.json;
......@@ -112,17 +110,14 @@ describe('request idhml', () => {
});
});
it('should list idhml from all states with all years available with no argument dimensions and filters', (done) => {
it('should return 400 with no filters', (done) => {
chai.request(server)
.get('/api/v1/idhml')
.end((err, res) => {
res.should.have.status(200);
res.should.have.status(400);
res.should.be.json;
res.body.should.have.property('result');
res.body.result.should.be.a('array');
res.body.result[0].should.have.property('total');
res.body.result[0].should.have.property('year');
res.body.result[0].should.have.property('state_id');
res.body.should.have.property('error');
res.body.error.should.be.equal('Wrong/No filter specified');
done();
});
});
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment