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]
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 == {}
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 } } }])
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"
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)
def get_settings(): import yaml with open(config_file) as stream: data = yaml.safe_load(stream) return config.Settings(**data)
def override_settings(data): settings = config.Settings(**data) main.app.dependency_overrides[config.get_settings] = lambda: settings