Skip to content

Commit

Permalink
Remove deprecated key file.file_type from rest responses
Browse files Browse the repository at this point in the history
  • Loading branch information
index-git committed Dec 23, 2024
1 parent 5b4c314 commit 02be106
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions doc/rest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions src/layman/common/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down
2 changes: 0 additions & 2 deletions src/layman/layer/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 0 additions & 4 deletions src/layman/rest_responses_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
}
Expand Down Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions src/layman/upgrade/upgrade_v1_17_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions tests/asserts/final/publication/internal_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 1 addition & 9 deletions tests/asserts/final/publication/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
)
1 change: 0 additions & 1 deletion tests/static_data/single_publication/layers_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'

Expand Down

0 comments on commit 02be106

Please sign in to comment.