summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMatthew Somerville <matthew-github@dracos.co.uk>2016-08-22 12:59:25 +0100
committerTim Graham <timograham@gmail.com>2016-08-23 17:30:11 -0400
commitfb951fb0c58e80dc6156a77fb0498272d5e77a66 (patch)
tree3b30ee4e1460e13d59a3d477d337f19819049095 /tests
parent48c34f3336cbbc906066636a7aa35270a7b44895 (diff)
Fixed #27103 -- Registered vcapi/rcapi GDAL prototypes based on their own drivers.
Diffstat (limited to 'tests')
-rw-r--r--tests/gis_tests/gdal_tests/test_driver.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/gis_tests/gdal_tests/test_driver.py b/tests/gis_tests/gdal_tests/test_driver.py
index 1efefcf131..74d6019db6 100644
--- a/tests/gis_tests/gdal_tests/test_driver.py
+++ b/tests/gis_tests/gdal_tests/test_driver.py
@@ -1,6 +1,7 @@
import unittest
from django.contrib.gis.gdal import HAS_GDAL
+from django.test import mock
if HAS_GDAL:
from django.contrib.gis.gdal import Driver, GDALException
@@ -48,3 +49,32 @@ class DriverTest(unittest.TestCase):
for alias, full_name in aliases.items():
dr = Driver(alias)
self.assertEqual(full_name, str(dr))
+
+ @mock.patch('django.contrib.gis.gdal.driver.vcapi.get_driver_count')
+ @mock.patch('django.contrib.gis.gdal.driver.rcapi.get_driver_count')
+ @mock.patch('django.contrib.gis.gdal.driver.vcapi.register_all')
+ @mock.patch('django.contrib.gis.gdal.driver.rcapi.register_all')
+ def test_registered(self, rreg, vreg, rcount, vcount):
+ """
+ Prototypes are registered only if their respective driver counts are
+ zero.
+ """
+ def check(rcount_val, vcount_val):
+ vreg.reset_mock()
+ rreg.reset_mock()
+ rcount.return_value = rcount_val
+ vcount.return_value = vcount_val
+ Driver.ensure_registered()
+ if rcount_val:
+ self.assertFalse(rreg.called)
+ else:
+ rreg.assert_called_once_with()
+ if vcount_val:
+ self.assertFalse(vreg.called)
+ else:
+ vreg.assert_called_once_with()
+
+ check(0, 0)
+ check(120, 0)
+ check(0, 120)
+ check(120, 120)