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

def test_layermap_unique_multigeometry_fk(self):

    try:
        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=u'NAD83')
        for arg in (u'name', (u'name', u'mpoly')):
            lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique=arg)
    except:
        self.fail(u'No    exception    should    be    raised    for    proper    use    of    keywords.')
    for (e, arg) in ((TypeError, 5.0), (ValueError, u'foobar'), (ValueError, (u'name', u'mpolygon'))):
        self.assertRaises(e, LayerMapping, County, co_shp, co_mapping, transform=False, unique=arg)
    if (not mysql):
        self.assertRaises(LayerMapError, LayerMapping, County, co_shp, co_mapping)
    bad_fk_map1 = copy(co_mapping)
    bad_fk_map1[u'state'] = u'name'
    bad_fk_map2 = copy(co_mapping)
    bad_fk_map2[u'state'] = {u'nombre': u'State'}
    self.assertRaises(TypeError, LayerMapping, County, co_shp, bad_fk_map1, transform=False)
    self.assertRaises(LayerMapError, LayerMapping, County, co_shp, bad_fk_map2, transform=False)
    lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique=u'name')
    self.assertRaises(MissingForeignKey, lm.save, silent=True, strict=True)
    State.objects.bulk_create([State(name=u'Colorado'), State(name=u'Hawaii'), State(name=u'Texas')])
    lm = LayerMapping(County, co_shp, co_mapping, transform=False, unique=u'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()
