def test_api_returns_limited_tile_regions(client: FlaskClient):
    """
    Covers most of the 'normal' products: they have a footprint, bounds and a simple crs epsg code.
    """
    geojson = get_geojson(client, '/api/regions/wofs_albers/2017/04')
    assert len(geojson['features']) == 4, "Unexpected wofs albers region month count"
    geojson = get_geojson(client, '/api/regions/wofs_albers/2017/04/20')
    print(json.dumps(geojson, indent=4))
    assert len(geojson['features']) == 1, "Unexpected wofs albers region day count"
    geojson = get_geojson(client, '/api/regions/wofs_albers/2017/04/6')
    assert len(geojson['features']) == 0, "Unexpected wofs albers region count"
Пример #2
0
def get_items(client: FlaskClient, url: str) -> Dict:
    """
    Get a URL, expecting a valid stac item collection document to be there"""
    with DebugContext(f"Requested {repr(url)}"):
        data = get_geojson(client, url)
        assert_item_collection(data)
    return data
Пример #3
0
def test_invalid_footprint_wofs_summary_load(client: FlaskClient):
    # This all-time overview has a valid footprint that becomes invalid
    # when reprojected to wrs84 by shapely.
    from .data_wofs_summary import wofs_time_summary

    _model.STORE._do_put("wofs_summary", None, None, None, wofs_time_summary)
    html = get_html(client, "/wofs_summary")
    check_dataset_count(html, 1244)

    d = get_geojson(client, "/api/regions/wofs_summary")
    assert len(d["features"]) == 1244
def test_api_returns_high_tide_comp_datasets(client: FlaskClient):
    """
    These are slightly fun to handle as they are a small number with a huge time range.
    """
    geojson = get_geojson(client, '/api/datasets/high_tide_comp_20p')
    assert len(geojson['features']) == 306, "Not all high tide datasets returned as geojson"

    # Check that they're not just using the center time.
    # Within the time range, but not the center_time.
    # Range: '2000-01-01T00:00:00' to '2016-10-31T00:00:00'
    # year
    geojson = get_geojson(client, '/api/datasets/high_tide_comp_20p/2000')
    assert len(geojson['features']) == 306, "Expected high tide datasets within whole dataset range"
    # month
    geojson = get_geojson(client, '/api/datasets/high_tide_comp_20p/2009/5')
    assert len(geojson['features']) == 306, "Expected high tide datasets within whole dataset range"
    # day
    geojson = get_geojson(client, '/api/datasets/high_tide_comp_20p/2016/10/1')
    assert len(geojson['features']) == 306, "Expected high tide datasets within whole dataset range"

    # Completely out of the test dataset time range. No results.
    geojson = get_geojson(client, '/api/datasets/high_tide_comp_20p/2018')
    assert len(geojson['features']) == 0, "Expected no high tide datasets in in this year"
def test_api_returns_high_tide_comp_datasets(client: FlaskClient):
    """
    These are slightly fun to handle as they are a small number with a huge time range.
    """
    geojson = get_geojson(client, "/api/datasets/high_tide_comp_20p")
    assert (
        len(geojson["features"]) == 306
    ), "Not all high tide datasets returned as geojson"

    # Search and time summary is only based on center time.
    # These searches are within the dataset time range, but not the center_time.
    # Dataset range: '2000-01-01T00:00:00' to '2016-10-31T00:00:00'
    # year
    geojson = get_geojson(client, "/api/datasets/high_tide_comp_20p/2008")
    assert (
        len(geojson["features"]) == 306
    ), "Expected high tide datasets within whole dataset range"
    # month
    geojson = get_geojson(client, "/api/datasets/high_tide_comp_20p/2008/6")
    assert (
        len(geojson["features"]) == 306
    ), "Expected high tide datasets within whole dataset range"
    # day
    geojson = get_geojson(client, "/api/datasets/high_tide_comp_20p/2008/6/1")
    assert (
        len(geojson["features"]) == 306
    ), "Expected high tide datasets within whole dataset range"

    # Out of the test dataset time range. No results.

    # Completely outside of range
    geojson = get_geojson(client, "/api/datasets/high_tide_comp_20p/2018")
    assert (
        len(geojson["features"]) == 0
    ), "Expected no high tide datasets in in this year"
    # One day before/after (is time zone handling correct?)
    geojson = get_geojson(client, "/api/datasets/high_tide_comp_20p/2008/6/2")
    assert len(geojson["features"]) == 0, "Expected no result one-day-after center time"
    geojson = get_geojson(client, "/api/datasets/high_tide_comp_20p/2008/5/31")
    assert len(geojson["features"]) == 0, "Expected no result one-day-after center time"
Пример #6
0
def test_api_returns_tiles_regions(client: FlaskClient):
    """
    Covers most of the 'normal' products: they have a footprint, bounds and a simple crs epsg code.
    """
    geojson = get_geojson(client, "/api/regions/ls7_nbart_albers")
    assert len(geojson["features"]) == 4, "Unexpected albers region count"
Пример #7
0
def test_api_returns_scene_regions(client: FlaskClient):
    """
    L1 scenes have no footprint, falls back to bounds. Have weird CRSes too.
    """
    geojson = get_geojson(client, "/api/regions/ls8_level1_scene")
    assert len(geojson["features"]) == 7, "Unexpected scene region count"
Пример #8
0
def get_items(client: FlaskClient, url: str) -> Dict:
    with DebugContext(f"Requested {repr(url)}"):
        data = get_geojson(client, url)
        assert_collection(data)
    return data
def test_api_returns_tiles_as_geojson(client: FlaskClient):
    """
    Covers most of the 'normal' products: they have a footprint, bounds and a simple crs epsg code.
    """
    geojson = get_geojson(client, '/api/datasets/ls7_nbart_albers')
    assert len(geojson['features']) == 4, "Unepected albers polygon count"
def test_api_returns_scenes_as_geojson(client: FlaskClient):
    """
    L1 scenes have no footprint, falls back to bounds. Have weird CRSes too.
    """
    geojson = get_geojson(client, '/api/datasets/ls8_level1_scene')
    assert len(geojson['features']) == 7, "Unexpected scene polygon count"