'Testing the `unique`, and `transform`, geometry collection conversion, and ForeignKey mappings.'

def test_layermap_unique_multigeometry_fk(self):

    lm = LayerMapping(County, co_shp, co_mapping, transform=False)
    lm = LayerMapping(County, co_shp, co_mapping, source_srs=4269)
    lm = LayerMapping(County, co_shp, co_mapping, source_srs='NAD83')
    for arg in ('name', ('name', 'mpoly')):
        lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg)
    for (e, arg) in ((TypeError, 5.0), (ValueError, 'foobar'), (ValueError, ('name', 'mpolygon'))):
        with self.assertRaises(e):
            LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg)
    if connection.features.supports_transform:
        with self.assertRaises(LayerMapError):
            LayerMapping(County, co_shp, co_mapping)
    bad_fk_map1 = copy(co_mapping)
    bad_fk_map1['state'] = 'name'
    bad_fk_map2 = copy(co_mapping)
    bad_fk_map2['state'] = {'nombre': 'State'}
    with self.assertRaises(TypeError):
        LayerMapping(County, co_shp, bad_fk_map1, transform=False)
    with self.assertRaises(LayerMapError):
        LayerMapping(County, co_shp, bad_fk_map2, transform=False)
    lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')
    with self.assertRaises(MissingForeignKey):
        lm.save(silent=True, strict=True)
    State.objects.bulk_create([State(name='Colorado'), State(name='Hawaii'), State(name='Texas')])
    lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique='name')
    lm.save(silent=True, strict=True)
    lm = LayerMapping(CountyFeat, co_shp, cofeat_mapping, transform=False)
    lm.save(silent=True, strict=True)
    self.county_helper()
