This commit is contained in:
Ivan Malagon 2017-12-13 10:43:43 +01:00
parent 02ac25181e
commit 1664975dd1
4 changed files with 46 additions and 15 deletions

View File

@ -78,10 +78,11 @@ describe('analysis-filters-params', () => {
it('should get a filtered histogram dataview with all filters', function(done) {
const testClient = new TestClient(mapConfig, 1234);
const testParams = Object.assign({}, params, {
own_filter: 1
});
params.own_filter = 1;
testClient.getDataview('pop_max_histogram', params, (err, dataview) => {
testClient.getDataview('pop_max_histogram', testParams, (err, dataview) => {
assert.ok(!err, err);
assert.equal(dataview.type, 'histogram');
@ -93,10 +94,11 @@ describe('analysis-filters-params', () => {
it('should get a filtered histogram dataview with all filters except my own filter', function(done) {
const testClient = new TestClient(mapConfig, 1234);
const testParams = Object.assign({}, params, {
own_filter: 0
});
params.own_filter = 0;
testClient.getDataview('pop_max_histogram', params, (err, dataview) => {
testClient.getDataview('pop_max_histogram', testParams, (err, dataview) => {
assert.ok(!err, err);
assert.equal(dataview.type, 'histogram');
@ -108,10 +110,11 @@ describe('analysis-filters-params', () => {
it('should get a filtered histogram dataview without filters', function(done) {
const testClient = new TestClient(mapConfig, 1234);
const testParams = Object.assign({}, params, {
no_filters: 1
});
params.no_filters = 1;
testClient.getDataview('pop_max_histogram', params, (err, dataview) => {
testClient.getDataview('pop_max_histogram', testParams, (err, dataview) => {
assert.ok(!err, err);
assert.equal(dataview.type, 'histogram');
@ -121,4 +124,27 @@ describe('analysis-filters-params', () => {
});
});
it('should return an error if both no_filters and own_filter params are present', function (done) {
const testClient = new TestClient(mapConfig, 1234);
const expectedError = {
errors: ['Both own_filter and no_filters cannot be sent in the same request'],
errors_with_context: [{
type: 'dataview',
message: 'Both own_filter and no_filters cannot be sent in the same request'
}]
};
const testParams = Object.assign({}, params, {
no_filters: 1,
own_filter: 0,
response: {
status: 400
}
});
testClient.getDataview('pop_max_histogram', testParams, (err, dataview) => {
assert.deepEqual(dataview, expectedError);
testClient.drain(done);
});
});
});

View File

@ -109,7 +109,8 @@ describe('analysis-layers-dataviews', function() {
min: 2e6
}
}
}
},
own_filter: 1
};
testClient.getDataview('pop_max_histogram', params, function(err, dataview) {

View File

@ -393,7 +393,8 @@ describe('dataviews using tables with overviews', function() {
var params = {
filters: {
dataviews: { test_histogram: { min: 2 } }
}
},
own_filter: 1
};
var testClient = new TestClient(overviewsMapConfig);
testClient.getDataview('test_histogram', params, function (err, histogram) {
@ -412,7 +413,8 @@ describe('dataviews using tables with overviews', function() {
var params = {
filters: {
dataviews: { test_histogram: { max: -1 } }
}
},
own_filter: 1
};
var testClient = new TestClient(overviewsMapConfig);
testClient.getDataview('test_histogram', params, function (err, histogram) {
@ -433,7 +435,8 @@ describe('dataviews using tables with overviews', function() {
var params = {
filters: {
dataviews: { test_histogram_date: { max: -1 } }
}
},
own_filter: 1
};
var testClient = new TestClient(overviewsMapConfig);
testClient.getDataview('test_histogram_date', params, function (err, histogram) {

View File

@ -414,8 +414,9 @@ TestClient.prototype.getDataview = function(dataviewName, params, callback) {
var urlParams = {};
if (params.hasOwnProperty('no_filters')) {
urlParams.no_filters = params.no_filters;
} else {
urlParams.own_filter = params.hasOwnProperty('own_filter') ? params.own_filter : 1;
}
if (params.hasOwnProperty('own_filter')) {
urlParams.own_filter = params.own_filter;
}
['bbox', 'bins', 'start', 'end', 'aggregation', 'offset', 'categories'].forEach(function(extraParam) {