Skip to content

Commit

Permalink
[Fixes #4025] Regression with uploading a shapefile with no ascii cha…
Browse files Browse the repository at this point in the history
…racters
  • Loading branch information
afabiani committed Oct 29, 2018
1 parent ac64c41 commit bd3bba5
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 5 deletions.
Binary file added geonode/tests/data/ming_female_1.zip
Binary file not shown.
1 change: 1 addition & 0 deletions geonode/tests/data/ming_female_1/ming_female_1.cst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
1 change: 1 addition & 0 deletions geonode/tests/data/ming_female_1/ming_female_1.prj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["Xian 1980", DATUM["Xian 1980", SPHEROID["IAG 1975", 6378140.0, 298.257, AUTHORITY["EPSG","7049"]], AUTHORITY["EPSG","6610"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4610"]]
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions geonode/tests/data/ming_female_1/wfsrequest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://amap.zju.edu.cn:8080/geoserver/wfs?access_token=vKa0jUDKSIJVS8mxn3QbeXlNKbxFlO?format_options=charset%3AUTF-8&typename=geonode%3Aming_female_1&outputFormat=SHAPE-ZIP&version=1.0.0&service=WFS&request=GetFeature&access_token=vKa0jUDKSIJVS8mxn3QbeXlNKbxFlO
Binary file added geonode/tests/data/zhejiang_yangcan_yanyu.zip
Binary file not shown.
1 change: 1 addition & 0 deletions geonode/tests/data/zhejiang_yangcan_yanyu/wfsrequest.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
http://128.31.22.46:8080/geoserver/wfs?access_token=TCSt2nAzYCZeeSF9jTDULPff6YUWrI?outputFormat=SHAPE-ZIP&service=WFS&srs=EPSG%3A4610&request=GetFeature&format_options=charset%3AUTF-8&typename=geonode%3Azhejiang_yangcan_yanyu&version=1.0.0&access_token=TCSt2nAzYCZeeSF9jTDULPff6YUWrI
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
UTF-8
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GEOGCS["Xian 1980", DATUM["Xian 1980", SPHEROID["IAG 1975", 6378140.0, 298.257, AUTHORITY["EPSG","7049"]], AUTHORITY["EPSG","6610"]], PRIMEM["Greenwich", 0.0, AUTHORITY["EPSG","8901"]], UNIT["degree", 0.017453292519943295], AXIS["Geodetic longitude", EAST], AXIS["Geodetic latitude", NORTH], AUTHORITY["EPSG","4610"]]
Binary file not shown.
Binary file not shown.
56 changes: 51 additions & 5 deletions geonode/tests/integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,57 @@ def test_layer_zip_upload_metadata(self):
uploaded.metadata_xml = thelayer_metadata
regions_resolved, regions_unresolved = resolve_regions(regions)
self.assertIsNotNone(regions_resolved)
# except:
# # Sometimes failes with the message:
# # UploadError: Could not save the layer air_runways,
# # there was an upload error: Error occured unzipping file
# pass
finally:
# Clean up and completely delete the layer
if uploaded:
uploaded.delete()

@on_ogc_backend(geoserver.BACKEND_PACKAGE)
@timeout_decorator.timeout(LOCAL_TIMEOUT)
def test_layer_zip_upload_non_utf8(self):
"""Test uploading a layer with non UTF-8 attributes names"""
uploaded = None
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
thelayer_path = os.path.join(
PROJECT_ROOT,
'data/zhejiang_yangcan_yanyu')
thelayer_zip = os.path.join(
PROJECT_ROOT,
'data/',
'zhejiang_yangcan_yanyu.zip')
try:
if os.path.exists(thelayer_zip):
os.remove(thelayer_zip)
if os.path.exists(thelayer_path) and not os.path.exists(thelayer_zip):
zip_dir(thelayer_path, thelayer_zip)
if os.path.exists(thelayer_zip):
uploaded = file_upload(thelayer_zip, overwrite=True)
self.assertEquals(uploaded.title, 'Zhejiang Yangcan Yanyu')
self.assertEquals(len(uploaded.keyword_list()), 0)
self.assertEquals(uploaded.constraints_other, None)
finally:
# Clean up and completely delete the layer
if uploaded:
uploaded.delete()

uploaded = None
thelayer_path = os.path.join(
PROJECT_ROOT,
'data/ming_female_1')
thelayer_zip = os.path.join(
PROJECT_ROOT,
'data/',
'ming_female_1.zip')
try:
if os.path.exists(thelayer_zip):
os.remove(thelayer_zip)
if os.path.exists(thelayer_path) and not os.path.exists(thelayer_zip):
zip_dir(thelayer_path, thelayer_zip)
if os.path.exists(thelayer_zip):
uploaded = file_upload(thelayer_zip, overwrite=True)
self.assertEquals(uploaded.title, 'Ming Female 1')
self.assertEquals(len(uploaded.keyword_list()), 0)
self.assertEquals(uploaded.constraints_other, None)
finally:
# Clean up and completely delete the layer
if uploaded:
Expand Down

0 comments on commit bd3bba5

Please sign in to comment.