'Prototypes are registered only if their respective driver counts are
zero.'

@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):

    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)
