diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 110b211..00720f5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,10 @@ jobs: uses: actions/setup-python@v2 with: python-version: 3.8 + - name: Use Node.js + uses: actions/setup-node@v2 + with: + node-version: '14.x' - name: Install dependencies run: | python -m pip install --upgrade pip diff --git a/timeseries/tests/Makefile b/timeseries/tests/Makefile index 79943b7..96c8369 100755 --- a/timeseries/tests/Makefile +++ b/timeseries/tests/Makefile @@ -1,11 +1,11 @@ all: install test node_modules: - npm install + npm ci .PHONY: install: - npm install + npm ci .PHONY: test: | node_modules diff --git a/timeseries/tests/__tests__/timeseries.polygon.tests.js b/timeseries/tests/__tests__/timeseries.polygon.tests.js index dd6b2c0..dbd0bf0 100644 --- a/timeseries/tests/__tests__/timeseries.polygon.tests.js +++ b/timeseries/tests/__tests__/timeseries.polygon.tests.js @@ -9,702 +9,703 @@ describe("When a GET request selects from a region exactly covering the northwes var response; - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'uint16_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-123,45], - [-123,43], - [-121,43], - [-121,45], - [-123,45] - ]] - }, - start: 1, - end: 5 - } - }); - }); - - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the average of four pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(105.5,3); - expect(response.entity.values[1]).toBeCloseTo(205.5,3); - expect(response.entity.values[2]).toBeCloseTo(305.5,3); - expect(response.entity.values[3]).toBeCloseTo(405.5,3); - expect(response.entity.values[4]).toBeCloseTo(505.5,3); - }); + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'uint16_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-123,45], + [-123,43], + [-121,43], + [-121,45], + [-123,45] + ]] + }, + start: 1, + end: 5 + } + }); + console.log("response: ", response); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the average of four pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(105.5,3); + expect(response.entity.values[1]).toBeCloseTo(205.5,3); + expect(response.entity.values[2]).toBeCloseTo(305.5,3); + expect(response.entity.values[3]).toBeCloseTo(405.5,3); + expect(response.entity.values[4]).toBeCloseTo(505.5,3); + }); }); describe("When a GET request selects from a region exactly covering the northwest 2x2 pixel area in the float32 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'float32_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-123,45], - [-123,43], - [-121,43], - [-121,45], - [-123,45] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the average of four pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(105.55,3); - expect(response.entity.values[1]).toBeCloseTo(205.55,3); - expect(response.entity.values[2]).toBeCloseTo(305.55,3); - expect(response.entity.values[3]).toBeCloseTo(405.55,3); - expect(response.entity.values[4]).toBeCloseTo(505.55,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'float32_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-123,45], + [-123,43], + [-121,43], + [-121,45], + [-123,45] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the average of four pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(105.55,3); + expect(response.entity.values[1]).toBeCloseTo(205.55,3); + expect(response.entity.values[2]).toBeCloseTo(305.55,3); + expect(response.entity.values[3]).toBeCloseTo(405.55,3); + expect(response.entity.values[4]).toBeCloseTo(505.55,3); + }); }); describe("When a GET request selects from a region of zero area from the uint16 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'uint16_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-122.5,45.5], - [-122.5,45.5], - [-122.5,45.5], - [-122.5,45.5], - [-122.5,45.5], - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 422', async function() { - expect(response.status.code).toBe(422); - }); - - it ('Error type should be out of bounds', async function() { - expect(response.entity.detail[0].type).toBe("value_error.selectedareapolygonisnotvalid"); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'uint16_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-122.5,45.5], + [-122.5,45.5], + [-122.5,45.5], + [-122.5,45.5], + [-122.5,45.5], + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); + }); + + it ('Error type should be out of bounds', async function() { + expect(response.entity.detail[0].type).toBe("value_error.selectedareapolygonisnotvalid"); + }); }); describe("When a GET request selects from a region of zero area from the float32 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'float32_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-122.5,45.5], - [-122.5,45.5], - [-122.5,45.5], - [-122.5,45.5], - [-122.5,45.5], - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 422', async function() { - expect(response.status.code).toBe(422); - }); - - it ('Error type should be out of bounds', async function() { - expect(response.entity.detail[0].type).toBe("value_error.selectedareapolygonisnotvalid"); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'float32_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-122.5,45.5], + [-122.5,45.5], + [-122.5,45.5], + [-122.5,45.5], + [-122.5,45.5], + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); + }); + + it ('Error type should be out of bounds', async function() { + expect(response.entity.detail[0].type).toBe("value_error.selectedareapolygonisnotvalid"); + }); }); describe("When a GET request selects from a 2x2 pixel region that intersects a 2x1 pixel region in the uint16 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'uint16_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-123,46], - [-123,44], - [-121,44], - [-121,46], - [-123,46] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the average of four pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(100.5,3); - expect(response.entity.values[1]).toBeCloseTo(200.5,3); - expect(response.entity.values[2]).toBeCloseTo(300.5,3); - expect(response.entity.values[3]).toBeCloseTo(400.5,3); - expect(response.entity.values[4]).toBeCloseTo(500.5,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'uint16_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-123,46], + [-123,44], + [-121,44], + [-121,46], + [-123,46] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the average of four pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(100.5,3); + expect(response.entity.values[1]).toBeCloseTo(200.5,3); + expect(response.entity.values[2]).toBeCloseTo(300.5,3); + expect(response.entity.values[3]).toBeCloseTo(400.5,3); + expect(response.entity.values[4]).toBeCloseTo(500.5,3); + }); }); describe("When a GET request selects from a 2x2 pixel region that intersects a 2x1 pixel region in the float32 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'float32_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-123,46], - [-123,44], - [-121,44], - [-121,46], - [-123,46] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the average of four pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(100.55,3); - expect(response.entity.values[1]).toBeCloseTo(200.55,3); - expect(response.entity.values[2]).toBeCloseTo(300.55,3); - expect(response.entity.values[3]).toBeCloseTo(400.55,3); - expect(response.entity.values[4]).toBeCloseTo(500.55,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'float32_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-123,46], + [-123,44], + [-121,44], + [-121,46], + [-123,46] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the average of four pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(100.55,3); + expect(response.entity.values[1]).toBeCloseTo(200.55,3); + expect(response.entity.values[2]).toBeCloseTo(300.55,3); + expect(response.entity.values[3]).toBeCloseTo(400.55,3); + expect(response.entity.values[4]).toBeCloseTo(500.55,3); + }); }); describe("When a GET request selects a region just outside coverage of the uint16 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'uint16_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-124,45], - [-124,47], - [-123,47], - [-123,45], - [-124,45] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 422', async function() { - expect(response.status.code).toBe(422); - }); - - it ('Error type should be out of bounds', async function() { - expect(response.entity.detail[0].type).toBe("value_error.selectedareaoutofbounds"); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'uint16_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-124,45], + [-124,47], + [-123,47], + [-123,45], + [-124,45] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); + }); + + it ('Error type should be out of bounds', async function() { + expect(response.entity.detail[0].type).toBe("value_error.selectedareaoutofbounds"); + }); }); describe("When a GET request selects a region just outside coverage of the float32 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'float32_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-124,45], - [-124,43], - [-123,43], - [-123,45], - [-124,45] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 422', async function() { - expect(response.status.code).toBe(422); - }); - - it ('Error type should be out of bounds', async function() { - expect(response.entity.detail[0].type).toBe("value_error.selectedareaoutofbounds"); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'float32_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-124,45], + [-124,43], + [-123,43], + [-123,45], + [-124,45] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); + }); + + it ('Error type should be out of bounds', async function() { + expect(response.entity.detail[0].type).toBe("value_error.selectedareaoutofbounds"); + }); }); describe("When a GET request selects a region well outside coverage of the float32 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'float32_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-104,37], - [-104,35], - [-103,35], - [-103,37], - [-104,37] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 422', async function() { - expect(response.status.code).toBe(422); - }); - - it ('Error type should be out of bounds', async function() { - expect(response.entity.detail[0].type).toBe("value_error.selectedareaoutofbounds"); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'float32_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-104,37], + [-104,35], + [-103,35], + [-103,37], + [-104,37] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); + }); + + it ('Error type should be out of bounds', async function() { + expect(response.entity.detail[0].type).toBe("value_error.selectedareaoutofbounds"); + }); }); describe("When a GET request selects exactly the top-left corner pixel of the uint16 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'uint16_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-123.0,45], - [-123.0,44], - [-122.0,44], - [-122.0,44], - [-123.0,45] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the values of the top-left pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(100.0,3); - expect(response.entity.values[1]).toBeCloseTo(200.0,3); - expect(response.entity.values[2]).toBeCloseTo(300.0,3); - expect(response.entity.values[3]).toBeCloseTo(400.0,3); - expect(response.entity.values[4]).toBeCloseTo(500.0,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'uint16_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-123.0,45], + [-123.0,44], + [-122.0,44], + [-122.0,44], + [-123.0,45] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the values of the top-left pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(100.0,3); + expect(response.entity.values[1]).toBeCloseTo(200.0,3); + expect(response.entity.values[2]).toBeCloseTo(300.0,3); + expect(response.entity.values[3]).toBeCloseTo(400.0,3); + expect(response.entity.values[4]).toBeCloseTo(500.0,3); + }); }); describe("When a GET request selects exactly the top-left corner pixel of the float32 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'float32_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-123.0,45], - [-123.0,44], - [-122.0,44], - [-122.0,45], - [-123.0,45] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the values of the top-left pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(100.0,3); - expect(response.entity.values[1]).toBeCloseTo(200.0,3); - expect(response.entity.values[2]).toBeCloseTo(300.0,3); - expect(response.entity.values[3]).toBeCloseTo(400.0,3); - expect(response.entity.values[4]).toBeCloseTo(500.0,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'float32_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-123.0,45], + [-123.0,44], + [-122.0,44], + [-122.0,45], + [-123.0,45] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the values of the top-left pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(100.0,3); + expect(response.entity.values[1]).toBeCloseTo(200.0,3); + expect(response.entity.values[2]).toBeCloseTo(300.0,3); + expect(response.entity.values[3]).toBeCloseTo(400.0,3); + expect(response.entity.values[4]).toBeCloseTo(500.0,3); + }); }); describe("When a GET request selects 1/4 of the top-left corner pixel of the uint16 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'uint16_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-123.0,45], - [-123.0,44.75], - [-122.75,44.75], - [-122.75,44.75], - [-123.0,45] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the values of the top-left pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(100.0,3); - expect(response.entity.values[1]).toBeCloseTo(200.0,3); - expect(response.entity.values[2]).toBeCloseTo(300.0,3); - expect(response.entity.values[3]).toBeCloseTo(400.0,3); - expect(response.entity.values[4]).toBeCloseTo(500.0,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'uint16_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-123.0,45], + [-123.0,44.75], + [-122.75,44.75], + [-122.75,44.75], + [-123.0,45] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the values of the top-left pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(100.0,3); + expect(response.entity.values[1]).toBeCloseTo(200.0,3); + expect(response.entity.values[2]).toBeCloseTo(300.0,3); + expect(response.entity.values[3]).toBeCloseTo(400.0,3); + expect(response.entity.values[4]).toBeCloseTo(500.0,3); + }); }); describe("When a GET request selects 1/4 of the top-left corner pixel of the float32 variable", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'float32_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-123.0,45], - [-123.0,44.75], - [-122.75,44.75], - [-122.75,44.75], - [-123.0,45] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the values of the top-left pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(100.0,3); - expect(response.entity.values[1]).toBeCloseTo(200.0,3); - expect(response.entity.values[2]).toBeCloseTo(300.0,3); - expect(response.entity.values[3]).toBeCloseTo(400.0,3); - expect(response.entity.values[4]).toBeCloseTo(500.0,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'float32_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-123.0,45], + [-123.0,44.75], + [-122.75,44.75], + [-122.75,44.75], + [-123.0,45] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the values of the top-left pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(100.0,3); + expect(response.entity.values[1]).toBeCloseTo(200.0,3); + expect(response.entity.values[2]).toBeCloseTo(300.0,3); + expect(response.entity.values[3]).toBeCloseTo(400.0,3); + expect(response.entity.values[4]).toBeCloseTo(500.0,3); + }); }); describe("When a GET request selects from a region exactly covering the 2x2 pixel area in southwest corner the dataset", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'uint16_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-123,42], - [-123,40], - [-121,40], - [-121,42], - [-123,42] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the average of four pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(135.5,3); - expect(response.entity.values[1]).toBeCloseTo(235.5,3); - expect(response.entity.values[2]).toBeCloseTo(335.5,3); - expect(response.entity.values[3]).toBeCloseTo(435.5,3); - expect(response.entity.values[4]).toBeCloseTo(535.5,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'uint16_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-123,42], + [-123,40], + [-121,40], + [-121,42], + [-123,42] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the average of four pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(135.5,3); + expect(response.entity.values[1]).toBeCloseTo(235.5,3); + expect(response.entity.values[2]).toBeCloseTo(335.5,3); + expect(response.entity.values[3]).toBeCloseTo(435.5,3); + expect(response.entity.values[4]).toBeCloseTo(535.5,3); + }); }); describe("When a GET request selects from a region exactly covering the 2x2 pixel area in southeast corner of uint16 variable with one NODATA pixel in each band", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'uint16_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-120,42], - [-118,42], - [-118,40], - [-120,40], - [-120,42] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the average of four pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(140.0,3); - expect(response.entity.values[1]).toBeCloseTo(240.0,3); - expect(response.entity.values[2]).toBeCloseTo(340.0,3); - expect(response.entity.values[3]).toBeCloseTo(440.0,3); - expect(response.entity.values[4]).toBeCloseTo(540.0,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'uint16_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-120,42], + [-118,42], + [-118,40], + [-120,40], + [-120,42] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the average of four pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(140.0,3); + expect(response.entity.values[1]).toBeCloseTo(240.0,3); + expect(response.entity.values[2]).toBeCloseTo(340.0,3); + expect(response.entity.values[3]).toBeCloseTo(440.0,3); + expect(response.entity.values[4]).toBeCloseTo(540.0,3); + }); }); describe("When a GET request selects from a region exactly covering the 2x2 pixel area in southeast corner of float32 variable with one NODATA pixel in each band", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'float32_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-120,42], - [-118,42], - [-118,40], - [-120,40], - [-120,42] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the average of four pixels in each band', async function() { - expect(response.entity.values).toEqual([null, null, null, null, null]); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'float32_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-120,42], + [-118,42], + [-118,40], + [-120,40], + [-120,42] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the average of four pixels in each band', async function() { + expect(response.entity.values).toEqual([null, null, null, null, null]); + }); }); describe("When a GET request selects from a region exactly covering the 2x2 pixel area in uint16 variable with one NODATA pixel in 3rd band", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'uint16_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-120,43], - [-118,43], - [-118,41], - [-120,41], - [-120,43] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the average of four pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(126.667,3); - expect(response.entity.values[1]).toBeCloseTo(226.667,3); - expect(response.entity.values[2]).toBeCloseTo(328.000,3); - expect(response.entity.values[3]).toBeCloseTo(426.667,3); - expect(response.entity.values[4]).toBeCloseTo(526.667,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'uint16_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-120,43], + [-118,43], + [-118,41], + [-120,41], + [-120,43] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the average of four pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(126.667,3); + expect(response.entity.values[1]).toBeCloseTo(226.667,3); + expect(response.entity.values[2]).toBeCloseTo(328.000,3); + expect(response.entity.values[3]).toBeCloseTo(426.667,3); + expect(response.entity.values[4]).toBeCloseTo(526.667,3); + }); }); describe("When a GET request selects from a region exactly covering the 2x2 pixel area in southeast corner of float32 variable with two NODATA pixels in 3rd band", async () => { - - var response; - - beforeAll(async () => { - response = await callRESTService({ - method: 'POST', - path: timeseriesServiceBase + '/timeseries', - entity: { - datasetId: 'annual_5x5x5_dataset', - variableName: 'float32_variable', - boundaryGeometry: { - "type": "Polygon", - "coordinates": [[ - [-120,44], - [-118,44], - [-118,42], - [-120,42], - [-120,44] - ]] - }, - start: 1, - end: 5 - } - }); - }); - it ('HTTP response status code should be 200 - success', async function() { - expect(response.status.code).toBe(200); - }); - - it ('The array should comprise the average of four pixels in each band', async function() { - expect(response.entity.values[0]).toBeCloseTo(118.850,3); - expect(response.entity.values[1]).toBeCloseTo(218.850,3); - expect(response.entity.values[2]).toBe(null); - expect(response.entity.values[3]).toBeCloseTo(418.850,3); - expect(response.entity.values[4]).toBeCloseTo(518.850,3); - }); + var response; + + beforeAll(async () => { + response = await callRESTService({ + method: 'POST', + path: timeseriesServiceBase + '/timeseries', + entity: { + datasetId: 'annual_5x5x5_dataset', + variableName: 'float32_variable', + boundaryGeometry: { + "type": "Polygon", + "coordinates": [[ + [-120,44], + [-118,44], + [-118,42], + [-120,42], + [-120,44] + ]] + }, + start: 1, + end: 5 + } + }); + }); + + it ('HTTP response status code should be 200 - success', async function() { + expect(response.status.code).toBe(200); + }); + + it ('The array should comprise the average of four pixels in each band', async function() { + expect(response.entity.values[0]).toBeCloseTo(118.850,3); + expect(response.entity.values[1]).toBeCloseTo(218.850,3); + expect(response.entity.values[2]).toBe(null); + expect(response.entity.values[3]).toBeCloseTo(418.850,3); + expect(response.entity.values[4]).toBeCloseTo(518.850,3); + }); });