summaryrefslogtreecommitdiff
path: root/tests/gis_tests/test_checks.py
blob: 4d01711e9486bbec63a08a30077471665baf0aef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from unittest import mock

from django.contrib.gis.checks import check_gdal_39
from django.contrib.gis.gdal import GDAL_VERSION
from django.core.checks import Warning
from django.test import SimpleTestCase


class GISChecksTests(SimpleTestCase):
    def test_gdal_39_warning(self):
        msg = (
            "The installed version of GDAL does not allow blocking file and "
            "network access. Upgrade to GDAL 3.9 or higher to receive "
            "protection against malicious spatial references."
        )
        with mock.patch("django.contrib.gis.checks.GDAL_VERSION", (3, 8, 5)):
            self.assertEqual(
                check_gdal_39(None),
                [Warning(msg, hint=f"Your version: {GDAL_VERSION}", id="gis.W001")],
            )
        with mock.patch("django.contrib.gis.checks.GDAL_VERSION", (3, 9)):
            self.assertEqual(check_gdal_39(None), [])
        with mock.patch("django.contrib.gis.checks.GDAL_VERSION", (3, 9, 1)):
            self.assertEqual(check_gdal_39(None), [])