def test_crs_lookup_fail(minimal_global_raw_cfg, minimal_dc): OWSConfig._instance = None cfg = OWSConfig(cfg=minimal_global_raw_cfg) with pytest.raises(ConfigException) as excinfo: crs = cfg.crs("EPSG:111") assert "EPSG:111" in str(excinfo.value) assert "is not published" in str(excinfo.value)
def parse_path(path, parse_only, folders, styles, input_file, output_file): try: raw_cfg = read_config(path) cfg = OWSConfig(refresh=True, cfg=raw_cfg) if not parse_only: with Datacube() as dc: cfg.make_ready(dc) except ConfigException as e: print("Config exception for path", str(e)) return False print("Configuration parsed OK") if folders: print() print("Folder/Layer Hierarchy") print("======================") print_layers(cfg.layers, styles, depth=0) print() elif styles: print() print("Layers and Styles") print("=================") for lyr in cfg.product_index.values(): print(lyr.name, f"[{','.join(lyr.product_names)}]") print_styles(lyr) print() if input_file or output_file: layers_report(cfg.product_index, input_file, output_file) return True
def test_wcs_only(minimal_global_raw_cfg, wcs_global_cfg, minimal_dc): OWSConfig._instance = None minimal_global_raw_cfg["global"]["services"] = { "wcs": True, "wms": False, "wmts": False, } minimal_global_raw_cfg["wcs"] = wcs_global_cfg cfg = OWSConfig(cfg=minimal_global_raw_cfg) cfg.make_ready(minimal_dc) assert cfg.ready assert cfg.wcs assert not cfg.wms assert not cfg.wmts
def test_bad_crs_alias(minimal_global_raw_cfg): OWSConfig._instance = None minimal_global_raw_cfg["global"]["published_CRSs"]["EPSG:7777"] = { "alias": "EPSG:6666", } cfg = OWSConfig(cfg=minimal_global_raw_cfg) assert "EPSG:7777" not in cfg.published_CRSs
def test_no_wcs_formats(minimal_global_raw_cfg): OWSConfig._instance = None minimal_global_raw_cfg["global"]["services"] = {"wcs": True} minimal_global_raw_cfg["wcs"] = {"formats": {}} with pytest.raises(ConfigException) as excinfo: cfg = OWSConfig(cfg=minimal_global_raw_cfg) assert "Must configure at least one wcs format" in str(excinfo.value)
def test_no_wcs(minimal_global_raw_cfg): OWSConfig._instance = None minimal_global_raw_cfg["global"]["services"] = {"wcs": True} with pytest.raises(ConfigException) as excinfo: cfg = OWSConfig(cfg=minimal_global_raw_cfg) assert "WCS section missing" in str(excinfo.value) assert "WCS is enabled" in str(excinfo.value)
def test_global_no_title(minimal_global_raw_cfg): OWSConfig._instance = None del minimal_global_raw_cfg["global"]["title"] with pytest.raises(ConfigException) as excinfo: cfg = OWSConfig(cfg=minimal_global_raw_cfg) assert "title" in str(excinfo.value) assert "Missing required config entry" in str(excinfo.value) assert "global" in str(excinfo.value)
def test_no_services(minimal_global_raw_cfg): OWSConfig._instance = None minimal_global_raw_cfg["global"]["services"] = { "wms": False, "wmts": False, } with pytest.raises(ConfigException) as excinfo: cfg = OWSConfig(cfg=minimal_global_raw_cfg) assert "At least one service must be active" in str(excinfo.value)
def test_bad_wcs_format(minimal_global_raw_cfg, wcs_global_cfg): OWSConfig._instance = None minimal_global_raw_cfg["global"]["services"] = {"wcs": True} minimal_global_raw_cfg["wcs"] = wcs_global_cfg minimal_global_raw_cfg["wcs"]["native_format"] = "jpeg2000" with pytest.raises(ConfigException) as excinfo: cfg = OWSConfig(cfg=minimal_global_raw_cfg) assert "Configured native WCS format" in str(excinfo.value) assert "jpeg2000" in str(excinfo.value) assert "not a supported format" in str(excinfo.value)
def layer_crs_nongeom(): product_layer = OWSProductLayer.__new__(OWSProductLayer) product_layer.name = "test_layer" product_layer.global_cfg = OWSConfig.__new__(OWSConfig) product_layer.global_cfg.published_CRSs = { "EPSG:3857": { # Web Mercator "geographic": False, "horizontal_coord": "x", "vertical_coord": "y", "vertical_coord_first": False, "gml_name": "http://www.opengis.net/def/crs/EPSG/0/3857", "alias_of": None, }, "EPSG:4326": { # WGS-84 "geographic": True, "vertical_coord_first": True, "horizontal_coord": "longitude", "vertical_coord": "latitude", "gml_name": "http://www.opengis.net/def/crs/EPSG/0/4326", "alias_of": None, }, "EPSG:3577": { "geographic": False, "horizontal_coord": "x", "vertical_coord": "y", "vertical_coord_first": False, "gml_name": "http://www.opengis.net/def/crs/EPSG/0/3577", "alias_of": None, }, "TEST:CRS": { "geographic": False, "horizontal_coord": "horrible_zonts", "vertical_coord": "vertex_calories", "vertical_coord_first": False, "gml_name": "TEST/CRS", "alias_of": None, }, "TEST:NATIVE_CRS": { "geographic": False, "horizontal_coord": "hortizonal_cults", "vertical_coord": "verbal_tics", "vertical_coord_first": False, "gml_name": "TEST/NATIVE_CRS", "alias_of": None, }, } product_layer.global_cfg.internal_CRSs = product_layer.global_cfg.published_CRSs product_layer.native_CRS = "TEST:NATIVE_CRS" product_layer.native_CRS_def = \ product_layer.global_cfg.published_CRSs[ product_layer.native_CRS ] return product_layer
def test_bad_geographic_crs(minimal_global_raw_cfg): OWSConfig._instance = None minimal_global_raw_cfg["global"]["published_CRSs"]["EPSG:7777"] = { "geographic": True, "horizontal_coord": "x" } with pytest.raises(ConfigException) as excinfo: cfg = OWSConfig(cfg=minimal_global_raw_cfg) assert "is geographic" in str(excinfo.value) assert "EPSG:7777" in str(excinfo.value) assert "horizontal" in str(excinfo.value) assert "longitude" in str(excinfo.value) OWSConfig._instance = None minimal_global_raw_cfg["global"]["published_CRSs"]["EPSG:7777"] = { "geographic": True, "vertical_coord": "y" } with pytest.raises(ConfigException) as excinfo: cfg = OWSConfig(cfg=minimal_global_raw_cfg) assert "is geographic" in str(excinfo.value) assert "EPSG:7777" in str(excinfo.value) assert "latitude" in str(excinfo.value) assert "vertical" in str(excinfo.value)
def test_wcs_no_native_format(minimal_global_raw_cfg, wcs_global_cfg): OWSConfig._instance = None minimal_global_raw_cfg["global"]["services"] = { "wcs": True, "wms": False, "wmts": False, } del wcs_global_cfg["native_format"] minimal_global_raw_cfg["wcs"] = wcs_global_cfg with pytest.raises(ConfigException) as excinfo: cfg = OWSConfig(cfg=minimal_global_raw_cfg) assert "native_format" in str(excinfo.value) assert "Missing required config entry" in str(excinfo.value) assert "wcs" in str(excinfo.value)
def test_minimal_global(minimal_global_raw_cfg, minimal_dc): OWSConfig._instance = None cfg = OWSConfig(cfg=minimal_global_raw_cfg) cfg.make_ready(minimal_dc) assert cfg.ready
def layer_crs_geom(): product_layer = OWSProductLayer.__new__(OWSProductLayer) product_layer.name = "test_layer" product_layer.global_cfg = OWSConfig.__new__(OWSConfig) product_layer.global_cfg.published_CRSs = { "EPSG:3857": { # Web Mercator "geographic": False, "horizontal_coord": "x", "vertical_coord": "y", "vertical_coord_first": False, "gml_name": "http://www.opengis.net/def/crs/EPSG/0/3857", "alias_of": False }, "EPSG:4326": { # WGS-84 "geographic": True, "vertical_coord_first": True, "horizontal_coord": "longitude", "vertical_coord": "latitude", "gml_name": "http://www.opengis.net/def/crs/EPSG/0/4326", "alias_of": False }, "EPSG:3577": { "geographic": False, "horizontal_coord": "x", "vertical_coord": "y", "vertical_coord_first": False, "gml_name": "http://www.opengis.net/def/crs/EPSG/0/3577", "alias_of": False }, } product_layer.global_cfg.internal_CRSs = product_layer.global_cfg.published_CRSs product_layer.native_CRS = "EPSG:3577" product_layer.native_CRS_def = \ product_layer.global_cfg.published_CRSs[ product_layer.native_CRS ] product_layer.grids = { 'EPSG:3857': { 'origin': (12324052.573696733, -5742240.963567746), 'resolution': (24.631092099500425, -27.828535092231032) }, 'EPSG:4326': { 'origin': (-8.95553593506657, 157.105656164263), 'resolution': (-0.00017552732376162043, 0.0002723248887547909) }, 'EPSG:3577': { 'origin': (-2407984.8524648934, -5195512.771063174), 'resolution': (25, -25) }, } times = [datetime.date(2013, 1, 1), datetime.date(2014, 1, 1), datetime.date(2015, 1, 1), datetime.date(2016, 1, 1), datetime.date(2017, 1, 1), datetime.date(2018, 1, 1)] product_layer.dynamic = False product_layer._ranges = { 'lat': { 'min': -34.5250413940276, 'max': -33.772472435988 }, 'lon': { 'min': 150.330509919584, 'max': 151.258021405841 }, 'times': times, 'start_time': datetime.date(2013, 1, 1), 'end_time': datetime.date(2018, 1, 1), 'time_set': set(times), 'bboxes': { 'EPSG:3111': { 'top': 5725844.213533809, 'left': -1623290.9363678931, 'right': 3983581.449863785, 'bottom': 1042109.9920098772 }, 'EPSG:3577': { 'top': -936185.3115191332, 'left': -2407984.8524648934, 'right': 2834259.110253384, 'bottom': -5195512.771063174 }, 'EPSG:3857': { 'top': -1001009.9542990683, 'left': 12324052.573696733, 'right': 17488921.644948877, 'bottom': -5742240.963567746 }, 'EPSG:4326': { 'top': -8.95553593506657, 'left': 110.708847892443, 'right': 157.105656164263, 'bottom': -45.761684927317 } } } return product_layer