class LayerModelTestCase(TestCase): def setUp(self): self.layer_schema = LayerSchemaFactory() def test_get_property_title_defined(self): """ method should return property title """ self.assertEqual( self.layer_schema.get_property_title('age'), self.layer_schema.schema['properties']['age']['title']) def test_get_property_title_undefined(self): """ method should return property name """ prop = 'name' self.assertEqual(self.layer_schema.get_property_title(prop), prop) def test_get_property_title_does_not_exist(self): """ method should return property name """ prop = 'toto' self.assertEqual(self.layer_schema.get_property_title(prop), prop) def test_get_property_type_defined(self): """ method should return property type if property exists """ self.assertEqual(self.layer_schema.get_property_type('age'), self.layer_schema.schema['properties']['age']['type']) def test_get_property_type_undefined(self): """ method should return None if property doesn't exist """ self.assertIsNone(self.layer_schema.get_property_type('unknown'))
def setUp(self) -> None: self.layer_trek = LayerSchemaFactory( geom_type=GeometryTypes.LineString) self.layer_city = LayerSchemaFactory(geom_type=GeometryTypes.Polygon) self.trek = FeatureFactory(layer=self.layer_trek, geom='LINESTRING(0 0, 1 1, 2 2, 3 3)') self.city_cover = FeatureFactory( layer=self.layer_city, geom='POLYGON((0 0, 0 3, 3 3, 3 0, 0 0))') self.city_uncover = FeatureFactory( layer=self.layer_city, geom='POLYGON((4 4, 4 7, 7 7, 7 4, 4 4))')
def setUp(self) -> None: self.layer_trek = LayerSchemaFactory( geom_type=GeometryTypes.LineString) self.layer_city = LayerSchemaFactory(geom_type=GeometryTypes.Polygon) self.trek = FeatureFactory(layer=self.layer_trek, geom='LINESTRING(0 0, 1 1, 2 2, 3 3)') self.city_uncover = FeatureFactory( layer=self.layer_city, geom='POLYGON((4 4, 4 7, 7 7, 7 4, 4 4))', properties={ "name": "Cahors", "age": 50000 }) self.detail_url = reverse('feature-detail', args=( self.layer_city.pk, self.city_uncover.identifier, )) self.super_user = UserFactory(is_superuser=True) self.client.force_authenticate(self.super_user)
def setUp(self): self.layer_schema = LayerSchemaFactory() self.extra_layer_point = LayerExtraGeom.objects.create( layer=self.layer_schema, geom_type=GeometryTypes.Point, title='Test_point') self.extra_layer_poly = LayerExtraGeom.objects.create( layer=self.layer_schema, geom_type=GeometryTypes.Polygon, title='Test_polygon') self.feature = Feature.objects.create(layer=self.layer_schema, geom='POINT(0 0)', properties={'name': 'toto'})
def setUp(self): self.layer_schema = LayerSchemaFactory() self.extra_layer = LayerExtraGeom.objects.create( layer=self.layer_schema, geom_type=GeometryTypes.Point, title='Test')
def setUp(self): self.layer_schema = LayerSchemaFactory()
def setUp(self): settings = {'metadata': {'attribution': 'plop'}} self.layer = LayerFactory(name="layerLine", settings=settings) self.layer_extra_geom = LayerExtraGeom.objects.create( layer=self.layer, geom_type=GeometryTypes.LineString, title='Extra geometry') self.layer_relation = LayerSchemaFactory( name='layer_relation', geom_type=GeometryTypes.Polygon) self.feature_cover = FeatureFactory( layer=self.layer_relation, geom='POLYGON((0 0, 0 44, 3 44, 3 0, 0 0))') self.feature_not_cover = FeatureFactory( layer=self.layer_relation, geom='POLYGON((0 0, 0 43.579, 3 43.579, 3 0, 0 0))') self.mygroup = LayerGroup.objects.create(name='mygroup', slug='mygroup') self.mygroup.layers.add(self.layer) self.layer.from_geojson(geojson_data=''' { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "foo": "bar", "baba": "fifi" }, "geometry": { "type": "LineString", "coordinates": [ [ 1.3700294494628906, 43.603640347220924 ], [ 1.2984466552734375, 43.57902295875415 ] ] } } ] } ''') self.layerPoint = LayerFactory(name="layerPoint", settings=settings) self.yourgroup = LayerGroup.objects.create(name='yourgroup', slug='yourgroup') self.yourgroup.layers.add(self.layerPoint) self.layerPoint.from_geojson(geojson_data=''' { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": { "foo": "bar" }, "geometry": { "type": "Point", "coordinates": [ 1.3700294494628906, 43.603640347220924 ] } } ] } ''')