From 02be106593c84e94658f643623e61ae88a0218e4 Mon Sep 17 00:00:00 2001 From: index-git Date: Mon, 23 Dec 2024 10:35:33 +0100 Subject: [PATCH] Remove deprecated key file.file_type from rest responses --- CHANGELOG.md | 1 + doc/rest.md | 3 --- src/layman/common/rest.py | 3 --- src/layman/layer/util.py | 2 -- src/layman/rest_responses_test.py | 4 ---- src/layman/upgrade/upgrade_v1_17_test.py | 4 ++-- tests/asserts/final/publication/internal_rest.py | 2 -- tests/asserts/final/publication/rest.py | 10 +--------- .../publications/wrong_input/wrong_input_test.py | 2 +- tests/static_data/single_publication/layers_test.py | 1 - 10 files changed, 5 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c0b05980..98c5f549b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ #### Data migrations ### Changes - [#1009](https://github.com/LayerManager/layman/issues/1009) PATCH Workspace [Layer](doc/rest.md#patch-workspace-layer)/[Map](doc/rest.md#patch-workspace-map) returns same response as POST Workspace [Layers](doc/rest.md#post-workspace-layers)/[Maps](doc/rest.md#post-workspace-maps) with only `name`, `uuid`, `url` and for Layer also optional `files_to_upload` keys. +- [#1009](https://github.com/LayerManager/layman/issues/1009) Deprecated key 'file_type' was removed from endpoints GET [Publications](doc/rest.md#get-publications)/[Layers](doc/rest.md#get-layers)/[Workspace Layers](doc/rest.md#get-workspace-layers)/[Workspace Maps](doc/rest.md#get-workspace-maps)/[Maps](doc/rest.md#get-maps)/[Workspace Layer](doc/rest.md#get-workspace-layer)/[Workspace Map](doc/rest.md#get-workspace-map) response. - [#1028](https://github.com/LayerManager/layman/issues/1028) Upgrade Node.js of Laymen Test Client from v18 to v22 and dependencies: - eslint-config-next 13 -> 14 - next 13 -> 14 diff --git a/doc/rest.md b/doc/rest.md index 078a8b788..4ab461d6f 100644 --- a/doc/rest.md +++ b/doc/rest.md @@ -72,8 +72,6 @@ JSON array of objects representing available layers and maps with following stru - **native_crs**: Code of native CRS in form "EPSG:<code>", e.g. "EPSG:4326". - **native_bounding_box**: List of 4 floats and one string. Bounding box coordinates [minx, miny, maxx, maxy] in native CRS. - *geodata_type*: String. Available only for layers. Either `vector`, `raster`, or `unknown`. Value `unknown` is used if input files are zipped and still being uploaded. -- *~~file~~*: **Deprecated**. - - *~~file_type~~*: **Deprecated**. Replaced by **geodata_type** at root level, contains same info. Available only for layers. - *wfs_wms_status*: String. Available only for layers. Status of layer availability in WMS (and WFS in case of vector data) endpoints. Either `AVAILABLE`, `PREPARING`, or `NOT_AVAILABLE`. Headers: @@ -315,7 +313,6 @@ JSON object with following structure: - Replaced by *paths*, which contains list of all data files. - String. Path to input data file. Path is relative to workspace directory. If data file was sent in ZIP archive to the server, path includes also path to the main file inside ZIP file. E.g. `layers/zipped_shapefile/input_file/zipped_shapefile.zip/layer_main_file.shp` - - *~~file_type~~*: **Deprecated**. Replaced by **geodata_type** at root level, contains same info. - *status*: Status information about saving and availability of files. See [GET Workspace Layer](#get-workspace-layer) **wms** property for meaning. - *error*: If status is FAILURE, this may contain error object. - *db*, available only for vector layers diff --git a/src/layman/common/rest.py b/src/layman/common/rest.py index ae02569b9..f50a88961 100644 --- a/src/layman/common/rest.py +++ b/src/layman/common/rest.py @@ -259,9 +259,6 @@ def get_publications(publication_type, actor, request_args=None, workspace=None, 'native_crs': info['native_crs'], 'native_bounding_box': info['native_bounding_box'], 'geodata_type': info['geodata_type'], - 'file': { - 'file_type': info['geodata_type'], - }, 'wfs_wms_status': info['_wfs_wms_status'].value if info['_wfs_wms_status'] else None, } multi_info_keys_to_remove = layman_util.get_multi_info_keys_to_remove(info['type']) diff --git a/src/layman/layer/util.py b/src/layman/layer/util.py index 7e693f6b7..673b4d590 100644 --- a/src/layman/layer/util.py +++ b/src/layman/layer/util.py @@ -114,8 +114,6 @@ def _get_complete_layer_info(workspace, layername, *, x_forwarded_items=None): file_type = complete_info.get('_file', {}).get('file_type') if complete_info['geodata_type'] == settings.GEODATA_TYPE_UNKNOWN and file_type and file_type != settings.GEODATA_TYPE_UNKNOWN: complete_info['geodata_type'] = file_type - if 'file' in complete_info: - complete_info['file']['file_type'] = complete_info['geodata_type'] complete_info = clear_publication_info(complete_info, geodata_type) diff --git a/src/layman/rest_responses_test.py b/src/layman/rest_responses_test.py index 529a54cd3..29dbafb85 100644 --- a/src/layman/rest_responses_test.py +++ b/src/layman/rest_responses_test.py @@ -79,9 +79,6 @@ class TestResponsesClass: 'native_bounding_box': list(test_data.SMALL_LAYER_NATIVE_BBOX), 'url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}/rest/workspaces/{workspace}/layers/{publication}', 'geodata_type': settings.GEODATA_TYPE_VECTOR, - 'file': { - 'file_type': settings.GEODATA_TYPE_VECTOR, - }, 'wfs_wms_status': settings.EnumWfsWmsStatus.AVAILABLE.value, 'publication_type': 'layer', } @@ -116,7 +113,6 @@ class TestResponsesClass: 'geodata_type': 'vector', 'file': {'path': f'layers/{publication}/input_file/{publication}.geojson', 'paths': [f'layers/{publication}/input_file/{publication}.geojson'], - 'file_type': 'vector', }, 'metadata': {'comparison_url': f'http://{settings.LAYMAN_PROXY_SERVER_NAME}/rest/workspaces/{workspace}/layers/{publication}/' f'metadata-comparison', diff --git a/src/layman/upgrade/upgrade_v1_17_test.py b/src/layman/upgrade/upgrade_v1_17_test.py index 8a7b7e758..450bcf2c8 100644 --- a/src/layman/upgrade/upgrade_v1_17_test.py +++ b/src/layman/upgrade/upgrade_v1_17_test.py @@ -83,9 +83,9 @@ def test_file_type(): layer_infos = process_client.get_layers(workspace=main_workspace) assert len(layer_infos) == 2 vector_layer_info = next(info for info in layer_infos if info['name'] == vector_layer_def[2]) - assert vector_layer_info['file']['file_type'] == 'vector' + assert vector_layer_info['geodata_type'] == 'vector' raster_layer_info = next(info for info in layer_infos if info['name'] == raster_layer_def[2]) - assert raster_layer_info['file']['file_type'] == 'raster' + assert raster_layer_info['geodata_type'] == 'raster' map_infos = process_client.get_maps(workspace=main_workspace) assert len(map_infos) == 1 diff --git a/tests/asserts/final/publication/internal_rest.py b/tests/asserts/final/publication/internal_rest.py index 0604d0b5d..b02de2a0b 100644 --- a/tests/asserts/final/publication/internal_rest.py +++ b/tests/asserts/final/publication/internal_rest.py @@ -15,8 +15,6 @@ def same_values_in_internal_and_rest(workspace, publ_type, name, rest_publicatio rest_publication_detail = copy.deepcopy(rest_publication_detail) for key in ('layman_metadata', 'sld', 'url', 'db_table'): rest_publication_detail.pop(key, None) - if 'file' in rest_publication_detail: - rest_publication_detail['file'].pop('file_type', None) if 'image_mosaic' not in rest_publication_detail: publ_info.pop('image_mosaic') diff --git a/tests/asserts/final/publication/rest.py b/tests/asserts/final/publication/rest.py index eb210197c..41d18a019 100644 --- a/tests/asserts/final/publication/rest.py +++ b/tests/asserts/final/publication/rest.py @@ -69,18 +69,10 @@ def same_values_in_detail_and_multi(workspace, publ_type, name, rest_publication expected_keys = ['workspace', 'name', 'title', 'uuid', 'url', 'updated_at', 'access_rights', 'bounding_box', 'native_crs', 'native_bounding_box'] if publ_type == process_client.LAYER_TYPE: - expected_keys += ['geodata_type', 'file'] + expected_keys += ['geodata_type'] rest_detail = copy.deepcopy(rest_publication_detail) exp_info = {k: v for k, v in rest_detail.items() if k in expected_keys} - # adjust deprecated `file` key - if 'file' in exp_info: - exp_info['file'] = {k: v for k, v in exp_info['file'].items() if k == 'file_type'} - elif publ_type == process_client.LAYER_TYPE: - exp_info['file'] = { - 'file_type': exp_info['geodata_type'], - } - # add other expected keys exp_info['workspace'] = workspace if publ_type == process_client.LAYER_TYPE: diff --git a/tests/dynamic_data/publications/wrong_input/wrong_input_test.py b/tests/dynamic_data/publications/wrong_input/wrong_input_test.py index 63db8950e..8b0394585 100644 --- a/tests/dynamic_data/publications/wrong_input/wrong_input_test.py +++ b/tests/dynamic_data/publications/wrong_input/wrong_input_test.py @@ -1570,5 +1570,5 @@ def test_publication(self, publication: Publication, rest_method, rest_args, par name=publication.name, rest_publication_detail=rest_publication_detail, headers=None, - different_value_keys=['file', 'geodata_type'], + different_value_keys=['geodata_type'], ) diff --git a/tests/static_data/single_publication/layers_test.py b/tests/static_data/single_publication/layers_test.py index 2bea82ea7..579183dad 100644 --- a/tests/static_data/single_publication/layers_test.py +++ b/tests/static_data/single_publication/layers_test.py @@ -53,7 +53,6 @@ def test_info(workspace, publ_type, publication): assert info_keys == item_keys, f'info={info}' assert info['wms'].get('url') == wms_url, f'r_json={info}, wms_url={wms_url}' assert 'url' in info['wms'], f'info={info}' - assert info.get('file', {}).get('file_type') == data.PUBLICATIONS[(workspace, publ_type, publication)][data.TEST_DATA].get('geodata_type') if 'wfs' in info: assert info['wfs'].get('url') == wfs_url, f'r_json={info}, wfs_url={wfs_url}'