From 2ef8ce35e3fc070212c97de1b388169ccf1ec493 Mon Sep 17 00:00:00 2001 From: Calvin Pritchard Date: Thu, 18 Feb 2021 18:16:46 -0700 Subject: [PATCH] test: polygon tests changes currently in skope-api --- .../__tests__/timeseries.polygon.tests.js | 239 +++--------------- 1 file changed, 38 insertions(+), 201 deletions(-) diff --git a/javascript/__tests__/timeseries.polygon.tests.js b/javascript/__tests__/timeseries.polygon.tests.js index 0101d9a..a439798 100644 --- a/javascript/__tests__/timeseries.polygon.tests.js +++ b/javascript/__tests__/timeseries.polygon.tests.js @@ -43,17 +43,6 @@ describe("When a GET request selects from a region exactly covering the northwes expect(response.entity.values[3]).toBeCloseTo(405.5,3); expect(response.entity.values[4]).toBeCloseTo(505.5,3); }); - - it ('The data column should comprise the average of four pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, uint16_variable" + "\n" + - "0,105.500" + "\n" + - "1,205.500" + "\n" + - "2,305.500" + "\n" + - "3,405.500" + "\n" + - "4,505.500" + "\n" - ); - }); }); describe("When a GET request selects from a region exactly covering the northwest 2x2 pixel area in the float32 variable", async () => { @@ -94,17 +83,6 @@ describe("When a GET request selects from a region exactly covering the northwes expect(response.entity.values[3]).toBeCloseTo(405.55,3); expect(response.entity.values[4]).toBeCloseTo(505.55,3); }); - - it ('The data column should comprise the average of four pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, float32_variable, range -, range +" + "\n" + - "0,105.550,95.0000,116.100" + "\n" + - "1,205.550,185.000,226.100" + "\n" + - "2,305.550,275.000,336.100" + "\n" + - "3,405.550,365.000,446.100" + "\n" + - "4,505.550,455.000,556.100" + "\n" - ); - }); }); describe("When a GET request selects from a region of zero area from the uint16 variable", async () => { @@ -134,17 +112,13 @@ describe("When a GET request selects from a region of zero area from the uint16 }); }); - it ('HTTP response status code should be 400', async function() { - expect(response.status.code).toBe(400); - }); - - it ('Error summary should be bad request', async function() { - expect(response.entity.error).toBe("Bad Request"); + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); }); - it ('Error message should be that longitude parameter is not present', async function() { - expect(response.entity.message).toBe("The selected area does not overlap the region covered by the dataset"); - }); + 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 () => { @@ -174,17 +148,13 @@ describe("When a GET request selects from a region of zero area from the float32 }); }); - it ('HTTP response status code should be 400', async function() { - expect(response.status.code).toBe(400); + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); }); - it ('Error summary should be bad request', async function() { - expect(response.entity.error).toBe("Bad Request"); + it ('Error type should be out of bounds', async function() { + expect(response.entity.detail[0].type).toBe("value_error.selectedareapolygonisnotvalid"); }); - - it ('Error message should be that longitude parameter is not present', async function() { - expect(response.entity.message).toBe("The selected area does not overlap the region covered by the dataset"); - }); }); @@ -226,17 +196,6 @@ describe("When a GET request selects from a 2x2 pixel region that intersects a 2 expect(response.entity.values[3]).toBeCloseTo(400.5,3); expect(response.entity.values[4]).toBeCloseTo(500.5,3); }); - - it ('The data column should comprise the average of the two pixels intersection of polygon and dataset', async function() { - expect(response.entity.csv).toEqual( - "index, uint16_variable" + "\n" + - "0,100.500" + "\n" + - "1,200.500" + "\n" + - "2,300.500" + "\n" + - "3,400.500" + "\n" + - "4,500.500" + "\n" - ); - }); }); describe("When a GET request selects from a 2x2 pixel region that intersects a 2x1 pixel region in the float32 variable", async () => { @@ -277,17 +236,6 @@ describe("When a GET request selects from a 2x2 pixel region that intersects a 2 expect(response.entity.values[3]).toBeCloseTo(400.55,3); expect(response.entity.values[4]).toBeCloseTo(500.55,3); }); - - it ('The data column should comprise the average of the two pixels intersection of polygon and dataset', async function() { - expect(response.entity.csv).toEqual( - "index, float32_variable, range -, range +" + "\n" + - "0,100.550,90.5000,110.600" + "\n" + - "1,200.550,180.500,220.600" + "\n" + - "2,300.550,270.500,330.600" + "\n" + - "3,400.550,360.500,440.600" + "\n" + - "4,500.550,450.500,550.600" + "\n" - ); - }); }); @@ -304,13 +252,13 @@ describe("When a GET request selects a region just outside coverage of the uint1 variableName: 'uint16_variable', boundaryGeometry: { "type": "Polygon", - "coordinates": [[ - [-124,45], - [-124,47], - [-123,47], - [-123,45], - [-123,45] - ]] + "coordinates": [[ + [-124,45], + [-124,47], + [-123,47], + [-123,45], + [-124,45] + ]] }, start: 0, end: 4 @@ -318,17 +266,13 @@ describe("When a GET request selects a region just outside coverage of the uint1 }); }); - it ('HTTP response status code should be 400', async function() { - expect(response.status.code).toBe(400); + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); }); - it ('Error summary should be bad request', async function() { - expect(response.entity.error).toBe("Bad Request"); + it ('Error type should be out of bounds', async function() { + expect(response.entity.detail[0].type).toBe("value_error.selectedareaoutofbounds"); }); - - it ('Error message should be that longitude parameter is not present', async function() { - expect(response.entity.message).toBe("The selected area does not overlap the region covered by the dataset"); - }); }); describe("When a GET request selects a region just outside coverage of the float32 variable", async () => { @@ -349,7 +293,7 @@ describe("When a GET request selects a region just outside coverage of the float [-124,43], [-123,43], [-123,45], - [-123,45] + [-124,45] ]] }, start: 0, @@ -358,16 +302,12 @@ describe("When a GET request selects a region just outside coverage of the float }); }); - it ('HTTP response status code should be 400', async function() { - expect(response.status.code).toBe(400); + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); }); - it ('Error summary should be bad request', async function() { - expect(response.entity.error).toBe("Bad Request"); - }); - - it ('Error message should be that coordinates are outside dataset coverage', async function() { - expect(response.entity.message).toBe("The selected area does not overlap the region covered by the dataset"); + it ('Error type should be out of bounds', async function() { + expect(response.entity.detail[0].type).toBe("value_error.selectedareaoutofbounds"); }); }); @@ -389,7 +329,7 @@ describe("When a GET request selects a region well outside coverage of the float [-104,35], [-103,35], [-103,37], - [-103,37] + [-104,37] ]] }, start: 0, @@ -398,16 +338,12 @@ describe("When a GET request selects a region well outside coverage of the float }); }); - it ('HTTP response status code should be 400', async function() { - expect(response.status.code).toBe(400); + it ('HTTP response status code should be 422', async function() { + expect(response.status.code).toBe(422); }); - it ('Error summary should be bad request', async function() { - expect(response.entity.error).toBe("Bad Request"); - }); - - it ('Error message should be that coordinates are outside dataset coverage', async function() { - expect(response.entity.message).toBe("The selected area does not overlap the region covered by the dataset"); + it ('Error type should be out of bounds', async function() { + expect(response.entity.detail[0].type).toBe("value_error.selectedareaoutofbounds"); }); }); @@ -449,17 +385,6 @@ describe("When a GET request selects exactly the top-left corner pixel of the ui expect(response.entity.values[3]).toBeCloseTo(400.0,3); expect(response.entity.values[4]).toBeCloseTo(500.0,3); }); - - it ('The data column should comprise the values of the top-left pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, uint16_variable" + "\n" + - "0,100.000" + "\n" + - "1,200.000" + "\n" + - "2,300.000" + "\n" + - "3,400.000" + "\n" + - "4,500.000" + "\n" - ); - }); }); describe("When a GET request selects exactly the top-left corner pixel of the float32 variable", async () => { @@ -500,17 +425,6 @@ describe("When a GET request selects exactly the top-left corner pixel of the fl expect(response.entity.values[3]).toBeCloseTo(400.0,3); expect(response.entity.values[4]).toBeCloseTo(500.0,3); }); - - it ('The data column should comprise the values of the top-left pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, float32_variable, range -, range +" + "\n" + - "0,100.000,90.0000,110.000" + "\n" + - "1,200.000,180.000,220.000" + "\n" + - "2,300.000,270.000,330.000" + "\n" + - "3,400.000,360.000,440.000" + "\n" + - "4,500.000,450.000,550.000" + "\n" - ); - }); }); @@ -552,17 +466,6 @@ describe("When a GET request selects 1/4 of the top-left corner pixel of the uin expect(response.entity.values[3]).toBeCloseTo(400.0,3); expect(response.entity.values[4]).toBeCloseTo(500.0,3); }); - - it ('The data column should comprise the values of the top-left pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, uint16_variable" + "\n" + - "0,100.000" + "\n" + - "1,200.000" + "\n" + - "2,300.000" + "\n" + - "3,400.000" + "\n" + - "4,500.000" + "\n" - ); - }); }); describe("When a GET request selects 1/4 of the top-left corner pixel of the float32 variable", async () => { @@ -603,17 +506,6 @@ describe("When a GET request selects 1/4 of the top-left corner pixel of the flo expect(response.entity.values[3]).toBeCloseTo(400.0,3); expect(response.entity.values[4]).toBeCloseTo(500.0,3); }); - - it ('The data column should comprise the values of the top-left pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, float32_variable, range -, range +" + "\n" + - "0,100.000,90.0000,110.000" + "\n" + - "1,200.000,180.000,220.000" + "\n" + - "2,300.000,270.000,330.000" + "\n" + - "3,400.000,360.000,440.000" + "\n" + - "4,500.000,450.000,550.000" + "\n" - ); - }); }); @@ -656,17 +548,6 @@ describe("When a GET request selects from a region exactly covering the 2x2 pixe expect(response.entity.values[3]).toBeCloseTo(435.5,3); expect(response.entity.values[4]).toBeCloseTo(535.5,3); }); - - it ('The data column should comprise the average of four pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, uint16_variable" + "\n" + - "0,135.500" + "\n" + - "1,235.500" + "\n" + - "2,335.500" + "\n" + - "3,435.500" + "\n" + - "4,535.500" + "\n" - ); - }); }); 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 () => { @@ -684,10 +565,10 @@ describe("When a GET request selects from a region exactly covering the 2x2 pixe "type": "Polygon", "coordinates": [[ [-120,42], + [-118,42], [-118,40], [-120,40], - [-120,42], - [-118,42] + [-120,42] ]] }, start: 0, @@ -707,17 +588,6 @@ describe("When a GET request selects from a region exactly covering the 2x2 pixe expect(response.entity.values[3]).toBeCloseTo(440.0,3); expect(response.entity.values[4]).toBeCloseTo(540.0,3); }); - - it ('The data column should comprise the average of four pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, uint16_variable" + "\n" + - "0,140.000" + "\n" + - "1,240.000" + "\n" + - "2,340.000" + "\n" + - "3,440.000" + "\n" + - "4,540.000" + "\n" - ); - }); }); 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 () => { @@ -735,10 +605,10 @@ describe("When a GET request selects from a region exactly covering the 2x2 pixe "type": "Polygon", "coordinates": [[ [-120,42], + [-118,42], [-118,40], [-120,40], - [-120,42], - [-118,42] + [-120,42] ]] }, start: 0, @@ -754,17 +624,6 @@ describe("When a GET request selects from a region exactly covering the 2x2 pixe 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]); }); - - it ('The data column should comprise the average of four pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, float32_variable, range -, range +" + "\n" + - "0,,," + "\n" + - "1,,," + "\n" + - "2,,," + "\n" + - "3,,," + "\n" + - "4,,," + "\n" - ); - }); }); @@ -783,10 +642,10 @@ describe("When a GET request selects from a region exactly covering the 2x2 pixe "type": "Polygon", "coordinates": [[ [-120,43], + [-118,43], [-118,41], [-120,41], - [-120,43], - [-118,43] + [-120,43] ]] }, start: 0, @@ -806,17 +665,6 @@ describe("When a GET request selects from a region exactly covering the 2x2 pixe expect(response.entity.values[3]).toBeCloseTo(426.667,3); expect(response.entity.values[4]).toBeCloseTo(526.667,3); }); - - it ('The data column should comprise the average of four pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, uint16_variable" + "\n" + - "0,126.667" + "\n" + - "1,226.667" + "\n" + - "2,328.000" + "\n" + - "3,426.667" + "\n" + - "4,526.667" + "\n" - ); - }); }); @@ -835,10 +683,10 @@ describe("When a GET request selects from a region exactly covering the 2x2 pixe "type": "Polygon", "coordinates": [[ [-120,44], + [-118,44], [-118,42], [-120,42], - [-120,44], - [-118,44] + [-120,44] ]] }, start: 0, @@ -858,16 +706,5 @@ describe("When a GET request selects from a region exactly covering the 2x2 pixe expect(response.entity.values[3]).toBeCloseTo(418.850,3); expect(response.entity.values[4]).toBeCloseTo(518.850,3); }); - - it ('The data column should comprise the average of four pixels in each band', async function() { - expect(response.entity.csv).toEqual( - "index, float32_variable, range -, range +" + "\n" + - "0,118.850,107.000,130.700" + "\n" + - "1,218.850,197.000,240.700" + "\n" + - "2,,," + "\n" + - "3,418.850,377.000,460.700" + "\n" + - "4,518.850,467.000,570.700" + "\n" - ); - }); });