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 71024a0
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 20 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
}
}
}
}
196 changes: 194 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,146 @@
# 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
- [ ] constant
- [ ] cos
- [ ] cosh
- [ ] count
- [ ] create_data_cube
- [ ] cummax
- [ ] cummin
- [ ] cumproduct
- [ ] cumsum
- [ ] date_between
- [ ] date_difference
- [ ] date_shift
- [ ] dimension_labels
- [ ] divide
- [ ] drop_dimension
- [ ] 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
- [ ] is_nan
- [ ] is_nodata
- [ ] 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
- [ ] nan
- [ ] ndvi
- [ ] neq
- [ ] normalized_difference
- [x] not
- [x] or
- [ ] order
- [ ] pi
- [ ] power
- [ ] product
- [ ] quantiles
- [ ] README.md
- [ ] 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
- [ ] text_begins
- [ ] text_concat
- [ ] text_contains
- [ ] text_ends
- [ ] trim_cube
- [ ] unflatten_dimension
- [ ] variance
- [ ] vector_buffer
- [ ] vector_reproject
- [ ] vector_to_regular_points
- [ ] xor

## Missing processes

Expand All @@ -22,4 +161,57 @@ We don't expect that we can provide meaningful test cases for these processes.
- run_udf_externally
- sar_backscatter
- save_result
- vector_to_random_points
- 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
- 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
```
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
84 changes: 84 additions & 0 deletions tests/add.json5
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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
}
]
}
Loading

0 comments on commit 71024a0

Please sign in to comment.