diff --git a/absolute.json b/absolute.json index 3b6e91dc..a1fc1d50 100644 --- a/absolute.json +++ b/absolute.json @@ -28,12 +28,6 @@ } }, "examples": [ - { - "arguments": { - "x": 0 - }, - "returns": 0 - }, { "arguments": { "x": 3.5 @@ -45,12 +39,6 @@ "x": -0.4 }, "returns": 0.4 - }, - { - "arguments": { - "x": -3.5 - }, - "returns": 3.5 } ], "links": [ @@ -95,4 +83,4 @@ "result": true } } -} \ No newline at end of file +} diff --git a/tests/README.md b/tests/README.md index c124b15e..81dda3a0 100644 --- a/tests/README.md +++ b/tests/README.md @@ -1,7 +1,148 @@ # Tests This folder contains test cases for the openEO processes. -To allow for more data types (e.g. infinity and nan for numbers), all the files are encoded in **JSON5**. + +## Supported processes + +- [x] absolute +- [x] add +- [ ] add_dimension +- [ ] aggregate_spatial +- [ ] aggregate_spatial_window +- [ ] aggregate_temporal +- [ ] aggregate_temporal_period +- [x] all +- [x] and +- [ ] anomaly +- [x] any +- [ ] apply +- [ ] apply_dimension +- [ ] apply_kernel +- [ ] apply_neighborhood +- [ ] apply_polygon +- [ ] arccos +- [ ] arcosh +- [ ] arcsin +- [ ] arctan +- [ ] arctan2 +- [ ] array_append +- [ ] array_apply +- [ ] array_concat +- [ ] array_contains +- [ ] array_create +- [ ] array_create_labeled +- [ ] array_element +- [ ] array_filter +- [ ] array_find +- [ ] array_find_label +- [ ] array_interpolate_linear +- [ ] array_labels +- [ ] array_modify +- [ ] arsinh +- [ ] artanh +- [ ] between +- [ ] ceil +- [ ] climatological_normal +- [ ] clip +- [x] constant +- [ ] cos +- [ ] cosh +- [ ] count +- [ ] create_data_cube +- [ ] cummax +- [ ] cummin +- [ ] cumproduct +- [ ] cumsum +- [ ] date_between +- [ ] date_difference +- [ ] date_shift +- [ ] dimension_labels +- [ ] divide +- [ ] drop_dimension +- [x] e +- [ ] eq +- [ ] exp +- [ ] extrema +- [ ] filter_bands +- [ ] filter_bbox +- [ ] filter_labels +- [ ] filter_spatial +- [ ] filter_temporal +- [ ] filter_vector +- [ ] first +- [ ] flatten_dimensions +- [ ] floor +- [ ] gt +- [ ] gte +- [ ] if +- [ ] int +- [ ] is_infinite +- [x] is_nan +- [ ] is_valid +- [ ] last +- [ ] linear_scale_range +- [ ] ln +- [ ] load_geojson +- [ ] load_stac +- [ ] load_uploaded_files +- [ ] load_url +- [ ] log +- [ ] lt +- [ ] lte +- [ ] mask +- [ ] mask_polygon +- [ ] max +- [ ] mean +- [ ] median +- [ ] merge_cubes +- [ ] min +- [ ] mod +- [ ] multiply +- [x] nan +- [ ] ndvi +- [ ] neq +- [ ] normalized_difference +- [x] not +- [x] or +- [ ] order +- [x] pi +- [ ] power +- [ ] product +- [ ] quantiles +- [ ] rearrange +- [ ] reduce_dimension +- [ ] reduce_spatial +- [ ] rename_dimension +- [ ] rename_labels +- [ ] resample_cube_spatial +- [ ] resample_cube_temporal +- [ ] resample_spatial +- [ ] round +- [ ] sd +- [ ] sgn +- [ ] sin +- [ ] sinh +- [ ] sort +- [ ] sqrt +- [x] subtract +- [ ] sum +- [ ] tan +- [ ] tanh +- [x] text_begins +- [x] text_concat +- [x] text_contains +- [x] text_ends +- [ ] trim_cube +- [ ] unflatten_dimension +- [ ] variance +- [ ] vector_buffer +- [ ] vector_reproject +- [ ] vector_to_regular_points +- [x] xor + +## Incomplete processes + +- [x] is_nodata - actual no-data values depends on context / metadata ## Missing processes @@ -9,17 +150,87 @@ The following processes have no test cases as the results heavily depend on the or need an external services to be available for testing (e.g. loading files from the user workspace or a UDF server). We don't expect that we can provide meaningful test cases for these processes. -- ard_normalized_radar_backscatter -- ard_surface_reflectance -- atmospheric_correction -- cloud_detection -- fit_curve -- inspect -- load_collection -- load_uploaded_files -- predict_curve -- run_udf -- run_udf_externally -- sar_backscatter -- save_result -- vector_to_random_points \ No newline at end of file +- [ ] ard_normalized_radar_backscatter +- [ ] ard_surface_reflectance +- [ ] atmospheric_correction +- [ ] cloud_detection +- [ ] fit_curve +- [ ] inspect +- [ ] load_collection +- [ ] load_uploaded_files +- [ ] predict_curve +- [ ] run_udf +- [ ] run_udf_externally +- [ ] sar_backscatter +- [ ] save_result +- [ ] vector_to_random_points + +## Assumptions + +The test cases assume a couple of things as they are an abstraction and not bound to specific implementations: +- The JSON Schema type `number` explicitly includes the values `+Infinity`, `-Infinity` and `NaN`. +- The input and output values for no-data values are `null`, so there's no mapping to e.g. `0` as no-data value. +- Input that is not valid according to the schemas, will be rejected upfront and will not be checked on. For example, the absolute process only tests against the data types `number` and `null`. There are no tests for a boolean or string input. +- Numerical data types such as uint8 don't matter, i.e. tests don't check for overflows etc. This suite can't provide such tests as the underlying data type is not known. + +## Test Files + +To allow for more data types (e.g. infinity and nan for numbers), all the files are encoded in **JSON5** instead of JSON. + +The test files have the following schema: + +```yaml +description: A document with test cases for a specific openEO process +type: object +required: + - tests +properties: + tests: + description: A list of test cases without a specific order + type: array + items: + description: A test case with a set of arguments and a specific return value or exception + type: object + required: + - arguments + properties: + arguments: + description: A key-value pair for an argument. Key = Parameter name, Value = Argument value + type: object + additionalProperties: + description: An argument, can be of any type + oneOf: + - required: + - returns + properties: + returns: + description: The return value, can be of any type + delta: + description: If set to a positive number the equality of the actual return value and the expected return value is checked against a delta value to circumvent problems with floating-point inaccuracy. + type: number + - required: + - throws + properties: + throws: + oneOf: + - description: Specify an exception name from the process specification + type: string + minLength: 1 + - description: Use true if the type of exception is unknown + type: boolean + const: true +``` + +Arguments and return values can point to external files, e.g. +```json +{ + "$ref": "https://host.example/file.nc" +} +``` + +### Assets + +Additional assets will be provided for the test cases. + +- Raster data cubes will be provided as CoverageJSON. +- Multi-dimensional vector data cubes can't be provided right now, we use GeoJSON whenever possible. diff --git a/tests/absolute.json5 b/tests/absolute.json5 index e7f17c42..fbd1f53e 100644 --- a/tests/absolute.json5 +++ b/tests/absolute.json5 @@ -1,5 +1,29 @@ { "tests": [ + { + "arguments": { + "x": -Infinity + }, + "returns": Infinity + }, + { + "arguments": { + "x": Infinity + }, + "returns": Infinity + }, + { + "arguments": { + "x": NaN + }, + "returns": NaN + }, + { + "arguments": { + "x": null + }, + "returns": null + }, { "arguments": { "x": 0 @@ -8,15 +32,15 @@ }, { "arguments": { - "x": 3.5 + "x": -1 }, - "returns": 3.5 + "returns": 1 }, { "arguments": { - "x": -0.4 + "x": 3.5 }, - "returns": 0.4 + "returns": 3.5 }, { "arguments": { diff --git a/tests/add.json5 b/tests/add.json5 index 1b0c998c..4ceab658 100644 --- a/tests/add.json5 +++ b/tests/add.json5 @@ -1,5 +1,68 @@ { "tests": [ + { + "arguments": { + "x": Infinity, + "y": -1 + }, + "returns": Infinity + }, + { + "arguments": { + "x": 1, + "y": -Infinity + }, + "returns": -Infinity + }, + { + "arguments": { + "x": Infinity, + "y": -Infinity + }, + "returns": NaN + }, + { + "arguments": { + "x": -Infinity, + "y": -Infinity + }, + "returns": -Infinity + }, + { + "arguments": { + "x": Infinity, + "y": Infinity + }, + "returns": Infinity + }, + { + "arguments": { + "x": Infinity, + "y": NaN + }, + "returns": NaN + }, + { + "arguments": { + "x": NaN, + "y": -Infinity + }, + "returns": NaN + }, + { + "arguments": { + "x": Infinity, + "y": null + }, + "returns": null + }, + { + "arguments": { + "x": null, + "y": -Infinity + }, + "returns": null + }, { "arguments": { "x": 5, @@ -14,12 +77,33 @@ }, "returns": -6 }, + { + "arguments": { + "x": 5.25, + "y": 0 + }, + "returns": 5.25 + }, + { + "arguments": { + "x": 250, + "y": 10 + }, + "returns": 260 + }, { "arguments": { "x": 1, "y": null }, "returns": null + }, + { + "arguments": { + "x": null, + "y": -1 + }, + "returns": null } ] } \ No newline at end of file diff --git a/tests/constant.json5 b/tests/constant.json5 index 308e1aa1..664fd424 100644 --- a/tests/constant.json5 +++ b/tests/constant.json5 @@ -1,3 +1,102 @@ { - "tests": [] + "tests": [ + { + "arguments": { + "x": 0 + }, + "returns": 0 + }, + { + "arguments": { + "x": -260 + }, + "returns": -260 + }, + { + "arguments": { + "x": 66666 + }, + "returns": 66666 + }, + { + "arguments": { + "x": 0.123456789 + }, + "returns": 0.123456789 + }, + { + "arguments": { + "x": NaN + }, + "returns": NaN + }, + { + "arguments": { + "x": Infinity + }, + "returns": Infinity + }, + { + "arguments": { + "x": -Infinity + }, + "returns": -Infinity + }, + { + "arguments": { + "x": true + }, + "returns": true + }, + { + "arguments": { + "x": false + }, + "returns": false + }, + { + "arguments": { + "x": null + }, + "returns": null + }, + { + "arguments": { + "x": "test" + }, + "returns": "test" + }, + { + "arguments": { + "x": [] + }, + "returns": [] + }, + { + "arguments": { + "x": [1,2,3,-4] + }, + "returns": [1,2,3,-4] + }, + { + "arguments": { + "x": [0,NaN,null,false,""] + }, + "returns": [0,NaN,null,false,""] + }, + { + "arguments": { + "x": { + "a": "b", + "b": 123, + "c": [] + } + }, + "returns": { + "a": "b", + "b": 123, + "c": [] + } + } + ] } \ No newline at end of file diff --git a/tests/e.json5 b/tests/e.json5 index 308e1aa1..2a02d4d8 100644 --- a/tests/e.json5 +++ b/tests/e.json5 @@ -1,3 +1,9 @@ { - "tests": [] + "tests": [ + { + "arguments": {}, + "returns": 2.718281828459, + "delta": 0.000000000001 + } + ] } \ No newline at end of file diff --git a/tests/is_infinite.json5 b/tests/is_infinite.json5 index 308e1aa1..2c6ac1cf 100644 --- a/tests/is_infinite.json5 +++ b/tests/is_infinite.json5 @@ -1,3 +1,112 @@ { - "tests": [] + "tests": [ + { + "arguments": { + "x": Infinity + }, + "returns": true + }, + { + "arguments": { + "x": -Infinity + }, + "returns": true + }, + { + "arguments": { + "x": 1 + }, + "returns": false + }, + { + "arguments": { + "x": -123456789.0 + }, + "returns": false + }, + { + "arguments": { + "x": NaN + }, + "returns": false + }, + { + "arguments": { + "x": true + }, + "returns": false + }, + { + "arguments": { + "x": false + }, + "returns": false + }, + { + "arguments": { + "x": [Infinity] + }, + "returns": false + }, + { + "arguments": { + "x": [] + }, + "returns": false + }, + { + "arguments": { + "x": {} + }, + "returns": false + }, + { + "arguments": { + "x": {"inf": Infinity} + }, + "returns": false + }, + { + "arguments": { + "x": "-infinity" + }, + "returns": false + }, + { + "arguments": { + "x": "-Infinity" + }, + "returns": false + }, + { + "arguments": { + "x": "-inf" + }, + "returns": false + }, + { + "arguments": { + "x": "infinity" + }, + "returns": false + }, + { + "arguments": { + "x": "Infinity" + }, + "returns": false + }, + { + "arguments": { + "x": "inf" + }, + "returns": false + }, + { + "arguments": { + "x": null + }, + "returns": false + } + ] } \ No newline at end of file diff --git a/tests/is_nan.json5 b/tests/is_nan.json5 index 7aa14245..a991a6d7 100644 --- a/tests/is_nan.json5 +++ b/tests/is_nan.json5 @@ -8,7 +8,73 @@ }, { "arguments": { - "x": "Test" + "x": -123456789.0 + }, + "returns": false + }, + { + "arguments": { + "x": Infinity + }, + "returns": false + }, + { + "arguments": { + "x": -Infinity + }, + "returns": false + }, + { + "arguments": { + "x": NaN + }, + "returns": true + }, + { + "arguments": { + "x": true + }, + "returns": true + }, + { + "arguments": { + "x": false + }, + "returns": true + }, + { + "arguments": { + "x": [NaN] + }, + "returns": true + }, + { + "arguments": { + "x": [] + }, + "returns": true + }, + { + "arguments": { + "x": {} + }, + "returns": true + }, + { + "arguments": { + "x": {"nan": NaN} + }, + "returns": true + }, + { + "arguments": { + "x": "NaN" + }, + "returns": true + }, + { + "arguments": { + "x": "nan" }, "returns": true }, diff --git a/tests/is_nodata.json5 b/tests/is_nodata.json5 index d316a73a..dd81695c 100644 --- a/tests/is_nodata.json5 +++ b/tests/is_nodata.json5 @@ -1,22 +1,24 @@ { + // We can't check for other no-data values than `null` + // as it depends on the data cube / metadata / context, which can't influence "tests": [ { "arguments": { - "x": 1 + "x": null }, - "returns": false + "returns": true }, { "arguments": { - "x": "Test" + "x": 1 }, "returns": false }, { "arguments": { - "x": null + "x": "Test" }, - "returns": true + "returns": false }, { "arguments": { diff --git a/tests/nan.json5 b/tests/nan.json5 index 308e1aa1..6e0a71c4 100644 --- a/tests/nan.json5 +++ b/tests/nan.json5 @@ -1,3 +1,8 @@ { - "tests": [] + "tests": [ + { + "arguments": {}, + "returns": NaN + } + ] } \ No newline at end of file diff --git a/tests/pi.json5 b/tests/pi.json5 index 308e1aa1..19c411a7 100644 --- a/tests/pi.json5 +++ b/tests/pi.json5 @@ -1,3 +1,9 @@ { - "tests": [] + "tests": [ + { + "arguments": {}, + "returns": 3.14159265, + "delta": 0.00000001 + } + ] } \ No newline at end of file diff --git a/tests/subtract.json5 b/tests/subtract.json5 index 7a9f82d6..e2c77377 100644 --- a/tests/subtract.json5 +++ b/tests/subtract.json5 @@ -1,5 +1,68 @@ { "tests": [ + { + "arguments": { + "x": Infinity, + "y": -1 + }, + "returns": Infinity + }, + { + "arguments": { + "x": 1, + "y": -Infinity + }, + "returns": -Infinity + }, + { + "arguments": { + "x": Infinity, + "y": -Infinity + }, + "returns": Infinity + }, + { + "arguments": { + "x": -Infinity, + "y": -Infinity + }, + "returns": NaN + }, + { + "arguments": { + "x": Infinity, + "y": Infinity + }, + "returns": Infinity + }, + { + "arguments": { + "x": Infinity, + "y": NaN + }, + "returns": NaN + }, + { + "arguments": { + "x": NaN, + "y": -Infinity + }, + "returns": NaN + }, + { + "arguments": { + "x": Infinity, + "y": null + }, + "returns": null + }, + { + "arguments": { + "x": null, + "y": -Infinity + }, + "returns": null + }, { "arguments": { "x": 5, @@ -13,6 +76,20 @@ "y": 4 }, "returns": -6 + } + { + "arguments": { + "x": 5.25, + "y": 0 + }, + "returns": 5.25 + }, + { + "arguments": { + "x": -250, + "y": 10 + }, + "returns": -260 }, { "arguments": { @@ -20,6 +97,13 @@ "y": null }, "returns": null + }, + { + "arguments": { + "x": null, + "y": -1 + }, + "returns": null } ] } \ No newline at end of file