diff options
| author | Arnaldo Govenem <arnaldo.govene@outlook.com> | 2025-01-22 22:54:02 +0200 |
|---|---|---|
| committer | Sarah Boyce <42296566+sarahboyce@users.noreply.github.com> | 2025-02-04 07:40:02 +0000 |
| commit | 8ff1399f0656b4ff8181fe7872e426c331d1b1ee (patch) | |
| tree | 69cf7a4649522fdb9a4f07c97502ef594c9a3346 /tests/gis_tests/test_spatialrefsys.py | |
| parent | 5f30fd2358fd60a514bdba31594bfc8122f30167 (diff) | |
Fixed #36058 -- Refactored SpatialRefSysMixin.srs to use cached_property.
Replaced manual caching complexity with cached_property for efficiency.
Enhanced error handling with distinct messages for WKT and PROJ.4.
Thanks to Sarah Boyce for the suggestions.
Diffstat (limited to 'tests/gis_tests/test_spatialrefsys.py')
| -rw-r--r-- | tests/gis_tests/test_spatialrefsys.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/gis_tests/test_spatialrefsys.py b/tests/gis_tests/test_spatialrefsys.py index 512fd217c3..b87dcf8b92 100644 --- a/tests/gis_tests/test_spatialrefsys.py +++ b/tests/gis_tests/test_spatialrefsys.py @@ -1,5 +1,6 @@ import re +from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.db import connection from django.test import TestCase, skipUnlessDBFeature from django.utils.functional import cached_property @@ -147,3 +148,17 @@ class SpatialRefSysTest(TestCase): self.assertTrue( self.SpatialRefSys.get_spheroid(srs.wkt).startswith("SPHEROID[") ) + + def test_srs_with_invalid_wkt_and_proj4(self): + class MockSpatialRefSys(SpatialRefSysMixin): + def __init__(self, wkt=None, proj4text=None): + self.wkt = wkt + self.proj4text = proj4text + + with self.assertRaisesMessage( + Exception, + "Could not get OSR SpatialReference.\n" + "Error for WKT 'INVALID_WKT': Corrupt data.\n" + "Error for PROJ.4 '+proj=invalid': Corrupt data.", + ): + MockSpatialRefSys(wkt="INVALID_WKT", proj4text="+proj=invalid").srs |
