예제 #1
0
def test_tile_endpoint_given_timestamp_in_miliseconds(tmpdir):
    netcdf_path = str(tmpdir / "test-netcdf.nc")

    # Config file
    data = sample_config(netcdf_path)

    # NetCDF file
    sample_h5netcdf(netcdf_path)

    # Time stamp
    # datetime.datetime(2021, 2, 23, 12, 2, 29, 999991)
    stamp_ms = 1614081749999.991

    # System under test
    settings = config.Settings(**data)
    main.app.dependency_overrides[config.get_settings] = lambda: settings
    query = json.dumps({"time": stamp_ms})
    response = client.get(f"/datasets/0/data/tiles/0/0/0?query={query}")
    actual = response.json()

    # Assert response
    assert actual["tile"] == [0, 0, 0]
    assert actual["data"]["x"] == [-20037508.342789244]
    assert actual["data"]["y"] == [-20037508.342789255]
    assert actual["data"]["dw"] == [40075016.68557849]
    assert actual["data"]["dh"] == [40075016.685578495]
예제 #2
0
def test_times_endpoint(tmpdir):
    config_path = str(tmpdir / "test-config.yaml")

    # Config file
    data = {
        "datasets": [{
            "label": "RDT",
            "driver": {
                "name": "rdt",
                "settings": {}
            }
        }]
    }
    with open(config_path, "w") as stream:
        yaml.dump(data, stream)

    # Patch config
    settings = config.Settings(config_file=config_path)
    main.app.dependency_overrides[config.get_settings] = lambda: settings

    # System under test
    response = client.get("/datasets/RDT/times")

    # Assert response
    actual = response.json()

    assert actual == {}
예제 #3
0
 def fn():
     return config.Settings(datasets=[{
         "label": file_name,
         "palettes": {
             "default": {
                 "name": palette,
                 "number": 256,
                 "reverse": True,
                 "low": 200,
                 "high": 300
             }
         },
         "driver": {
             "name": driver_name,
             "settings": {
                 "pattern": file_name
             }
         }
     }])
예제 #4
0
def test_points_endpoint(tmpdir):
    config_path = str(tmpdir / "test-config.yaml")
    netcdf_path = str(tmpdir / "test-netcdf.nc")

    # Config file
    with open(config_path, "w") as stream:
        yaml.dump(sample_config(netcdf_path), stream)

    # NetCDF file
    sample_h5netcdf(netcdf_path)

    # Patch config
    settings = config.Settings(config_file=config_path)
    main.app.dependency_overrides[config.get_settings] = lambda: settings

    # System under test
    response = client.get("/datasets/0/times/0/points")

    # Assert response
    actual = response.json()
    assert actual["attrs"]["long_name"] == "toa_brightness_temperature"
예제 #5
0
def test_tile_endpoint(tmpdir):
    netcdf_path = str(tmpdir / "test-netcdf.nc")

    # Config file
    data = sample_config(netcdf_path)

    # NetCDF file
    sample_h5netcdf(netcdf_path)

    # System under test
    settings = config.Settings(**data)
    main.app.dependency_overrides[config.get_settings] = lambda: settings
    query = json.dumps({"time": "1970-01-01T00:00:00Z"})
    response = client.get(f"/datasets/0/data/tiles/0/0/0?query={query}")
    actual = response.json()

    # Assert response
    assert actual["tile"] == [0, 0, 0]
    assert actual["data"]["x"] == [-20037508.342789244]
    assert actual["data"]["y"] == [-20037508.342789255]
    assert actual["data"]["dw"] == [40075016.68557849]
    assert actual["data"]["dh"] == [40075016.685578495]
 def fn():
     return config.Settings(**data)
 def wrapper():
     return config.Settings(**data)
예제 #8
0
 def get_settings():
     import yaml
     with open(config_file) as stream:
         data = yaml.safe_load(stream)
     return config.Settings(**data)
예제 #9
0
def override_settings(data):
    settings = config.Settings(**data)
    main.app.dependency_overrides[config.get_settings] = lambda: settings