def setUp(self) -> None: self.view = CrudViewFactory() self.prop_name = CrudViewProperty.objects.create(view=self.view, key="name", required=True, json_schema={ 'type': "string", "title": "Name" }) self.prop_age = CrudViewProperty.objects.create(view=self.view, key="age", json_schema={ 'type': "integer", "title": "Age" }) self.prop_country = CrudViewProperty.objects.create(view=self.view, key="country", json_schema={ 'type': "string", "title": "Country" }) sync_layer_schema(self.view) sync_ui_schema(self.view) self.feature = Feature.objects.create(layer=self.view.layer, geom='POINT(0 0)', properties={ "name": None, "age": 15, "country": "Country" })
def setUp(self) -> None: self.crud_view = factories.CrudViewFactory() models.CrudViewProperty.objects.create(view=self.crud_view, key="date_start", required=True, json_schema={ 'type': "string", "title": "Date start", "format": "date" }) models.CrudViewProperty.objects.create(view=self.crud_view, key="date_end", required=True, json_schema={ 'type': "string", "title": "Date end", "format": "date" }) self.feature = Feature.objects.create(geom='POINT(0 0)', properties={ "date_start": "test", "date_end": "2020-12-10" }, layer=self.crud_view.layer) sync_layer_schema(self.crud_view) sync_ui_schema(self.crud_view) self.serializer = CrudFeatureDetailSerializer(self.feature)
def setUp(self) -> None: self.view = CrudViewFactory() self.prop_name = CrudViewProperty.objects.create(view=self.view, key="name", required=True, json_schema={ 'type': "string", "title": "Name" }, include_in_tile=True) self.prop_age = CrudViewProperty.objects.create(view=self.view, key="age", json_schema={ 'type': "integer", "title": "Age" }) self.prop_country = CrudViewProperty.objects.create(view=self.view, key="country", json_schema={ 'type': "string", "title": "Country" }) sync_layer_schema(self.view) sync_ui_schema(self.view) sync_properties_in_tiles(self.view)
def test_value_is_removed_if_property_deleted(self): self.prop_age.delete() sync_layer_schema(self.view) sync_ui_schema(self.view) self.feature.refresh_from_db() self.assertIn('age', self.feature.properties) clean_properties_not_in_schema_or_null(self.view) self.feature.refresh_from_db() self.assertNotIn('age', self.feature.properties)
def setUp(self) -> None: self.crud_view = factories.CrudViewFactory() models.CrudViewProperty.objects.create(view=self.crud_view, key="date_start", required=True, json_schema={ 'type': "string", "title": "Date start", "format": "date" }) models.CrudViewProperty.objects.create(view=self.crud_view, key="date_end", required=True, json_schema={ 'type': "string", "title": "Date end", "format": "date" }) models.CrudViewProperty.objects.create( view=self.crud_view, key="not_editable", required=False, editable=False, json_schema={ 'type': "string", "title": "Not editable", }, ) prop_with_values = models.CrudViewProperty.objects.create( view=self.crud_view, key="type", required=False, editable=False, json_schema={ 'type': "string", "title": "Type", }, ) prop_with_array_values = models.CrudViewProperty.objects.create( view=self.crud_view, key="types", required=False, editable=False, json_schema={ "type": "array", "items": { "type": "string", "enum": ['multi_type_3', 'multi_type_4'] }, "title": "Types" }) PropertyEnum.objects.create(value='type_1', pictogram=ContentFile(SMALL_PICTURE, name='test.png'), property=prop_with_values) PropertyEnum.objects.create(value='multi_type_1', pictogram=ContentFile(SMALL_PICTURE, name='test.png'), property=prop_with_array_values) PropertyEnum.objects.create(value='multi_type_2', pictogram=ContentFile(SMALL_PICTURE, name='test.png'), property=prop_with_array_values) PropertyEnum.objects.create(value='multi_type_5', property=prop_with_array_values) self.feature = Feature.objects.create(geom='POINT(0 0)', properties={ "date_start": "test", "date_end": "2020-12-10", "type": "type_1", "types": [ 'multi_type_1', 'multi_type_2', 'multi_type_3', 'multi_type_4', 'multi_type_5' ] }, layer=self.crud_view.layer) sync_layer_schema(self.crud_view) sync_ui_schema(self.crud_view) self.serializer = CrudFeatureDetailSerializer(self.feature)
def setUpTestData(cls): cls.crud_view = factories.CrudViewFactory() sync_layer_schema(cls.crud_view) sync_ui_schema(cls.crud_view)