コード例 #1
0
def test_apply_dimension_temporal_run_udf_legacy_client(api):
    api.check_result(
        "apply_dimension_temporal_run_udf.json",
        preprocess=preprocess_check_and_replace('"dimension": "t"', '"dimension": "temporal"')
    )
    assert api.collections["S2_FAPAR_CLOUDCOVER"].apply_tiles_spatiotemporal.call_count == 1
    assert api.collections["S2_FAPAR_CLOUDCOVER"].apply_dimension.call_count == 1
コード例 #2
0
def test_execute_apply_unary_invalid_from_parameter(api100):
    pg = api100.load_json(
        "apply_unary.json",
        preprocess=preprocess_check_and_replace('"from_parameter": "x"', '"from_parameter": "1nv8l16"')
    )
    resp = api100.post("/result", json=api100.get_process_graph_dict(pg))
    resp.assert_error(400, "ProcessParameterMissing")
コード例 #3
0
def test_reduce_max_invalid_dimension(api):
    pg = api.load_json("reduce_max.json", preprocess=preprocess_check_and_replace("PLACEHOLDER", "orbit"))
    res = api.post("/result", json=api.get_process_graph_dict(pg))
    res.assert_error(
        400, 'ProcessArgumentInvalid',
        message="The argument 'dimension' in process '{p}' is invalid: got 'orbit', but should be one of ['x', 'y', 't', 'bands']".format(
            p="reduce_dimension" if api.api_version_compare.at_least("1.0.0") else "reduce"
        )
    )
コード例 #4
0
def test_aggregate_temporal_max_invalid_temporal_dimension(api):
    pg = api.load_json(
        "aggregate_temporal_max.json",
        preprocess=preprocess_check_and_replace('"dimension": "t"', '"dimension": "detijd"')
    )
    resp = api.post(path="/result", json=api.get_process_graph_dict(pg))
    resp.assert_error(
        400, 'ProcessArgumentInvalid',
        message="The argument 'dimension' in process 'aggregate_temporal' is invalid: got 'detijd', but should be one of ['x', 'y', 't']"
    )
コード例 #5
0
def test_reduce_bands_legacy_client(api):
    api.check_result(
        "reduce_bands.json",
        preprocess=preprocess_check_and_replace('"dimension": "bands"', '"dimension": "spectral_bands"')
    )
    reduce_bands = dummy_backend.collections["S2_FOOBAR"].reduce_bands
    reduce_bands.assert_called_once()
    visitor = reduce_bands.call_args_list[0][0][0]
    assert isinstance(visitor, dummy_backend.DummyVisitor)
    assert set(p[0] for p in visitor.processes) == {"sum", "subtract", "divide"}
コード例 #6
0
def test_apply_dimension_temporal_run_udf_invalid_temporal_dimension(api):
    pg = api.load_json(
        "apply_dimension_temporal_run_udf.json",
        preprocess=preprocess_check_and_replace('"dimension": "t"', '"dimension": "letemps"')
    )
    resp = api.post("/result", json=api.get_process_graph_dict(pg))
    resp.assert_error(
        400, 'ProcessArgumentInvalid',
        message="The argument 'dimension' in process 'apply_dimension' is invalid: got 'letemps', but should be one of ['x', 'y', 't']"
    )
コード例 #7
0
def test_reduce_bands_invalid_dimension(api):
    pg = api.load_json(
        "reduce_bands.json",
        preprocess=preprocess_check_and_replace('"dimension": "bands"', '"dimension": "layor"')
    )
    res = api.post("/result", json=api.get_process_graph_dict(pg))
    res.assert_error(
        400, "ProcessArgumentInvalid",
        message="The argument 'dimension' in process '{p}' is invalid: got 'layor', but should be one of ['x', 'y', 't', 'bands']".format(
            p="reduce_dimension" if api.api_version_compare.at_least("1.0.0") else "reduce"
        )
    )
コード例 #8
0
def test_preprocess_check_and_replace():
    preprocess = preprocess_check_and_replace("foo", "bar")
    assert preprocess("foobar") == "barbar"
    assert preprocess("foobarfoobar") == "barbarbarbar"
    with pytest.raises(AssertionError):
        preprocess("bazbar")
コード例 #9
0
def test_fuzzy_mask_parent_scope(api100):
    api100.check_result(
        "fuzzy_mask.json",
        preprocess=preprocess_check_and_replace('"from_parameter": "x"', '"from_parameter": "data"')
    )
コード例 #10
0
def test_aggregate_temporal_max_legacy_client(api):
    api.check_result(
        "aggregate_temporal_max.json",
        preprocess=preprocess_check_and_replace('"dimension": "t"', '"dimension": "temporal"')
    )
コード例 #11
0
def test_reduce_max_bands(api):
    api.check_result("reduce_max.json", preprocess=preprocess_check_and_replace("PLACEHOLDER", "bands"))
    # Legacy client style
    api.check_result("reduce_max.json", preprocess=preprocess_check_and_replace("PLACEHOLDER", "spectral_bands"))
コード例 #12
0
def test_reduce_max_xy(api):
    api.check_result("reduce_max.json", preprocess=preprocess_check_and_replace("PLACEHOLDER", "x"))
    api.check_result("reduce_max.json", preprocess=preprocess_check_and_replace("PLACEHOLDER", "y"))
コード例 #13
0
def test_reduce_bands_run_udf_legacy_client(api):
    api.check_result(
        "reduce_bands_run_udf.json",
        preprocess=preprocess_check_and_replace('"dimension": "bands"', '"dimension": "spectral_bands"')
    )
    assert api.collections["S2_FOOBAR"].apply_tiles.call_count == 1
コード例 #14
0
def test_execute_apply_unary_parent_scope(api100):
    api100.check_result(
        "apply_unary.json",
        preprocess=preprocess_check_and_replace('"from_parameter": "x"', '"from_parameter": "data"')
    )