Skip to content

Commit

Permalink
Add tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
m-mohr committed Oct 13, 2023
1 parent f563a2c commit dafc6d9
Show file tree
Hide file tree
Showing 27 changed files with 753 additions and 69 deletions.
14 changes: 1 addition & 13 deletions absolute.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@
}
},
"examples": [
{
"arguments": {
"x": 0
},
"returns": 0
},
{
"arguments": {
"x": 3.5
Expand All @@ -45,12 +39,6 @@
"x": -0.4
},
"returns": 0.4
},
{
"arguments": {
"x": -3.5
},
"returns": 3.5
}
],
"links": [
Expand Down Expand Up @@ -95,4 +83,4 @@
"result": true
}
}
}
}
241 changes: 226 additions & 15 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,236 @@
# 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

The following processes have no test cases as the results heavily depend on the underlying implementation
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
- [ ] 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.
32 changes: 28 additions & 4 deletions tests/absolute.json5
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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": {
Expand Down
Loading

0 comments on commit dafc6d9

Please sign in to comment.