From b92d541ae2d0b0a210e585b77d1b8a148320be00 Mon Sep 17 00:00:00 2001 From: Stefaan Lippens Date: Thu, 5 Sep 2019 17:42:54 +0200 Subject: [PATCH] fixup! #76: ImageCollectionClient.band(): support both band names and indices --- tests/data/band0.json | 35 +++++++++++++++++++++++++++++++++++ tests/test_bandmath.py | 20 ++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 tests/data/band0.json diff --git a/tests/data/band0.json b/tests/data/band0.json new file mode 100644 index 000000000..791b9a0e9 --- /dev/null +++ b/tests/data/band0.json @@ -0,0 +1,35 @@ +{ + "loadcollection1": { + "arguments": { + "spatial_extent": null, + "id": "SENTINEL2_RADIOMETRY_10M", + "temporal_extent": null + }, + "process_id": "load_collection", + "result": false + }, + "reduce1": { + "arguments": { + "dimension": "spectral_bands", + "reducer": { + "callback": { + "r1": { + "arguments": { + "index": 0, + "data": { + "from_argument": "data" + } + }, + "process_id": "array_element", + "result": true + } + } + }, + "data": { + "from_node": "loadcollection1" + } + }, + "process_id": "reduce", + "result": false + } +} \ No newline at end of file diff --git a/tests/test_bandmath.py b/tests/test_bandmath.py index 2f52fbfe4..10a98c5ea 100644 --- a/tests/test_bandmath.py +++ b/tests/test_bandmath.py @@ -11,6 +11,26 @@ @requests_mock.mock() class TestBandMath(TestCase): + def test_basic(self, m): + session = openeo.connect("http://localhost:8000/api") + session.post = MagicMock() + session.download = MagicMock() + + m.get("http://localhost:8000/api/", json={"version": "0.4.0"}) + m.get("http://localhost:8000/api/collections/SENTINEL2_RADIOMETRY_10M", json={"product_id": "sentinel2_subset", + "bands": [{'band_id': 'B02'}, + {'band_id': 'B04'}, + {'band_id': 'B08'}, + ], + 'time': {'from': '2015-06-23', + 'to': '2018-06-18'}}) + + cube = session.imagecollection("SENTINEL2_RADIOMETRY_10M") + expected_graph = load_json_resource('data/band0.json') + + assert cube.band(0).graph == expected_graph + assert cube.band('B02').graph == expected_graph + def test_evi(self,m): # configuration phase: define username, endpoint, parameters? session = openeo.connect("http://localhost:8000/api")