def handle(self, *args, **options): if len(args) == 1: map_id = args[0] fix_baselayers(map_id) else: for map in Map.objects.all(): fix_baselayers(map.id)
def test_fix_baselayers(self): """Test fix_baselayers function, used by the fix_baselayers command """ map_obj = Map.objects.all().first() map_id = map_obj.id if check_ogc_backend(geoserver.BACKEND_PACKAGE): # number of base layers (we remove the local geoserver entry from the total) n_baselayers = len(settings.MAP_BASELAYERS) - 1 # number of local layers n_locallayers = map_obj.layer_set.filter(local=True).count() fix_baselayers(map_id) self.assertEqual(1, n_baselayers + n_locallayers)
def test_fix_baselayers(self): """Test fix_baselayers function, used by the fix_baselayers command """ map_id = 1 map_obj = Map.objects.get(id=map_id) # number of base layers (we remove the local geoserver entry from the total) n_baselayers = len(settings.MAP_BASELAYERS) - 1 # number of local layers n_locallayers = map_obj.layer_set.filter(local=True).count() fix_baselayers(map_id) self.assertEquals(map_obj.layer_set.all().count(), n_baselayers + n_locallayers)
def test_fix_baselayers(self): """Test fix_baselayers function, used by the fix_baselayers command """ map_id = 1 map_obj = Map.objects.get(id=map_id) if check_ogc_backend(geoserver.BACKEND_PACKAGE): # number of base layers (we remove the local geoserver entry from the total) n_baselayers = len(settings.MAP_BASELAYERS) - 1 elif check_ogc_backend(qgis_server.BACKEND_PACKAGE): # QGIS Server backend already excluded local geoserver entry n_baselayers = len(settings.MAP_BASELAYERS) # number of local layers n_locallayers = map_obj.layer_set.filter(local=True).count() fix_baselayers(map_id) self.assertEquals(map_obj.layer_set.all().count(), n_baselayers + n_locallayers)