summaryrefslogtreecommitdiff
path: root/tests/gis_tests
diff options
context:
space:
mode:
authorJordi Castells <jordi.kstells@gmail.com>2021-04-14 16:07:36 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-05-07 20:03:46 +0200
commit205c36b58fed5a1a0ff462593fc61b58189027d8 (patch)
treef392f7f04fe44189eea6792e5082c1422925c2e9 /tests/gis_tests
parent028f10fac651292edf8d50e013b16a52862e4c08 (diff)
downloaddjango-205c36b58fed5a1a0ff462593fc61b58189027d8.tar.gz
Fixed #32670 -- Allowed GDALRasters to use any GDAL virtual filesystem.
Diffstat (limited to 'tests/gis_tests')
-rw-r--r--tests/gis_tests/gdal_tests/test_raster.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/gis_tests/gdal_tests/test_raster.py b/tests/gis_tests/gdal_tests/test_raster.py
index 6858abc4d8..229f09eaf4 100644
--- a/tests/gis_tests/gdal_tests/test_raster.py
+++ b/tests/gis_tests/gdal_tests/test_raster.py
@@ -2,6 +2,7 @@ import os
import shutil
import struct
import tempfile
+import zipfile
from unittest import mock
from django.contrib.gis.gdal import GDALRaster, SpatialReference
@@ -229,6 +230,17 @@ class GDALRasterTests(SimpleTestCase):
# The vsi buffer is None for rasters that are not vsi based.
self.assertIsNone(self.rs.vsi_buffer)
+ def test_vsi_vsizip_filesystem(self):
+ rst_zipfile = tempfile.NamedTemporaryFile(suffix='.zip')
+ with zipfile.ZipFile(rst_zipfile, mode='w') as zf:
+ zf.write(self.rs_path, 'raster.tif')
+ rst_path = '/vsizip/' + os.path.join(rst_zipfile.name, 'raster.tif')
+ rst = GDALRaster(rst_path)
+ self.assertEqual(rst.driver.name, self.rs.driver.name)
+ self.assertEqual(rst.name, rst_path)
+ self.assertIs(rst.is_vsi_based, True)
+ self.assertIsNone(rst.vsi_buffer)
+
def test_offset_size_and_shape_on_raster_creation(self):
rast = GDALRaster({
'datatype': 1,