'Testing the `strict` keyword, and import of a LineString shapefile.'

def test03_layermap_strict(self):

    try:
        lm = LayerMapping(Interstate, inter_shp, inter_mapping)
        lm.save(silent=True, strict=True)
    except InvalidDecimal:
        if mysql:
            Interstate.objects.all().delete()
    else:
        self.fail('Should    have    failed    on    strict    import    with    invalid    decimal    values.')
    lm = LayerMapping(Interstate, inter_shp, inter_mapping)
    lm.save(silent=True)
    self.assertEqual(2, Interstate.objects.count())
    ds = DataSource(inter_shp)
    valid_feats = ds[0][:2]
    for feat in valid_feats:
        istate = Interstate.objects.get(name=feat['Name'].value)
        if (feat.fid == 0):
            self.assertEqual(Decimal(str(feat['Length'])), istate.length)
        elif (feat.fid == 1):
            self.assertAlmostEqual(feat.get('Length'), float(istate.length), 2)
        for (p1, p2) in zip(feat.geom, istate.path):
            self.assertAlmostEqual(p1[0], p2[0], 6)
            self.assertAlmostEqual(p1[1], p2[1], 6)
