Skip to content

Commit 527f97a

Browse files
mattiagiupponiMalteIwanicki
authored andcommitted
[Fixes GeoNode#10113] Data retriver keep kmz files even if is unzipped (GeoNode#10114)
* [Fixes GeoNode#10113] Data retriever keeps kmz files even if are unzipped
1 parent bf89577 commit 527f97a

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

geonode/storage/data_retriever.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ def _unzip(self, zip_name: str) -> Mapping:
202202
the_zip = zipfile.ZipFile(zip_file, allowZip64=True)
203203
the_zip.extractall(self.temporary_folder)
204204
available_choices = get_allowed_extensions()
205-
not_main_files = ['xml', 'sld', 'zip']
205+
not_main_files = ['xml', 'sld', 'zip', 'kmz']
206206
base_file_choices = [x for x in available_choices if x not in not_main_files]
207207
for _file in Path(self.temporary_folder).iterdir():
208208
if any([_file.name.endswith(_ext) for _ext in base_file_choices]):

geonode/storage/tests.py

+21
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import io
2020
import os
2121
import shutil
22+
from django.test import override_settings
2223
import gisdata
2324
from unittest.mock import patch
2425

@@ -584,6 +585,26 @@ def test_zip_file_should_correctly_recognize_main_extension_with_csv(self):
584585
_files = storage_manager.get_retrieved_paths()
585586
self.assertTrue("example.csv" in _files.get("base_file"))
586587

588+
@override_settings(SUPPORTED_DATASET_FILE_TYPES=[{
589+
"id": "kmz",
590+
"label": "kmz",
591+
"format": "vector",
592+
"ext": ["kmz"]
593+
}, {
594+
"id": "kml",
595+
"label": "kml",
596+
"format": "vector",
597+
"ext": ["kml"]
598+
}])
599+
def test_zip_file_should_correctly_recognize_main_extension_with_kmz(self):
600+
# reinitiate the storage manager with the zip file
601+
storage_manager = self.sut(remote_files={"base_file": os.path.join(f"{self.project_root}", "tests/data/Italy.kmz")})
602+
storage_manager.clone_remote_files()
603+
604+
self.assertIsNotNone(storage_manager.data_retriever.temporary_folder)
605+
_files = storage_manager.get_retrieved_paths()
606+
self.assertTrue("doc.kml" in _files.get("base_file"), msg=f"files available: {_files}")
607+
587608
def test_zip_file_should_correctly_recognize_main_extension_with_shp(self):
588609
# zipping files
589610
storage_manager = self.sut(remote_files=self.local_files_paths)

geonode/storage/tests/data/Italy.kmz

19.9 KB
Binary file not shown.

0 commit comments

Comments
 (0)