Skip to content

Commit d8a4718

Browse files
issue693 add test for sar_backscatter with coefficient check
1 parent 877c1a3 commit d8a4718

File tree

1 file changed

+25
-94
lines changed

1 file changed

+25
-94
lines changed

tests/rest/datacube/test_datacube100.py

Lines changed: 25 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2774,36 +2774,7 @@ def test_print_json_file_path(con100, tmp_path, path_factory):
27742774
assert path.read_text() == EXPECTED_JSON_EXPORT_S2_NDVI + "\n"
27752775

27762776

2777-
def test_sar_backscatter_defaults(con100, requests_mock):
2778-
requests_mock.get(API_URL, json={"api_version": "1.0.0"})
2779-
processes = [
2780-
{
2781-
"id": "sar_backscatter",
2782-
"description": "Computes backscatter from SAR input",
2783-
"summary": "Computes backscatter from SAR input",
2784-
"parameters": [
2785-
{
2786-
"default": "gamma0-terrain",
2787-
"description": "Select the radiometric correction coefficient.",
2788-
"name": "coefficient",
2789-
"schema": [
2790-
{
2791-
"enum": [
2792-
"beta0",
2793-
"sigma0-ellipsoid",
2794-
"sigma0-terrain",
2795-
"gamma0-ellipsoid",
2796-
"gamma0-terrain",
2797-
],
2798-
"type": "string",
2799-
},
2800-
],
2801-
},
2802-
],
2803-
"returns": {"description": "incremented value", "schema": {"type": "integer"}},
2804-
}
2805-
]
2806-
requests_mock.get(API_URL + "/processes", json={"processes": processes})
2777+
def test_sar_backscatter_defaults(con100):
28072778
cube = con100.load_collection("S2").sar_backscatter()
28082779
assert _get_leaf_node(cube) == {
28092780
"process_id": "sar_backscatter",
@@ -2821,36 +2792,7 @@ def test_sar_backscatter_defaults(con100, requests_mock):
28212792
}
28222793

28232794

2824-
def test_sar_backscatter_custom(con100, requests_mock):
2825-
requests_mock.get(API_URL, json={"api_version": "1.0.0"})
2826-
processes = [
2827-
{
2828-
"id": "sar_backscatter",
2829-
"description": "Computes backscatter from SAR input",
2830-
"summary": "Computes backscatter from SAR input",
2831-
"parameters": [
2832-
{
2833-
"default": "gamma0-terrain",
2834-
"description": "Select the radiometric correction coefficient.",
2835-
"name": "coefficient",
2836-
"schema": [
2837-
{
2838-
"enum": [
2839-
"beta0",
2840-
"sigma0-ellipsoid",
2841-
"sigma0-terrain",
2842-
"gamma0-ellipsoid",
2843-
"gamma0-terrain",
2844-
],
2845-
"type": "string",
2846-
},
2847-
],
2848-
},
2849-
],
2850-
"returns": {"description": "incremented value", "schema": {"type": "integer"}},
2851-
}
2852-
]
2853-
requests_mock.get(API_URL + "/processes", json={"processes": processes})
2795+
def test_sar_backscatter_custom(con100):
28542796
cube = con100.load_collection("S2")
28552797
cube = cube.sar_backscatter(
28562798
coefficient="sigma0-ellipsoid",
@@ -2874,42 +2816,19 @@ def test_sar_backscatter_custom(con100, requests_mock):
28742816
}
28752817

28762818

2877-
def test_sar_backscatter_coefficient_none(con100, requests_mock):
2878-
requests_mock.get(API_URL, json={"api_version": "1.0.0"})
2879-
processes = [
2880-
{
2881-
"id": "sar_backscatter",
2882-
"description": "Computes backscatter from SAR input",
2883-
"summary": "Computes backscatter from SAR input",
2884-
"parameters": [
2885-
{
2886-
"default": "gamma0-terrain",
2887-
"description": "Select the radiometric correction coefficient.",
2888-
"name": "coefficient",
2889-
"schema": [
2890-
{
2891-
"enum": [
2892-
"beta0",
2893-
"sigma0-ellipsoid",
2894-
"sigma0-terrain",
2895-
"gamma0-ellipsoid",
2896-
"gamma0-terrain",
2897-
],
2898-
"type": "string",
2899-
},
2900-
],
2901-
},
2902-
],
2903-
"returns": {"description": "incremented value", "schema": {"type": "integer"}},
2904-
}
2905-
]
2906-
requests_mock.get(API_URL + "/processes", json={"processes": processes})
2819+
def test_sar_backscatter_coefficient_none(con100):
29072820
cube = con100.load_collection("S2")
29082821
cube = cube.sar_backscatter(coefficient=None)
29092822
assert _get_leaf_node(cube)["arguments"]["coefficient"] is None
29102823

29112824

2912-
def test_sar_backscatter_coefficient_invalid(con100, requests_mock):
2825+
def test_sar_backscatter_coefficient_invalid(con100):
2826+
cube = con100.load_collection("S2")
2827+
with pytest.raises(OpenEoClientException, match="Invalid.*coef.*unicorn.*Should.*sigma0-ellipsoid.*gamma0-terrain"):
2828+
cube.sar_backscatter(coefficient="unicorn")
2829+
2830+
2831+
def test_sar_backscatter_check_coefficient_backend(con100, requests_mock):
29132832
requests_mock.get(API_URL, json={"api_version": "1.0.0"})
29142833
processes = [
29152834
{
@@ -2939,9 +2858,21 @@ def test_sar_backscatter_coefficient_invalid(con100, requests_mock):
29392858
}
29402859
]
29412860
requests_mock.get(API_URL + "/processes", json={"processes": processes})
2942-
cube = con100.load_collection("S2")
2943-
with pytest.raises(OpenEoClientException, match="Invalid.*coef.*unicorn.*Should.*sigma0-ellipsoid.*gamma0-terrain"):
2944-
cube.sar_backscatter(coefficient="unicorn")
2861+
cube = con100.load_collection("S2").sar_backscatter()
2862+
assert _get_leaf_node(cube) == {
2863+
"process_id": "sar_backscatter",
2864+
"arguments": {
2865+
"data": {"from_node": "loadcollection1"},
2866+
"coefficient": "gamma0-terrain",
2867+
"elevation_model": None,
2868+
"mask": False,
2869+
"contributing_area": False,
2870+
"local_incidence_angle": False,
2871+
"ellipsoid_incidence_angle": False,
2872+
"noise_removal": True,
2873+
},
2874+
"result": True,
2875+
}
29452876

29462877

29472878
def test_datacube_from_process(con100):

0 commit comments

Comments
 (0)