def test_shapefile_publish(self): """Publishing a shapefile puts the data into the PostGIS table""" res = self.add_shapefile_resource("test-publish") s = Shapefile(res["id"]) self.assertTrue(s.publish()) self.assertEqual(s.get_source_layer().GetFeatureCount(), s.get_destination_layer().GetFeatureCount())
def test_shapefile_get_dest_layer(self): """Check that we can get an OGRLayer in the datastore database""" res = self.add_shapefile_resource("test-get-dest-layer") s = Shapefile(res["id"]) ds = s.get_destination_source() self.assertIsInstance(s.get_destination_layer(ds, s.table_name()), Layer)
def test_shapefile_dest_layer_fields(self): """The destination layer must contain the fields from the source""" res = self.add_shapefile_resource("test-dest-fields") s = Shapefile(res["id"]) shapefile = s.get_source_layer().GetLayerDefn() source_fields = [shapefile.GetFieldDefn(i).GetName().lower() for i in range(shapefile.GetFieldCount())] dest = s.get_destination_layer(s.get_destination_source(), s.get_name()).GetLayerDefn() dest_fields = [dest.GetFieldDefn(i).GetName().lower() for i in range(dest.GetFieldCount())] self.assertEqual(len(set(source_fields).difference(dest_fields)), 0)