1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #34411 -- Updated GDAL API to handle vector DataSource's.

Co-authored-by: David Smith <smithdc@gmail.com>
This commit is contained in:
Claude Paroz
2023-03-13 18:38:23 +01:00
committed by Mariusz Felisiak
parent 77278929c8
commit 08306bad57
5 changed files with 58 additions and 76 deletions

View File

@@ -54,32 +54,21 @@ class DriverTest(unittest.TestCase):
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):
@mock.patch("django.contrib.gis.gdal.driver.capi.get_driver_count")
@mock.patch("django.contrib.gis.gdal.driver.capi.register_all")
def test_registered(self, reg, count):
"""
Prototypes are registered only if their respective driver counts are
zero.
Prototypes are registered only if the driver count is zero.
"""
def check(rcount_val, vcount_val):
vreg.reset_mock()
rreg.reset_mock()
rcount.return_value = rcount_val
vcount.return_value = vcount_val
def check(count_val):
reg.reset_mock()
count.return_value = count_val
Driver.ensure_registered()
if rcount_val:
self.assertFalse(rreg.called)
if count_val:
self.assertFalse(reg.called)
else:
rreg.assert_called_once_with()
if vcount_val:
self.assertFalse(vreg.called)
else:
vreg.assert_called_once_with()
reg.assert_called_once_with()
check(0, 0)
check(120, 0)
check(0, 120)
check(120, 120)
check(0)
check(120)