Exemplo n.º 1
0
class OGRGeometryFieldTestCase(SimpleTestCase):
    def setUp(self):
        self.field = OGRGeometryField()

    def test_feature(self):
        feature = Feature(geometry=_geom)
        geojson = str(feature)
        geom = self.field.to_python(geojson)
        self.assertEqual(json.loads(geom.geojson), feature['geometry'])

    def test_extent(self):
        ex = (0, 0, 10, 10)
        geom = self.field.to_python(','.join(map(str, ex)))
        self.assertEqual(geom.extent, ex)

    def test_invalid(self):
        self.assertRaises(forms.ValidationError, self.field.to_python, '3')
Exemplo n.º 2
0
class OGRGeometryFieldTestCase(SimpleTestCase):
    def setUp(self):
        self.field = OGRGeometryField()

    def test_dict(self):
        geom = self.field.to_python(_geom)
        self.assertEqual(json.loads(geom.geojson), _geom)

    def test_extent(self):
        ex = (0, 0, 10, 10)
        geom = self.field.to_python(','.join(map(str, ex)))
        self.assertEqual(geom.extent, ex)

    def test_feature(self):
        feature = Feature(geometry=_geom)
        geojson = str(feature)
        geom = self.field.to_python(geojson)
        self.assertEqual(json.loads(geom.geojson), feature['geometry'])
        geom = self.field.to_python(feature)
        self.assertEqual(json.loads(geom.geojson), feature['geometry'])

    def test_feature_srid(self):
        srid = 3857
        feature = Feature(geometry=_geom, crs=NamedCRS(srid))
        geom = self.field.to_python(str(feature))
        self.assertEqual(geom.srid, srid)

    def test_invalid(self):
        self.assertRaises(forms.ValidationError, self.field.to_python, '3')

    def test_size_validator(self):
        validator = GeometrySizeValidator(3**2, 4326)
        field = OGRGeometryField(srid=validator.srid, validators=[validator])
        self.assertRaises(forms.ValidationError, field.clean, '0,0,5,5')

    def test_srid(self):
        srid = 4269
        geom = OGRGeometryField(srid=srid).to_python('POINT(0 0)')
        self.assertEqual(geom.srid, srid)
Exemplo n.º 3
0
class OGRGeometryFieldTestCase(SimpleTestCase):
    def setUp(self):
        self.field = OGRGeometryField()

    def test_dict(self):
        geom = self.field.to_python(_geom)
        self.assertEqual(json.loads(geom.geojson), _geom)

    def test_extent(self):
        ex = (0, 0, 10, 10)
        geom = self.field.to_python(','.join(map(str, ex)))
        self.assertEqual(geom.extent, ex)

    def test_feature(self):
        feature = Feature(geometry=_geom)
        geojson = str(feature)
        geom = self.field.to_python(geojson)
        self.assertEqual(json.loads(geom.geojson), feature['geometry'])
        geom = self.field.to_python(feature)
        self.assertEqual(json.loads(geom.geojson), feature['geometry'])

    def test_feature_srid(self):
        srid = 3857
        feature = Feature(geometry=_geom, crs=NamedCRS(srid))
        geom = self.field.to_python(str(feature))
        self.assertEqual(geom.srid, srid)

    def test_invalid(self):
        self.assertRaises(forms.ValidationError, self.field.to_python, '3')

    def test_size_validator(self):
        validator = GeometrySizeValidator(3 ** 2, 4326)
        field = OGRGeometryField(srid=validator.srid, validators=[validator])
        self.assertRaises(forms.ValidationError, field.clean, '0,0,5,5')

    def test_srid(self):
        srid = 4269
        geom = OGRGeometryField(srid=srid).to_python('POINT(0 0)')
        self.assertEqual(geom.srid, srid)
Exemplo n.º 4
0
 def test_srid(self):
     srid = 4269
     geom = OGRGeometryField(srid=srid).to_python('POINT(0 0)')
     self.assertEqual(geom.srid, srid)
Exemplo n.º 5
0
 def test_size_validator(self):
     validator = GeometrySizeValidator(3**2, 4326)
     field = OGRGeometryField(srid=validator.srid, validators=[validator])
     self.assertRaises(forms.ValidationError, field.clean, '0,0,5,5')
Exemplo n.º 6
0
 def setUp(self):
     self.field = OGRGeometryField()
Exemplo n.º 7
0
 def setUp(self):
     self.field = OGRGeometryField()