def test_geojson_type_simple_false(self):
        value = ''
        self.field['type'] = 'geojson'
        _type = types.GeoJSONType(self.field)

        # Required is false so cast null value to None
        assert _type.cast(value) == None
    def test_geojson_type_cast_from_string(self):
        value = '{"geometry": null, "type": "Feature", "properties": {"\\u00c3": "\\u00c3"}}'
        self.field['type'] = 'geojson'
        _type = types.GeoJSONType(self.field)

        self.assertEquals(_type.cast(value), {
            "properties": {
                "Ã": "Ã"
            },
            "type": "Feature",
            "geometry": None,
        })
    def test_geojson_type_simple_true(self):
        value = {
            "properties": {
                "Ã": "Ã"
            },
            "type": "Feature",
            "geometry": None,
        }

        self.field['type'] = 'geojson'
        _type = types.GeoJSONType(self.field)

        self.assertEquals(_type.cast(value), value)
    def test_geojson_type(self):
        value = {'coordinates': [0, 0, 0], 'type': 'Point'}
        self.field['type'] = 'geojson'
        _type = types.GeoJSONType(self.field)

        self.assertRaises(exceptions.InvalidGeoJSONType, _type.cast, value)