openwisp / django-rest-framework-gis

Geographic add-ons for Django REST Framework. Maintained by the OpenWISP Project.
http://openwisp.org
MIT License
1.09k stars 201 forks source link

OpenAPI Schema Generation #223

Closed dhaval-mehta closed 3 years ago

dhaval-mehta commented 4 years ago

Hi @auvipy,

This fixes: #219, #237

You requested to wait for 3.12 Release. I will write code in such a way that it will be compatible will 3.12 Release.

This will close: #186 and #219

auvipy commented 4 years ago

OK

dhaval-mehta commented 4 years ago

Hi, @auvipy Whenever you are free time, please review code quality. Now, I will work on Testcases and Documentation.

I do not know how to generate schema for models.GeometryField & models.GeometryCollectionField. Please provide guidance for the schema generation for these fields.

auvipy commented 4 years ago

@sir-sigurd would you mind sharing your insight on this? I saw you contribute a lot on geodjango front :)

compacq commented 4 years ago
#````````

Sent with GitHawk

dhaval-mehta commented 4 years ago

Hi @auvipy,

I have handled the majority use cases. You can start reviewing code!

auvipy commented 4 years ago

great work so far. allow me some time

jayvdb commented 4 years ago

Another general comment - the current approach doesnt declare components: and use $ref, which means that the schema are being duplicated throughout the document if the same GIS field are used multiple times in the models. It would be really nice if the GEO schemas can be emitted only once and $ref used. I am not sure if DRF supports that yet.

dhaval-mehta commented 4 years ago

Another general comment - the current approach doesnt declare components: and use $ref, which means that the schema are being duplicated throughout the document if the same GIS field are used multiple times in the models. It would be really nice if the GEO schemas can be emitted only once and $ref used. I am not sure if DRF supports that yet.

In DRF 3.11, There are no components. Component generation logic got merged recently in the master branch of DRF.

If you look at the master branch code of DRF, components related functions _get_reference & get_components internally calls map_serializer method.

We have overridden the map_serializer method. Hence, It will automatically generate components with the future's 3.12 release and it will not generate components with DRF 3.11.

This is the expected behavior.

auvipy commented 4 years ago

Another general comment - the current approach doesnt declare components: and use $ref, which means that the schema are being duplicated throughout the document if the same GIS field are used multiple times in the models. It would be really nice if the GEO schemas can be emitted only once and $ref used. I am not sure if DRF supports that yet.

In DRF 3.11, There are no components. Component generation logic got merged recently in the master branch of DRF.

If you look at the master branch code of DRF, components related functions _get_reference & get_components internally calls map_serializer method.

We have overridden the map_serializer method. Hence, It will automatically generate components with the future's 3.12 release and it will not generate components with DRF 3.11.

This is the expected behavior.

so make this DRF 3.12 only :) no shims needed

dhaval-mehta commented 4 years ago

Another general comment - the current approach doesnt declare components: and use $ref, which means that the schema are being duplicated throughout the document if the same GIS field are used multiple times in the models. It would be really nice if the GEO schemas can be emitted only once and $ref used. I am not sure if DRF supports that yet.

In DRF 3.11, There are no components. Component generation logic got merged recently in the master branch of DRF. If you look at the master branch code of DRF, components related functions _get_reference & get_components internally calls map_serializer method. We have overridden the map_serializer method. Hence, It will automatically generate components with the future's 3.12 release and it will not generate components with DRF 3.11. This is the expected behavior.

so make this DRF 3.12 only :) no shims needed

Alright, I will make this merge request to support only DRF 3.12.

dhaval-mehta commented 4 years ago

@auvipy DRF 3.12 is out. Should I start work on this again?

nemesifier commented 4 years ago

@dhaval-mehta go ahead! :+1:

auvipy commented 4 years ago

@auvipy DRF 3.12 is out. Should I start work on this again?

i won't mind to make drf-gis as drf 3.12+ only as it improved openAPI support to a great extent

nemesifier commented 4 years ago

@auvipy DRF 3.12 is out. Should I start work on this again?

i won't mind to make drf-gis as drf 3.12+ only as it improved openAPI support to a great extent

@auvipy improved openAPI support is not compelling enough to drop support to older DRF versions. We should simply make sure the openAPI features throw some kind of error or warning if DRF<3.12 is used, but the rest of the code should keep working with older DRF versions that are listed in the compatibility table.

TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

10th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! ERROR: /home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:before 2020-10-18 06:28:07.240487 +++ /home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:after 2020-10-18 06:29:07.050781 @@ -5,7 +5,10 @@ from rest_framework.utils import model_meta from rest_framework_gis.fields import GeometrySerializerMethodField -from rest_framework_gis.serializers import GeoFeatureModelListSerializer, GeoFeatureModelSerializer +from rest_framework_gis.serializers import ( + GeoFeatureModelListSerializer, + GeoFeatureModelSerializer, +) class GeoFeatureAutoSchema(AutoSchema): ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/serializers.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/serializers.py:before 2020-10-18 06:28:07.240487 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/serializers.py:after 2020-10-18 06:29:07.076578 @@ -3,9 +3,8 @@ from rest_framework_gis import serializers as gis_serializers from rest_framework_gis.fields import GeometrySerializerMethodField + from .models import * - - from .models import BoxedLocation, Location __all__ = [ ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/models.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/models.py:before 2020-10-18 06:28:07.240487 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/models.py:after 2020-10-18 06:29:07.079459 @@ -1,6 +1,5 @@ from django.contrib.gis.db import models from django.utils.text import slugify - __all__ = [ 'Location', ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:before 2020-10-18 06:28:07.240487 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:after 2020-10-18 06:29:07.099240 @@ -4,6 +4,7 @@ from rest_framework.schemas.openapi import SchemaGenerator from rest_framework_gis.schema import GeoFeatureAutoSchema + from .views import * Skipped 1 files ERROR: Isort check failed! Hint: did you forget running openwisp-qa-format? --- rest_framework_gis/pagination.py 2020-10-18 06:28:07.240487 +0000 +++ rest_framework_gis/pagination.py 2020-10-18 06:29:07.550367 +0000 @@ -26,13 +26,10 @@ def get_paginated_response_schema(self, view): schema = super().get_paginated_response_schema(view) schema['properties']['features'] = schema['properties'].pop('results') schema['properties'] = { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, **schema['properties'], } return schema would reformat rest_framework_gis/pagination.py --- rest_framework_gis/filters.py 2020-10-18 06:28:07.240487 +0000 +++ rest_framework_gis/filters.py 2020-10-18 06:29:07.750864 +0000 @@ -80,26 +80,23 @@ bbox = self.get_filter_bbox(request) if not bbox: return queryset return queryset.filter(Q(**{'%s__%s' % (filter_field, geoDjango_filter): bbox})) - def get_schema_operation_parameters(self, view): return [ { 'name': self.bbox_param, 'required': False, 'in': 'query', 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 4, 'maxItems': 4, - 'example': [0, 0, 10, 10] + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, }, ] @@ -155,14 +152,11 @@ { 'name': self.tile_param, 'required': False, 'in': 'query', 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, + 'schema': {'type': 'string', 'example': '12/56/34'}, }, ] class DistanceToPointFilter(BaseFilterBackend): @@ -273,33 +267,27 @@ return [ { 'name': self.dist_param, 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***{point_param}*** is passed.'.format(point_param=self.point_param) + '***{point_param}*** is passed.'.format(point_param=self.point_param), }, { 'name': self.point_param, 'required': False, 'in': 'query', 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'Represents **point** in **Distance to point filter**', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 2, 'maxItems': 2, - 'example': [0, 10] + 'example': [0, 10], }, 'style': 'form', 'explode': False, - } + }, ] would reformat rest_framework_gis/filters.py --- rest_framework_gis/schema.py 2020-10-18 06:28:07.240487 +0000 +++ rest_framework_gis/schema.py 2020-10-18 06:29:07.796948 +0000 @@ -3,20 +3,20 @@ from django.contrib.gis.db import models from rest_framework.schemas.openapi import AutoSchema from rest_framework.utils import model_meta from rest_framework_gis.fields import GeometrySerializerMethodField -from rest_framework_gis.serializers import GeoFeatureModelListSerializer, GeoFeatureModelSerializer +from rest_framework_gis.serializers import ( + GeoFeatureModelListSerializer, + GeoFeatureModelSerializer, +) class GeoFeatureAutoSchema(AutoSchema): COORDINATES_SCHEMA_FOR_POINT = { 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float', - }, + 'items': {'type': 'number', 'format': 'float',}, 'example': [12.9721, 77.5933], 'minItems': 2, 'maxItems': 3, } @@ -27,73 +27,72 @@ 'minItems': 2, } GEO_FIELD_TO_SCHEMA = { models.PointField: { - 'type': { - 'type': 'string', - 'enum': ['Point'], - }, + 'type': {'type': 'string', 'enum': ['Point'],}, 'coordinates': COORDINATES_SCHEMA_FOR_POINT, }, models.LineStringField: { - 'type': { - 'type': 'string', - 'enum': ['LineString'], - }, + 'type': {'type': 'string', 'enum': ['LineString'],}, 'coordinates': COORDINATES_SCHEMA_FOR_LINE_STRING, }, models.PolygonField: { - 'type': { - 'type': 'string', - 'enum': ['Polygon'], - }, + 'type': {'type': 'string', 'enum': ['Polygon'],}, 'coordinates': { 'type': 'array', - 'items': { - **COORDINATES_SCHEMA_FOR_LINE_STRING, - 'minItems': 4, - }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - } - } + 'items': {**COORDINATES_SCHEMA_FOR_LINE_STRING, 'minItems': 4,}, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], + }, + }, } MULTI_FIELD_MAPPING = { models.PointField: models.MultiPointField, models.LineStringField: models.MultiLineStringField, - models.PolygonField: models.MultiPolygonField + models.PolygonField: models.MultiPolygonField, } for singular_field, multi_field in MULTI_FIELD_MAPPING.items(): GEO_FIELD_TO_SCHEMA[multi_field] = { - 'type': { - 'type': 'string', - 'enum': [multi_field.geom_class.__name__], - }, + 'type': {'type': 'string', 'enum': [multi_field.geom_class.__name__],}, 'coordinates': { 'type': 'array', 'items': GEO_FIELD_TO_SCHEMA[singular_field]['coordinates'], 'example': [ GEO_FIELD_TO_SCHEMA[singular_field]['coordinates']['example'] - ] - } + ], + }, } def _map_geo_field(self, serializer, geo_field_name): field = serializer.fields[geo_field_name] if isinstance(field, GeometrySerializerMethodField): - warnings.warn('Geometry generation for GeometrySerializerMethodField is not supported.'.format(field=field)) + warnings.warn( + 'Geometry generation for GeometrySerializerMethodField is not supported.'.format( + field=field + ) + ) return {} model_field_name = geo_field_name - geo_field = model_meta.get_field_info(serializer.Meta.model).fields[model_field_name] + geo_field = model_meta.get_field_info(serializer.Meta.model).fields[ + model_field_name + ] try: return self.GEO_FIELD_TO_SCHEMA[geo_field.__class__] except KeyError: - warnings.warn('Geometry generation for {field} is not supported.'.format(field=field)) + warnings.warn( + 'Geometry generation for {field} is not supported.'.format(field=field) + ) return {} def map_field(self, field): if isinstance(field, GeoFeatureModelListSerializer): return self._map_geo_feature_model_list_serializer(field) @@ -108,36 +107,30 @@ def _map_geo_feature_model_list_serializer(self, serializer): return { 'type': 'object', 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, 'features': { 'type': 'array', - 'items': self._map_serializer(serializer.child) - } - } + 'items': self._map_serializer(serializer.child), + }, + }, } def _map_geo_feature_model_serializer(self, serializer): schema = super()._map_serializer(serializer) geo_json_schema = { 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - } + 'properties': {'type': {'type': 'string', 'enum': ['Feature']},}, } if serializer.Meta.id_field: - geo_json_schema['properties']['id'] = schema['properties'].pop(serializer.Meta.id_field) + geo_json_schema['properties']['id'] = schema['properties'].pop( + serializer.Meta.id_field + ) geo_field = serializer.Meta.geo_field geo_json_schema['properties']['geometry'] = { 'type': 'object', 'properties': self._map_geo_field(serializer, geo_field), @@ -145,13 +138,11 @@ schema['properties'].pop(geo_field) if serializer.Meta.auto_bbox or serializer.Meta.bbox_geo_field: geo_json_schema['properties']['bbox'] = { 'type': 'array', - 'items': { - 'type': 'number' - }, + 'items': {'type': 'number'}, 'minItems': 4, 'maxItems': 4, 'example': [12.9721, 77.5933, 12.9721, 77.5933], } if serializer.Meta.bbox_geo_field in schema['properties']: would reformat rest_framework_gis/schema.py --- tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 06:28:07.240487 +0000 +++ tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 06:29:08.176654 +0000 @@ -12,76 +12,127 @@ operations = [ migrations.CreateModel( name='LineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.LineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.LineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiLineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiPointField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiPointField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), ('location', django.contrib.gis.db.models.fields.PointField(srid=4326)), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.PolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.PolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), ] would reformat tests/django_restframework_gis_tests/migrations/0003_schema_models.py --- tests/django_restframework_gis_tests/serializers.py 2020-10-18 06:28:07.240487 +0000 +++ tests/django_restframework_gis_tests/serializers.py 2020-10-18 06:29:08.248751 +0000 @@ -235,9 +235,13 @@ model = Nullable geo_field = 'geometry' fields = '__all__' -class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer(BoxedLocationGeoFeatureSerializer): +class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer( + BoxedLocationGeoFeatureSerializer +): class Meta(BoxedLocationGeoFeatureSerializer.Meta): - fields = BoxedLocationGeoFeatureSerializer.Meta.fields + [BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field] - + fields = BoxedLocationGeoFeatureSerializer.Meta.fields + [ + BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field + ] + would reformat tests/django_restframework_gis_tests/serializers.py --- tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 06:28:07.240487 +0000 +++ tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 06:29:09.496803 +0000 @@ -18,11 +18,10 @@ view = generator.create_view(view_cls.as_view(), method, request) return view class TestSchemaGeneration(TestCase): - def test_point_field_outer_most_gis_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = PointSerializer path = '/' @@ -33,123 +32,104 @@ inspector.view = view serializer = inspector._get_serializer(path, method) content = inspector._map_serializer(serializer) content.pop('type', None) content['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', + self.assertEqual( + content, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] + 'properties': { + 'random_field1': {'type': 'string', 'maxLength': 32}, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 + 'required': ['random_field1', 'random_field2', 'location'], + }, + } + }, + ) + + def test_point_field_inner_geo_serializer(self): + class TestPointFieldView(RetrieveAPIView): + serializer_class = ChildPointSerializer + + path = '/' + method = 'GET' + + view = create_view(TestPointFieldView, 'POST', create_request('/')) + inspector = GeoFeatureAutoSchema() + inspector.view = view + serializer = inspector._get_serializer(path, method) + content = inspector._map_serializer(serializer) + content.pop('type', None) + content['properties']['point'].pop('type', None) + content['properties']['point']['properties']['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'point': { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, } } }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - }) - - def test_point_field_inner_geo_serializer(self): - class TestPointFieldView(RetrieveAPIView): - serializer_class = ChildPointSerializer - - path = '/' - method = 'GET' - - view = create_view(TestPointFieldView, 'POST', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - serializer = inspector._get_serializer(path, method) - content = inspector._map_serializer(serializer) - content.pop('type', None) - content['properties']['point'].pop('type', None) - content['properties']['point']['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'point': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, - 'required': [ - 'point' - ] - }) + 'required': ['point'], + }, + ) def test_point_field_inner_geo_list_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = ListChildPointSerializer @@ -161,73 +141,73 @@ inspector.view = view serializer = inspector._get_serializer(path, method) content = inspector._map_serializer(serializer) content.pop('type', None) content['properties']['points'].pop('type', None) - content['properties']['points']['properties']['features']['items']['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'points': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, - 'features': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] + content['properties']['points']['properties']['features']['items'][ + 'properties' + ]['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'points': { + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'features': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': { + 'type': 'string', + 'enum': ['Point'], + }, + 'coordinates': { + 'type': 'array', + 'items': { + 'type': 'number', + 'format': 'float', + }, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, + }, + }, + } } - } - }, - 'required': ['points'] - }) + }, + 'required': ['points'], + }, + ) def test_line_string_field(self): class TestLineStringFieldView(RetrieveAPIView): serializer_class = LineStringSerializer @@ -239,33 +219,30 @@ inspector.view = view serializer = inspector._get_serializer(path, method) content = inspector._map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['LineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['LineString']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 + }, } - } - }) + }, + ) def test_multi_polygon(self): class TestMultiPolygonFieldView(RetrieveAPIView): serializer_class = MultiPolygonSerializer @@ -277,43 +254,52 @@ inspector.view = view serializer = inspector._get_serializer(path, method) content = inspector._map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPolygon'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPolygon']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 4 + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], + 'minItems': 4, + }, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - }, - 'example': [ - [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - ] + 'example': [ + [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ] + ], + }, } - } - }) + }, + ) def test_multi_line_string_field(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiLineStringSerializer @@ -325,37 +311,34 @@ inspector.view = view serializer = inspector._get_serializer(path, method) content = inspector._map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiLineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiLineString']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 - }, - 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]] + 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]], + }, } - } - }) + }, + ) def test_multi_point(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -367,32 +350,29 @@ inspector.view = view serializer = inspector._get_serializer(path, method) content = inspector._map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPoint'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPoint']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[12.9721, 77.5933]] + 'example': [[12.9721, 77.5933]], + }, } - } - }) + }, + ) def check_bbox_schema(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -403,33 +383,31 @@ inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector._get_serializer(path, method) content = inspector._map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) def test_warning_for_geometry_serializer_method_field(self): class TestGeometrySerializerMethodField(RetrieveAPIView): serializer_class = GeometrySerializerMethodFieldSerializer path = '/' method = 'GET' - view = create_view(TestGeometrySerializerMethodField, 'POST', create_request('/')) + view = create_view( + TestGeometrySerializerMethodField, 'POST', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector._get_serializer(path, method) with self.assertWarns(Warning): inspector._map_serializer(serializer) @@ -450,144 +428,142 @@ def test_schema_for_bbox_geo_field(self): path = '/' method = 'GET' - class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView(GeojsonBoxedLocationDetails): + class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView( + GeojsonBoxedLocationDetails + ): serializer_class = BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer - view = create_view(GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/')) + view = create_view( + GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector._get_serializer(path, method) content = inspector._map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertNotIn('bbox_geometry', content['properties']['properties']['properties']) - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertNotIn( + 'bbox_geometry', content['properties']['properties']['properties'] + ) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) class TestPaginationSchemaGeneration(TestCase): - def test_geo_json_pagination_schema(self): - generated_schema = GeoJsonPagination().get_paginated_response_schema(geojson_location_list) + generated_schema = GeoJsonPagination().get_paginated_response_schema( + geojson_location_list + ) self.assertIn('features', generated_schema['properties']) generated_schema['properties'].pop('features') - self.assertDictEqual(generated_schema, { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] + self.assertDictEqual( + generated_schema, + { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'count': {'type': 'integer', 'example': 123,}, + 'next': {'type': 'string', 'nullable': True,}, + 'previous': {'type': 'string', 'nullable': True,}, }, - 'count': { - 'type': 'integer', - 'example': 123, - }, - 'next': { - 'type': 'string', - 'nullable': True, - }, - 'previous': { - 'type': 'string', - 'nullable': True, - }, - }, - }) + }, + ) class TestRestFrameworkGisFiltersSchema(TestCase): - def test_in_BBox_filter_schema(self): path = '/' method = 'GET' - view = create_view(GeojsonLocationContainedInBBoxList, 'GET', create_request('/')) + view = create_view( + GeojsonLocationContainedInBBoxList, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view generated_schema = inspector._get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'in_bbox', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', - 'schema': { - 'type': 'array', - 'items': { - 'type': 'float' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [0, 0, 10, 10]}, - 'style': 'form', - 'explode': False - }) - - def test_in_TMS_filter_schema(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationContainedInTileList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector._get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'tile', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, - }) - - def test_distance_to_point_filter(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector._get_filter_parameters(path, method) - self.assertListEqual(generated_schema, [ - { - 'name': 'dist', + self.assertDictEqual( + generated_schema[0], + { + 'name': 'in_bbox', 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, - 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***point*** is passed.' - }, - { - 'name': 'point', - 'required': False, - 'in': 'query', - 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, - 'minItems': 2, - 'maxItems': 2, - 'example': [0, 10] + 'items': {'type': 'float'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, - } - ]) - + }, + ) + + def test_in_TMS_filter_schema(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationContainedInTileList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector._get_filter_parameters(path, method) + self.assertDictEqual( + generated_schema[0], + { + 'name': 'tile', + 'required': False, + 'in': 'query', + 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', + 'schema': {'type': 'string', 'example': '12/56/34'}, + }, + ) + + def test_distance_to_point_filter(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector._get_filter_parameters(path, method) + self.assertListEqual( + generated_schema, + [ + { + 'name': 'dist', + 'required': False, + 'in': 'query', + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, + 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' + '***point*** is passed.', + }, + { + 'name': 'point', + 'required': False, + 'in': 'query', + 'description': 'Point represented in **x,y** format. ' + 'Represents **point** in **Distance to point filter**', + 'schema': { + 'type': 'array', + 'items': {'type': 'float',}, + 'minItems': 2, + 'maxItems': 2, + 'example': [0, 10], + }, + 'style': 'form', + 'explode': False, + }, + ], + ) + would reformat tests/django_restframework_gis_tests/test_schema_generation.py Oh no! 💥 💔 💥 6 files would be reformatted, 24 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? ./rest_framework_gis/filters.py:86:5: E303 too many blank lines (2) ./rest_framework_gis/filters.py:283:111: E501 line too long (120 > 110 characters) ./rest_framework_gis/schema.py:85:27: F522 '...'.format(...) has unused named argument(s): field ./rest_framework_gis/schema.py:85:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/serializers.py:6:1: F403 'from .models import *' used; unable to detect undefined names ./tests/django_restframework_gis_tests/serializers.py:171:17: F405 'PointModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:186:17: F405 'LineStringModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:193:17: F405 'PolygonModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:200:17: F405 'MultiPolygonModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:207:17: F405 'MultiLineStringModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:214:17: F405 'MultiPointModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:235:17: F405 'Nullable' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:242:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/test_schema_generation.py:7:1: F403 'from .views import *' used; unable to detect undefined names ./tests/django_restframework_gis_tests/test_schema_generation.py:26:32: F405 'PointSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:86:32: F405 'ChildPointSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:154:32: F405 'ListChildPointSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:166:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/test_schema_generation.py:232:32: F405 'LineStringSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:270:32: F405 'MultiPolygonSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:318:32: F405 'MultiLineStringSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:360:32: F405 'MultiPointSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:397:32: F405 'MultiPointSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:425:32: F405 'GeometrySerializerMethodFieldSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:439:32: F405 'GeometrySerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:455:63: F405 'GeojsonBoxedLocationDetails' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:456:32: F405 'BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:484:28: F405 'GeoJsonPagination' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:484:78: F405 'geojson_location_list' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:515:28: F405 'GeojsonLocationContainedInBBoxList' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:539:28: F405 'GeojsonLocationContainedInTileList' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:557:28: F405 'GeojsonLocationWithinDistanceOfPointList' may be undefined, or defined from star imports: .views ./tests/django_restframework_gis_tests/test_schema_generation.py:571:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:17:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:29:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:41:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:53:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:65:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:77:111: E501 line too long (114 > 110 characters) ERROR: Flake8 check failed! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: Merge remote-tracking branch 'upstream/master' ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.10, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@9d9356320b92d3ad130e693e1f4590ece9d60184#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.10 travis run-test-pre: PYTHONHASHSEED='2795338674' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s.........FF..EEEEEEEEEE....s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ====================================================================== ERROR: test_line_string_field (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 231, in test_line_string_field class TestLineStringFieldView(RetrieveAPIView): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 232, in TestLineStringFieldView serializer_class = LineStringSerializer NameError: name 'LineStringSerializer' is not defined ====================================================================== ERROR: test_multi_line_string_field (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 317, in test_multi_line_string_field class TestMultiLineStringFieldView(RetrieveAPIView): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 318, in TestMultiLineStringFieldView serializer_class = MultiLineStringSerializer NameError: name 'MultiLineStringSerializer' is not defined ====================================================================== ERROR: test_multi_point (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 359, in test_multi_point class TestMultiLineStringFieldView(RetrieveAPIView): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 360, in TestMultiLineStringFieldView serializer_class = MultiPointSerializer NameError: name 'MultiPointSerializer' is not defined ====================================================================== ERROR: test_multi_polygon (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 269, in test_multi_polygon class TestMultiPolygonFieldView(RetrieveAPIView): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 270, in TestMultiPolygonFieldView serializer_class = MultiPolygonSerializer NameError: name 'MultiPolygonSerializer' is not defined ====================================================================== ERROR: test_point_field_inner_geo_list_serializer (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 153, in test_point_field_inner_geo_list_serializer class TestPointFieldView(RetrieveAPIView): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 154, in TestPointFieldView serializer_class = ListChildPointSerializer NameError: name 'ListChildPointSerializer' is not defined ====================================================================== ERROR: test_point_field_inner_geo_serializer (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 85, in test_point_field_inner_geo_serializer class TestPointFieldView(RetrieveAPIView): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 86, in TestPointFieldView serializer_class = ChildPointSerializer NameError: name 'ChildPointSerializer' is not defined ====================================================================== ERROR: test_point_field_outer_most_gis_serializer (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 25, in test_point_field_outer_most_gis_serializer class TestPointFieldView(RetrieveAPIView): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 26, in TestPointFieldView serializer_class = PointSerializer NameError: name 'PointSerializer' is not defined ====================================================================== ERROR: test_schema_for_bbox_geo_field (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 455, in test_schema_for_bbox_geo_field class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView(GeojsonBoxedLocationDetails): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 456, in GeojsonBoxedLocationDetailsWithBBoxGeoFieldView serializer_class = BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer NameError: name 'BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer' is not defined ====================================================================== ERROR: test_warning_for_geometry_field (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 438, in test_warning_for_geometry_field class TestGeometryView(RetrieveAPIView): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 439, in TestGeometryView serializer_class = GeometrySerializer NameError: name 'GeometrySerializer' is not defined ====================================================================== ERROR: test_warning_for_geometry_serializer_method_field (django_restframework_gis_tests.test_schema_generation.TestSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 424, in test_warning_for_geometry_serializer_method_field class TestGeometrySerializerMethodField(RetrieveAPIView): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 425, in TestGeometrySerializerMethodField serializer_class = GeometrySerializerMethodFieldSerializer NameError: name 'GeometrySerializerMethodFieldSerializer' is not defined ====================================================================== FAIL: test_geo_json_pagination_schema (django_restframework_gis_tests.test_schema_generation.TestPaginationSchemaGeneration) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 487, in test_geo_json_pagination_schema self.assertDictEqual(generated_schema, { AssertionError: {'typ[172 chars] True, 'format': 'uri', 'example': 'http://api[149 chars]2'}}} != {'typ[172 chars] True}, 'previous': {'type': 'string', 'nullable': True}}} Diff is 743 characters long. Set self.maxDiff to None to see it. ====================================================================== FAIL: test_distance_to_point_filter (django_restframework_gis_tests.test_schema_generation.TestRestFrameworkGisFiltersSchema) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py", line 561, in test_distance_to_point_filter self.assertListEqual(generated_schema, [ AssertionError: Lists differ: [] != [{'name': 'dist', 'required': False, 'in':[502 chars]lse}] Second list contains 2 additional elements. First extra element 0: {'name': 'dist', 'required': False, 'in': 'query', 'schema': {'type': 'number', 'format': 'float', 'default': 1000}, 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ***point*** is passed.'} Diff is 704 characters long. Set self.maxDiff to None to see it. ---------------------------------------------------------------------- Ran 90 tests in 0.856s FAILED (failures=2, errors=10, skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 47e03300-110b-11eb-bfd1-1f84b849c73d
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

9th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! ERROR: /home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:before 2020-10-18 07:12:54.606777 +++ /home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:after 2020-10-18 07:13:44.358175 @@ -5,7 +5,10 @@ from rest_framework.utils import model_meta from rest_framework_gis.fields import GeometrySerializerMethodField -from rest_framework_gis.serializers import GeoFeatureModelListSerializer, GeoFeatureModelSerializer +from rest_framework_gis.serializers import ( + GeoFeatureModelListSerializer, + GeoFeatureModelSerializer, +) class GeoFeatureAutoSchema(AutoSchema): ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/serializers.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/serializers.py:before 2020-10-18 07:12:54.606777 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/serializers.py:after 2020-10-18 07:13:44.385265 @@ -3,9 +3,8 @@ from rest_framework_gis import serializers as gis_serializers from rest_framework_gis.fields import GeometrySerializerMethodField + from .models import * - - from .models import BoxedLocation, Location __all__ = [ ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/models.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/models.py:before 2020-10-18 07:12:54.606777 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/models.py:after 2020-10-18 07:13:44.388243 @@ -1,6 +1,5 @@ from django.contrib.gis.db import models from django.utils.text import slugify - __all__ = [ 'Location', ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:before 2020-10-18 07:12:54.606777 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:after 2020-10-18 07:13:44.409297 @@ -4,6 +4,7 @@ from rest_framework.schemas.openapi import SchemaGenerator from rest_framework_gis.schema import GeoFeatureAutoSchema + from .serializers import * from .views import * Skipped 1 files ERROR: Isort check failed! Hint: did you forget running openwisp-qa-format? --- rest_framework_gis/pagination.py 2020-10-18 07:12:54.606777 +0000 +++ rest_framework_gis/pagination.py 2020-10-18 07:13:44.872932 +0000 @@ -26,13 +26,10 @@ def get_paginated_response_schema(self, view): schema = super().get_paginated_response_schema(view) schema['properties']['features'] = schema['properties'].pop('results') schema['properties'] = { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, **schema['properties'], } return schema would reformat rest_framework_gis/pagination.py --- rest_framework_gis/schema.py 2020-10-18 07:12:54.606777 +0000 +++ rest_framework_gis/schema.py 2020-10-18 07:13:45.112936 +0000 @@ -3,20 +3,20 @@ from django.contrib.gis.db import models from rest_framework.schemas.openapi import AutoSchema from rest_framework.utils import model_meta from rest_framework_gis.fields import GeometrySerializerMethodField -from rest_framework_gis.serializers import GeoFeatureModelListSerializer, GeoFeatureModelSerializer +from rest_framework_gis.serializers import ( + GeoFeatureModelListSerializer, + GeoFeatureModelSerializer, +) class GeoFeatureAutoSchema(AutoSchema): COORDINATES_SCHEMA_FOR_POINT = { 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float', - }, + 'items': {'type': 'number', 'format': 'float',}, 'example': [12.9721, 77.5933], 'minItems': 2, 'maxItems': 3, } @@ -27,73 +27,72 @@ 'minItems': 2, } GEO_FIELD_TO_SCHEMA = { models.PointField: { - 'type': { - 'type': 'string', - 'enum': ['Point'], - }, + 'type': {'type': 'string', 'enum': ['Point'],}, 'coordinates': COORDINATES_SCHEMA_FOR_POINT, }, models.LineStringField: { - 'type': { - 'type': 'string', - 'enum': ['LineString'], - }, + 'type': {'type': 'string', 'enum': ['LineString'],}, 'coordinates': COORDINATES_SCHEMA_FOR_LINE_STRING, }, models.PolygonField: { - 'type': { - 'type': 'string', - 'enum': ['Polygon'], - }, + 'type': {'type': 'string', 'enum': ['Polygon'],}, 'coordinates': { 'type': 'array', - 'items': { - **COORDINATES_SCHEMA_FOR_LINE_STRING, - 'minItems': 4, - }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - } - } + 'items': {**COORDINATES_SCHEMA_FOR_LINE_STRING, 'minItems': 4,}, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], + }, + }, } MULTI_FIELD_MAPPING = { models.PointField: models.MultiPointField, models.LineStringField: models.MultiLineStringField, - models.PolygonField: models.MultiPolygonField + models.PolygonField: models.MultiPolygonField, } for singular_field, multi_field in MULTI_FIELD_MAPPING.items(): GEO_FIELD_TO_SCHEMA[multi_field] = { - 'type': { - 'type': 'string', - 'enum': [multi_field.geom_class.__name__], - }, + 'type': {'type': 'string', 'enum': [multi_field.geom_class.__name__],}, 'coordinates': { 'type': 'array', 'items': GEO_FIELD_TO_SCHEMA[singular_field]['coordinates'], 'example': [ GEO_FIELD_TO_SCHEMA[singular_field]['coordinates']['example'] - ] - } + ], + }, } def _map_geo_field(self, serializer, geo_field_name): field = serializer.fields[geo_field_name] if isinstance(field, GeometrySerializerMethodField): - warnings.warn('Geometry generation for GeometrySerializerMethodField is not supported.'.format(field=field)) + warnings.warn( + 'Geometry generation for GeometrySerializerMethodField is not supported.'.format( + field=field + ) + ) return {} model_field_name = geo_field_name - geo_field = model_meta.get_field_info(serializer.Meta.model).fields[model_field_name] + geo_field = model_meta.get_field_info(serializer.Meta.model).fields[ + model_field_name + ] try: return self.GEO_FIELD_TO_SCHEMA[geo_field.__class__] except KeyError: - warnings.warn('Geometry generation for {field} is not supported.'.format(field=field)) + warnings.warn( + 'Geometry generation for {field} is not supported.'.format(field=field) + ) return {} def map_field(self, field): if isinstance(field, GeoFeatureModelListSerializer): return self._map_geo_feature_model_list_serializer(field) @@ -102,36 +101,30 @@ def _map_geo_feature_model_list_serializer(self, serializer): return { 'type': 'object', 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, 'features': { 'type': 'array', - 'items': self._map_serializer(serializer.child) - } - } + 'items': self._map_serializer(serializer.child), + }, + }, } def _map_geo_feature_model_serializer(self, serializer): schema = super().map_serializer(serializer) geo_json_schema = { 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - } + 'properties': {'type': {'type': 'string', 'enum': ['Feature']},}, } if serializer.Meta.id_field: - geo_json_schema['properties']['id'] = schema['properties'].pop(serializer.Meta.id_field) + geo_json_schema['properties']['id'] = schema['properties'].pop( + serializer.Meta.id_field + ) geo_field = serializer.Meta.geo_field geo_json_schema['properties']['geometry'] = { 'type': 'object', 'properties': self._map_geo_field(serializer, geo_field), @@ -139,13 +132,11 @@ schema['properties'].pop(geo_field) if serializer.Meta.auto_bbox or serializer.Meta.bbox_geo_field: geo_json_schema['properties']['bbox'] = { 'type': 'array', - 'items': { - 'type': 'number' - }, + 'items': {'type': 'number'}, 'minItems': 4, 'maxItems': 4, 'example': [12.9721, 77.5933, 12.9721, 77.5933], } if serializer.Meta.bbox_geo_field in schema['properties']: would reformat rest_framework_gis/schema.py --- rest_framework_gis/filters.py 2020-10-18 07:12:54.606777 +0000 +++ rest_framework_gis/filters.py 2020-10-18 07:13:45.135708 +0000 @@ -89,16 +89,14 @@ 'required': False, 'in': 'query', 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 4, 'maxItems': 4, - 'example': [0, 0, 10, 10] + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, }, ] @@ -154,14 +152,11 @@ { 'name': self.tile_param, 'required': False, 'in': 'query', 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, + 'schema': {'type': 'string', 'example': '12/56/34'}, }, ] class DistanceToPointFilter(BaseFilterBackend): @@ -248,36 +243,30 @@ return [ { 'name': self.dist_param, 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***{point_param}*** is passed.'.format(point_param=self.point_param) + '***{point_param}*** is passed.'.format(point_param=self.point_param), }, { 'name': self.point_param, 'required': False, 'in': 'query', 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'Represents **point** in **Distance to point filter**', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 2, 'maxItems': 2, - 'example': [0, 10] + 'example': [0, 10], }, 'style': 'form', 'explode': False, - } + }, ] class DistanceToPointOrderingFilter(DistanceToPointFilter): srid = 4326 @@ -306,33 +295,27 @@ return [ { 'name': self.dist_param, 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***{point_param}*** is passed.'.format(point_param=self.point_param) + '***{point_param}*** is passed.'.format(point_param=self.point_param), }, { 'name': self.point_param, 'required': False, 'in': 'query', 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'Represents **point** in **Distance to point filter**', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 2, 'maxItems': 2, - 'example': [0, 10] + 'example': [0, 10], }, 'style': 'form', 'explode': False, - } + }, ] would reformat rest_framework_gis/filters.py --- tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 07:12:54.606777 +0000 +++ tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 07:13:45.515584 +0000 @@ -12,76 +12,127 @@ operations = [ migrations.CreateModel( name='LineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.LineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.LineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiLineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiPointField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiPointField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), ('location', django.contrib.gis.db.models.fields.PointField(srid=4326)), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.PolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.PolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), ] would reformat tests/django_restframework_gis_tests/migrations/0003_schema_models.py --- tests/django_restframework_gis_tests/serializers.py 2020-10-18 07:12:54.606777 +0000 +++ tests/django_restframework_gis_tests/serializers.py 2020-10-18 07:13:45.594844 +0000 @@ -235,9 +235,13 @@ model = Nullable geo_field = 'geometry' fields = '__all__' -class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer(BoxedLocationGeoFeatureSerializer): +class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer( + BoxedLocationGeoFeatureSerializer +): class Meta(BoxedLocationGeoFeatureSerializer.Meta): - fields = BoxedLocationGeoFeatureSerializer.Meta.fields + [BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field] - + fields = BoxedLocationGeoFeatureSerializer.Meta.fields + [ + BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field + ] + would reformat tests/django_restframework_gis_tests/serializers.py --- tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 07:12:54.606777 +0000 +++ tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 07:13:46.877444 +0000 @@ -19,11 +19,10 @@ view = generator.create_view(view_cls.as_view(), method, request) return view class TestSchemaGeneration(TestCase): - def test_point_field_outer_most_gis_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = PointSerializer path = '/' @@ -34,123 +33,104 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) content.pop('type', None) content['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', + self.assertEqual( + content, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] + 'properties': { + 'random_field1': {'type': 'string', 'maxLength': 32}, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 + 'required': ['random_field1', 'random_field2', 'location'], + }, + } + }, + ) + + def test_point_field_inner_geo_serializer(self): + class TestPointFieldView(RetrieveAPIView): + serializer_class = ChildPointSerializer + + path = '/' + method = 'GET' + + view = create_view(TestPointFieldView, 'POST', create_request('/')) + inspector = GeoFeatureAutoSchema() + inspector.view = view + serializer = inspector.get_serializer(path, method) + content = inspector.map_serializer(serializer) + content.pop('type', None) + content['properties']['point'].pop('type', None) + content['properties']['point']['properties']['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'point': { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, } } }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - }) - - def test_point_field_inner_geo_serializer(self): - class TestPointFieldView(RetrieveAPIView): - serializer_class = ChildPointSerializer - - path = '/' - method = 'GET' - - view = create_view(TestPointFieldView, 'POST', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - serializer = inspector.get_serializer(path, method) - content = inspector.map_serializer(serializer) - content.pop('type', None) - content['properties']['point'].pop('type', None) - content['properties']['point']['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'point': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, - 'required': [ - 'point' - ] - }) + 'required': ['point'], + }, + ) def test_point_field_inner_geo_list_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = ListChildPointSerializer @@ -162,73 +142,73 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) content.pop('type', None) content['properties']['points'].pop('type', None) - content['properties']['points']['properties']['features']['items']['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'points': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, - 'features': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] + content['properties']['points']['properties']['features']['items'][ + 'properties' + ]['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'points': { + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'features': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': { + 'type': 'string', + 'enum': ['Point'], + }, + 'coordinates': { + 'type': 'array', + 'items': { + 'type': 'number', + 'format': 'float', + }, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, + }, + }, + } } - } - }, - 'required': ['points'] - }) + }, + 'required': ['points'], + }, + ) def test_line_string_field(self): class TestLineStringFieldView(RetrieveAPIView): serializer_class = LineStringSerializer @@ -240,33 +220,30 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['LineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['LineString']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 + }, } - } - }) + }, + ) def test_multi_polygon(self): class TestMultiPolygonFieldView(RetrieveAPIView): serializer_class = MultiPolygonSerializer @@ -278,43 +255,52 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPolygon'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPolygon']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 4 + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], + 'minItems': 4, + }, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - }, - 'example': [ - [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - ] + 'example': [ + [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ] + ], + }, } - } - }) + }, + ) def test_multi_line_string_field(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiLineStringSerializer @@ -326,37 +312,34 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiLineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiLineString']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 - }, - 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]] + 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]], + }, } - } - }) + }, + ) def test_multi_point(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -368,32 +351,29 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPoint'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPoint']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[12.9721, 77.5933]] + 'example': [[12.9721, 77.5933]], + }, } - } - }) + }, + ) def check_bbox_schema(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -404,33 +384,31 @@ inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) def test_warning_for_geometry_serializer_method_field(self): class TestGeometrySerializerMethodField(RetrieveAPIView): serializer_class = GeometrySerializerMethodFieldSerializer path = '/' method = 'GET' - view = create_view(TestGeometrySerializerMethodField, 'POST', create_request('/')) + view = create_view( + TestGeometrySerializerMethodField, 'POST', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) with self.assertWarns(Warning): inspector.map_serializer(serializer) @@ -451,148 +429,152 @@ def test_schema_for_bbox_geo_field(self): path = '/' method = 'GET' - class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView(GeojsonBoxedLocationDetails): + class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView( + GeojsonBoxedLocationDetails + ): serializer_class = BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer - view = create_view(GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/')) + view = create_view( + GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertNotIn('bbox_geometry', content['properties']['properties']['properties']) - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertNotIn( + 'bbox_geometry', content['properties']['properties']['properties'] + ) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) class TestPaginationSchemaGeneration(TestCase): - def test_geo_json_pagination_schema(self): - generated_schema = GeoJsonPagination().get_paginated_response_schema(geojson_location_list) + generated_schema = GeoJsonPagination().get_paginated_response_schema( + geojson_location_list + ) self.assertIn('features', generated_schema['properties']) generated_schema['properties'].pop('features') - self.assertDictEqual(generated_schema, { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] + self.assertDictEqual( + generated_schema, + { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'count': {'type': 'integer', 'example': 123,}, + 'next': { + 'type': 'string', + 'nullable': True, + 'format': 'uri', + 'example': 'http://api.example.org/accounts/?page=4', + }, + 'previous': { + 'type': 'string', + 'nullable': True, + 'format': 'uri', + 'example': 'http://api.example.org/accounts/?page=2', + }, }, - 'count': { - 'type': 'integer', - 'example': 123, - }, - 'next': { - 'type': 'string', - 'nullable': True, - 'format': 'uri', - 'example': 'http://api.example.org/accounts/?page=4', - }, - 'previous': { - 'type': 'string', - 'nullable': True, - 'format': 'uri', - 'example': 'http://api.example.org/accounts/?page=2', - }, - }, - }) + }, + ) class TestRestFrameworkGisFiltersSchema(TestCase): - def test_in_BBox_filter_schema(self): path = '/' method = 'GET' - view = create_view(GeojsonLocationContainedInBBoxList, 'GET', create_request('/')) + view = create_view( + GeojsonLocationContainedInBBoxList, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view generated_schema = inspector.get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'in_bbox', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', - 'schema': { - 'type': 'array', - 'items': { - 'type': 'float' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [0, 0, 10, 10]}, - 'style': 'form', - 'explode': False - }) - - def test_in_TMS_filter_schema(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationContainedInTileList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector.get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'tile', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, - }) - - def test_distance_to_point_filter(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector.get_filter_parameters(path, method) - self.assertListEqual(generated_schema, [ - { - 'name': 'dist', + self.assertDictEqual( + generated_schema[0], + { + 'name': 'in_bbox', 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, - 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***point*** is passed.' - }, - { - 'name': 'point', - 'required': False, - 'in': 'query', - 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, - 'minItems': 2, - 'maxItems': 2, - 'example': [0, 10] + 'items': {'type': 'float'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, - } - ]) - + }, + ) + + def test_in_TMS_filter_schema(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationContainedInTileList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector.get_filter_parameters(path, method) + self.assertDictEqual( + generated_schema[0], + { + 'name': 'tile', + 'required': False, + 'in': 'query', + 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', + 'schema': {'type': 'string', 'example': '12/56/34'}, + }, + ) + + def test_distance_to_point_filter(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector.get_filter_parameters(path, method) + self.assertListEqual( + generated_schema, + [ + { + 'name': 'dist', + 'required': False, + 'in': 'query', + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, + 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' + '***point*** is passed.', + }, + { + 'name': 'point', + 'required': False, + 'in': 'query', + 'description': 'Point represented in **x,y** format. ' + 'Represents **point** in **Distance to point filter**', + 'schema': { + 'type': 'array', + 'items': {'type': 'float',}, + 'minItems': 2, + 'maxItems': 2, + 'example': [0, 10], + }, + 'style': 'form', + 'explode': False, + }, + ], + ) + would reformat tests/django_restframework_gis_tests/test_schema_generation.py Oh no! 💥 💔 💥 6 files would be reformatted, 24 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? ./rest_framework_gis/filters.py:258:111: E501 line too long (120 > 110 characters) ./rest_framework_gis/filters.py:316:111: E501 line too long (120 > 110 characters) ./rest_framework_gis/schema.py:85:27: F522 '...'.format(...) has unused named argument(s): field ./rest_framework_gis/schema.py:85:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/serializers.py:6:1: F403 'from .models import *' used; unable to detect undefined names ./tests/django_restframework_gis_tests/serializers.py:171:17: F405 'PointModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:186:17: F405 'LineStringModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:193:17: F405 'PolygonModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:200:17: F405 'MultiPolygonModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:207:17: F405 'MultiLineStringModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:214:17: F405 'MultiPointModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:235:17: F405 'Nullable' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:242:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/test_schema_generation.py:7:1: F403 'from .serializers import *' used; unable to detect undefined names ./tests/django_restframework_gis_tests/test_schema_generation.py:8:1: F403 'from .views import *' used; unable to detect undefined names ./tests/django_restframework_gis_tests/test_schema_generation.py:27:32: F405 'PointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:87:32: F405 'ChildPointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:155:32: F405 'ListChildPointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:167:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/test_schema_generation.py:233:32: F405 'LineStringSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:271:32: F405 'MultiPolygonSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:319:32: F405 'MultiLineStringSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:361:32: F405 'MultiPointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:398:32: F405 'MultiPointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:426:32: F405 'GeometrySerializerMethodFieldSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:440:32: F405 'GeometrySerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:456:63: F405 'GeojsonBoxedLocationDetails' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:457:32: F405 'BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:485:28: F405 'GeoJsonPagination' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:485:78: F405 'geojson_location_list' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:520:28: F405 'GeojsonLocationContainedInBBoxList' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:544:28: F405 'GeojsonLocationContainedInTileList' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:562:28: F405 'GeojsonLocationWithinDistanceOfPointList' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:576:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:17:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:29:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:41:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:53:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:65:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:77:111: E501 line too long (114 > 110 characters) ERROR: Flake8 check failed! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: fix support for distance to point filter ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@f79fb38c83f5d1514f5e26d544cebdb394111b7a#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.10 travis run-test-pre: PYTHONHASHSEED='4003749541' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:94: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn('Geometry generation for {field} is not supported.'.format(field=field)) .......sfree(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
python setup.py check -r -s ``` changes detected (content changed, file is created, or file is deleted):\n/home/travis/.cache/pip/http/0/1/a/b/3/01ab38ac63d82e82f212dd86d62de883eb0d7de6be8db88f70d14a62 /home/travis/.cache/pip/http/0/4/1/8/c/0418c83b80f7f7bfaec2738bfbbee53d2c1562196c0781702f6eddc8 /home/travis/.cache/pip/http/2/1/3/7/f/2137f603f620cd2c8b12df96008a50a6038fc764aaf0d243c22963d6 /home/travis/.cache/pip/http/2/7/5/f/2/275f241b603ce94e72c60a9e95956f608cb948fdd3aa91d83b67a949 /home/travis/.cache/pip/http/2/a/8/8/1/2a881ed1cd85be35ec0cf3f055dc952010fdae76af5357361c9dde85 /home/travis/.cache/pip/http/3/3/2/f/4/332f48a907b592bd9bf085af65691cebb7583c166f92435c1594e9d8 /home/travis/.cache/pip/http/4/8/4/4/3/484431dd73b47358ec9671bf3076913bb0ebf701bcfd0bdbc092a988 /home/travis/.cache/pip/http/4/b/e/0/7/4be07d3ac353e38d2c9e3a257cad36ee2a758fc88b4cd5f0d479a5a9 /home/travis/.cache/pip/http/4/c/9/5/4/4c95479e6337bff60ba209bc982cb2eaaf97107ed9b2cd560e537457 /home/travis/.cache/pip/http/4/d/2/7/2/4d272e6453941ce8b0a37a02cdb1685fc612c33441fa74691fb40656 /home/travis/.cache/pip/http/5/b/e/1/1/5\n... changes detected, packing new archive gzip: warning: GZIP environment variable is deprecated; use an alias or script uploading PR.223/cache--linux-focal-11939a93e416e084b3cbb7f39953f832301d7488f75e175d73fa0743b8351523--python-3.8.tgz cache uploaded Done. Your build exited with 1. ```

10th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! ERROR: /home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:before 2020-10-18 07:12:47.763783 +++ /home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:after 2020-10-18 07:13:34.127378 @@ -5,7 +5,10 @@ from rest_framework.utils import model_meta from rest_framework_gis.fields import GeometrySerializerMethodField -from rest_framework_gis.serializers import GeoFeatureModelListSerializer, GeoFeatureModelSerializer +from rest_framework_gis.serializers import ( + GeoFeatureModelListSerializer, + GeoFeatureModelSerializer, +) class GeoFeatureAutoSchema(AutoSchema): ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/serializers.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/serializers.py:before 2020-10-18 07:12:47.763783 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/serializers.py:after 2020-10-18 07:13:34.152952 @@ -3,9 +3,8 @@ from rest_framework_gis import serializers as gis_serializers from rest_framework_gis.fields import GeometrySerializerMethodField + from .models import * - - from .models import BoxedLocation, Location __all__ = [ ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/models.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/models.py:before 2020-10-18 07:12:47.763783 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/models.py:after 2020-10-18 07:13:34.155696 @@ -1,6 +1,5 @@ from django.contrib.gis.db import models from django.utils.text import slugify - __all__ = [ 'Location', ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:before 2020-10-18 07:12:47.763783 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:after 2020-10-18 07:13:34.176268 @@ -4,6 +4,7 @@ from rest_framework.schemas.openapi import SchemaGenerator from rest_framework_gis.schema import GeoFeatureAutoSchema + from .serializers import * from .views import * Skipped 1 files ERROR: Isort check failed! Hint: did you forget running openwisp-qa-format? --- rest_framework_gis/pagination.py 2020-10-18 07:12:47.763783 +0000 +++ rest_framework_gis/pagination.py 2020-10-18 07:13:34.595669 +0000 @@ -26,13 +26,10 @@ def get_paginated_response_schema(self, view): schema = super().get_paginated_response_schema(view) schema['properties']['features'] = schema['properties'].pop('results') schema['properties'] = { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, **schema['properties'], } return schema would reformat rest_framework_gis/pagination.py --- rest_framework_gis/schema.py 2020-10-18 07:12:47.763783 +0000 +++ rest_framework_gis/schema.py 2020-10-18 07:13:34.829169 +0000 @@ -3,20 +3,20 @@ from django.contrib.gis.db import models from rest_framework.schemas.openapi import AutoSchema from rest_framework.utils import model_meta from rest_framework_gis.fields import GeometrySerializerMethodField -from rest_framework_gis.serializers import GeoFeatureModelListSerializer, GeoFeatureModelSerializer +from rest_framework_gis.serializers import ( + GeoFeatureModelListSerializer, + GeoFeatureModelSerializer, +) class GeoFeatureAutoSchema(AutoSchema): COORDINATES_SCHEMA_FOR_POINT = { 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float', - }, + 'items': {'type': 'number', 'format': 'float',}, 'example': [12.9721, 77.5933], 'minItems': 2, 'maxItems': 3, } @@ -27,73 +27,72 @@ 'minItems': 2, } GEO_FIELD_TO_SCHEMA = { models.PointField: { - 'type': { - 'type': 'string', - 'enum': ['Point'], - }, + 'type': {'type': 'string', 'enum': ['Point'],}, 'coordinates': COORDINATES_SCHEMA_FOR_POINT, }, models.LineStringField: { - 'type': { - 'type': 'string', - 'enum': ['LineString'], - }, + 'type': {'type': 'string', 'enum': ['LineString'],}, 'coordinates': COORDINATES_SCHEMA_FOR_LINE_STRING, }, models.PolygonField: { - 'type': { - 'type': 'string', - 'enum': ['Polygon'], - }, + 'type': {'type': 'string', 'enum': ['Polygon'],}, 'coordinates': { 'type': 'array', - 'items': { - **COORDINATES_SCHEMA_FOR_LINE_STRING, - 'minItems': 4, - }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - } - } + 'items': {**COORDINATES_SCHEMA_FOR_LINE_STRING, 'minItems': 4,}, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], + }, + }, } MULTI_FIELD_MAPPING = { models.PointField: models.MultiPointField, models.LineStringField: models.MultiLineStringField, - models.PolygonField: models.MultiPolygonField + models.PolygonField: models.MultiPolygonField, } for singular_field, multi_field in MULTI_FIELD_MAPPING.items(): GEO_FIELD_TO_SCHEMA[multi_field] = { - 'type': { - 'type': 'string', - 'enum': [multi_field.geom_class.__name__], - }, + 'type': {'type': 'string', 'enum': [multi_field.geom_class.__name__],}, 'coordinates': { 'type': 'array', 'items': GEO_FIELD_TO_SCHEMA[singular_field]['coordinates'], 'example': [ GEO_FIELD_TO_SCHEMA[singular_field]['coordinates']['example'] - ] - } + ], + }, } def _map_geo_field(self, serializer, geo_field_name): field = serializer.fields[geo_field_name] if isinstance(field, GeometrySerializerMethodField): - warnings.warn('Geometry generation for GeometrySerializerMethodField is not supported.'.format(field=field)) + warnings.warn( + 'Geometry generation for GeometrySerializerMethodField is not supported.'.format( + field=field + ) + ) return {} model_field_name = geo_field_name - geo_field = model_meta.get_field_info(serializer.Meta.model).fields[model_field_name] + geo_field = model_meta.get_field_info(serializer.Meta.model).fields[ + model_field_name + ] try: return self.GEO_FIELD_TO_SCHEMA[geo_field.__class__] except KeyError: - warnings.warn('Geometry generation for {field} is not supported.'.format(field=field)) + warnings.warn( + 'Geometry generation for {field} is not supported.'.format(field=field) + ) return {} def map_field(self, field): if isinstance(field, GeoFeatureModelListSerializer): return self._map_geo_feature_model_list_serializer(field) @@ -102,36 +101,30 @@ def _map_geo_feature_model_list_serializer(self, serializer): return { 'type': 'object', 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, 'features': { 'type': 'array', - 'items': self._map_serializer(serializer.child) - } - } + 'items': self._map_serializer(serializer.child), + }, + }, } def _map_geo_feature_model_serializer(self, serializer): schema = super().map_serializer(serializer) geo_json_schema = { 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - } + 'properties': {'type': {'type': 'string', 'enum': ['Feature']},}, } if serializer.Meta.id_field: - geo_json_schema['properties']['id'] = schema['properties'].pop(serializer.Meta.id_field) + geo_json_schema['properties']['id'] = schema['properties'].pop( + serializer.Meta.id_field + ) geo_field = serializer.Meta.geo_field geo_json_schema['properties']['geometry'] = { 'type': 'object', 'properties': self._map_geo_field(serializer, geo_field), @@ -139,13 +132,11 @@ schema['properties'].pop(geo_field) if serializer.Meta.auto_bbox or serializer.Meta.bbox_geo_field: geo_json_schema['properties']['bbox'] = { 'type': 'array', - 'items': { - 'type': 'number' - }, + 'items': {'type': 'number'}, 'minItems': 4, 'maxItems': 4, 'example': [12.9721, 77.5933, 12.9721, 77.5933], } if serializer.Meta.bbox_geo_field in schema['properties']: would reformat rest_framework_gis/schema.py --- rest_framework_gis/filters.py 2020-10-18 07:12:47.763783 +0000 +++ rest_framework_gis/filters.py 2020-10-18 07:13:34.845699 +0000 @@ -89,16 +89,14 @@ 'required': False, 'in': 'query', 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 4, 'maxItems': 4, - 'example': [0, 0, 10, 10] + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, }, ] @@ -154,14 +152,11 @@ { 'name': self.tile_param, 'required': False, 'in': 'query', 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, + 'schema': {'type': 'string', 'example': '12/56/34'}, }, ] class DistanceToPointFilter(BaseFilterBackend): @@ -248,36 +243,30 @@ return [ { 'name': self.dist_param, 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***{point_param}*** is passed.'.format(point_param=self.point_param) + '***{point_param}*** is passed.'.format(point_param=self.point_param), }, { 'name': self.point_param, 'required': False, 'in': 'query', 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'Represents **point** in **Distance to point filter**', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 2, 'maxItems': 2, - 'example': [0, 10] + 'example': [0, 10], }, 'style': 'form', 'explode': False, - } + }, ] class DistanceToPointOrderingFilter(DistanceToPointFilter): srid = 4326 @@ -306,33 +295,27 @@ return [ { 'name': self.dist_param, 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***{point_param}*** is passed.'.format(point_param=self.point_param) + '***{point_param}*** is passed.'.format(point_param=self.point_param), }, { 'name': self.point_param, 'required': False, 'in': 'query', 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'Represents **point** in **Distance to point filter**', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 2, 'maxItems': 2, - 'example': [0, 10] + 'example': [0, 10], }, 'style': 'form', 'explode': False, - } + }, ] would reformat rest_framework_gis/filters.py --- tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 07:12:47.763783 +0000 +++ tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 07:13:35.212409 +0000 @@ -12,76 +12,127 @@ operations = [ migrations.CreateModel( name='LineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.LineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.LineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiLineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiPointField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiPointField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), ('location', django.contrib.gis.db.models.fields.PointField(srid=4326)), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.PolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.PolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), ] would reformat tests/django_restframework_gis_tests/migrations/0003_schema_models.py --- tests/django_restframework_gis_tests/serializers.py 2020-10-18 07:12:47.763783 +0000 +++ tests/django_restframework_gis_tests/serializers.py 2020-10-18 07:13:35.291975 +0000 @@ -235,9 +235,13 @@ model = Nullable geo_field = 'geometry' fields = '__all__' -class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer(BoxedLocationGeoFeatureSerializer): +class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer( + BoxedLocationGeoFeatureSerializer +): class Meta(BoxedLocationGeoFeatureSerializer.Meta): - fields = BoxedLocationGeoFeatureSerializer.Meta.fields + [BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field] - + fields = BoxedLocationGeoFeatureSerializer.Meta.fields + [ + BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field + ] + would reformat tests/django_restframework_gis_tests/serializers.py --- tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 07:12:47.763783 +0000 +++ tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 07:13:36.536000 +0000 @@ -19,11 +19,10 @@ view = generator.create_view(view_cls.as_view(), method, request) return view class TestSchemaGeneration(TestCase): - def test_point_field_outer_most_gis_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = PointSerializer path = '/' @@ -34,123 +33,104 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) content.pop('type', None) content['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', + self.assertEqual( + content, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] + 'properties': { + 'random_field1': {'type': 'string', 'maxLength': 32}, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 + 'required': ['random_field1', 'random_field2', 'location'], + }, + } + }, + ) + + def test_point_field_inner_geo_serializer(self): + class TestPointFieldView(RetrieveAPIView): + serializer_class = ChildPointSerializer + + path = '/' + method = 'GET' + + view = create_view(TestPointFieldView, 'POST', create_request('/')) + inspector = GeoFeatureAutoSchema() + inspector.view = view + serializer = inspector.get_serializer(path, method) + content = inspector.map_serializer(serializer) + content.pop('type', None) + content['properties']['point'].pop('type', None) + content['properties']['point']['properties']['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'point': { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, } } }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - }) - - def test_point_field_inner_geo_serializer(self): - class TestPointFieldView(RetrieveAPIView): - serializer_class = ChildPointSerializer - - path = '/' - method = 'GET' - - view = create_view(TestPointFieldView, 'POST', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - serializer = inspector.get_serializer(path, method) - content = inspector.map_serializer(serializer) - content.pop('type', None) - content['properties']['point'].pop('type', None) - content['properties']['point']['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'point': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, - 'required': [ - 'point' - ] - }) + 'required': ['point'], + }, + ) def test_point_field_inner_geo_list_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = ListChildPointSerializer @@ -162,73 +142,73 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) content.pop('type', None) content['properties']['points'].pop('type', None) - content['properties']['points']['properties']['features']['items']['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'points': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, - 'features': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] + content['properties']['points']['properties']['features']['items'][ + 'properties' + ]['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'points': { + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'features': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': { + 'type': 'string', + 'enum': ['Point'], + }, + 'coordinates': { + 'type': 'array', + 'items': { + 'type': 'number', + 'format': 'float', + }, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, + }, + }, + } } - } - }, - 'required': ['points'] - }) + }, + 'required': ['points'], + }, + ) def test_line_string_field(self): class TestLineStringFieldView(RetrieveAPIView): serializer_class = LineStringSerializer @@ -240,33 +220,30 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['LineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['LineString']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 + }, } - } - }) + }, + ) def test_multi_polygon(self): class TestMultiPolygonFieldView(RetrieveAPIView): serializer_class = MultiPolygonSerializer @@ -278,43 +255,52 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPolygon'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPolygon']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 4 + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], + 'minItems': 4, + }, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - }, - 'example': [ - [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - ] + 'example': [ + [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ] + ], + }, } - } - }) + }, + ) def test_multi_line_string_field(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiLineStringSerializer @@ -326,37 +312,34 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiLineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiLineString']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 - }, - 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]] + 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]], + }, } - } - }) + }, + ) def test_multi_point(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -368,32 +351,29 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPoint'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPoint']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[12.9721, 77.5933]] + 'example': [[12.9721, 77.5933]], + }, } - } - }) + }, + ) def check_bbox_schema(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -404,33 +384,31 @@ inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) def test_warning_for_geometry_serializer_method_field(self): class TestGeometrySerializerMethodField(RetrieveAPIView): serializer_class = GeometrySerializerMethodFieldSerializer path = '/' method = 'GET' - view = create_view(TestGeometrySerializerMethodField, 'POST', create_request('/')) + view = create_view( + TestGeometrySerializerMethodField, 'POST', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) with self.assertWarns(Warning): inspector.map_serializer(serializer) @@ -451,148 +429,152 @@ def test_schema_for_bbox_geo_field(self): path = '/' method = 'GET' - class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView(GeojsonBoxedLocationDetails): + class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView( + GeojsonBoxedLocationDetails + ): serializer_class = BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer - view = create_view(GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/')) + view = create_view( + GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertNotIn('bbox_geometry', content['properties']['properties']['properties']) - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertNotIn( + 'bbox_geometry', content['properties']['properties']['properties'] + ) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) class TestPaginationSchemaGeneration(TestCase): - def test_geo_json_pagination_schema(self): - generated_schema = GeoJsonPagination().get_paginated_response_schema(geojson_location_list) + generated_schema = GeoJsonPagination().get_paginated_response_schema( + geojson_location_list + ) self.assertIn('features', generated_schema['properties']) generated_schema['properties'].pop('features') - self.assertDictEqual(generated_schema, { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] + self.assertDictEqual( + generated_schema, + { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'count': {'type': 'integer', 'example': 123,}, + 'next': { + 'type': 'string', + 'nullable': True, + 'format': 'uri', + 'example': 'http://api.example.org/accounts/?page=4', + }, + 'previous': { + 'type': 'string', + 'nullable': True, + 'format': 'uri', + 'example': 'http://api.example.org/accounts/?page=2', + }, }, - 'count': { - 'type': 'integer', - 'example': 123, - }, - 'next': { - 'type': 'string', - 'nullable': True, - 'format': 'uri', - 'example': 'http://api.example.org/accounts/?page=4', - }, - 'previous': { - 'type': 'string', - 'nullable': True, - 'format': 'uri', - 'example': 'http://api.example.org/accounts/?page=2', - }, - }, - }) + }, + ) class TestRestFrameworkGisFiltersSchema(TestCase): - def test_in_BBox_filter_schema(self): path = '/' method = 'GET' - view = create_view(GeojsonLocationContainedInBBoxList, 'GET', create_request('/')) + view = create_view( + GeojsonLocationContainedInBBoxList, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view generated_schema = inspector.get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'in_bbox', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', - 'schema': { - 'type': 'array', - 'items': { - 'type': 'float' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [0, 0, 10, 10]}, - 'style': 'form', - 'explode': False - }) - - def test_in_TMS_filter_schema(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationContainedInTileList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector.get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'tile', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, - }) - - def test_distance_to_point_filter(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector.get_filter_parameters(path, method) - self.assertListEqual(generated_schema, [ - { - 'name': 'dist', + self.assertDictEqual( + generated_schema[0], + { + 'name': 'in_bbox', 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, - 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***point*** is passed.' - }, - { - 'name': 'point', - 'required': False, - 'in': 'query', - 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, - 'minItems': 2, - 'maxItems': 2, - 'example': [0, 10] + 'items': {'type': 'float'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, - } - ]) - + }, + ) + + def test_in_TMS_filter_schema(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationContainedInTileList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector.get_filter_parameters(path, method) + self.assertDictEqual( + generated_schema[0], + { + 'name': 'tile', + 'required': False, + 'in': 'query', + 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', + 'schema': {'type': 'string', 'example': '12/56/34'}, + }, + ) + + def test_distance_to_point_filter(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector.get_filter_parameters(path, method) + self.assertListEqual( + generated_schema, + [ + { + 'name': 'dist', + 'required': False, + 'in': 'query', + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, + 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' + '***point*** is passed.', + }, + { + 'name': 'point', + 'required': False, + 'in': 'query', + 'description': 'Point represented in **x,y** format. ' + 'Represents **point** in **Distance to point filter**', + 'schema': { + 'type': 'array', + 'items': {'type': 'float',}, + 'minItems': 2, + 'maxItems': 2, + 'example': [0, 10], + }, + 'style': 'form', + 'explode': False, + }, + ], + ) + would reformat tests/django_restframework_gis_tests/test_schema_generation.py Oh no! 💥 💔 💥 6 files would be reformatted, 24 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? ./rest_framework_gis/filters.py:258:111: E501 line too long (120 > 110 characters) ./rest_framework_gis/filters.py:316:111: E501 line too long (120 > 110 characters) ./rest_framework_gis/schema.py:85:27: F522 '...'.format(...) has unused named argument(s): field ./rest_framework_gis/schema.py:85:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/serializers.py:6:1: F403 'from .models import *' used; unable to detect undefined names ./tests/django_restframework_gis_tests/serializers.py:171:17: F405 'PointModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:186:17: F405 'LineStringModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:193:17: F405 'PolygonModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:200:17: F405 'MultiPolygonModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:207:17: F405 'MultiLineStringModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:214:17: F405 'MultiPointModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:235:17: F405 'Nullable' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:242:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/test_schema_generation.py:7:1: F403 'from .serializers import *' used; unable to detect undefined names ./tests/django_restframework_gis_tests/test_schema_generation.py:8:1: F403 'from .views import *' used; unable to detect undefined names ./tests/django_restframework_gis_tests/test_schema_generation.py:27:32: F405 'PointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:87:32: F405 'ChildPointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:155:32: F405 'ListChildPointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:167:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/test_schema_generation.py:233:32: F405 'LineStringSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:271:32: F405 'MultiPolygonSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:319:32: F405 'MultiLineStringSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:361:32: F405 'MultiPointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:398:32: F405 'MultiPointSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:426:32: F405 'GeometrySerializerMethodFieldSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:440:32: F405 'GeometrySerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:456:63: F405 'GeojsonBoxedLocationDetails' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:457:32: F405 'BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:485:28: F405 'GeoJsonPagination' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:485:78: F405 'geojson_location_list' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:520:28: F405 'GeojsonLocationContainedInBBoxList' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:544:28: F405 'GeojsonLocationContainedInTileList' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:562:28: F405 'GeojsonLocationWithinDistanceOfPointList' may be undefined, or defined from star imports: .serializers, .views ./tests/django_restframework_gis_tests/test_schema_generation.py:576:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:17:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:29:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:41:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:53:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:65:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:77:111: E501 line too long (114 > 110 characters) ERROR: Flake8 check failed! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: fix support for distance to point filter ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@f79fb38c83f5d1514f5e26d544cebdb394111b7a#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.10 travis run-test-pre: PYTHONHASHSEED='265146364' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:94: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn('Geometry generation for {field} is not supported.'.format(field=field)) .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.741s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 830e97e0-1111-11eb-bfd1-1f84b849c73d
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

10th Build

View build log

./run-qa-checks ``` ./AUTHORS needs newline at the end ERROR: Blank endline check failed! Skipped 1 files SUCCESS: Isort check successful! --- rest_framework_gis/pagination.py 2020-10-18 07:41:24.284564 +0000 +++ rest_framework_gis/pagination.py 2020-10-18 07:42:12.347316 +0000 @@ -26,13 +26,10 @@ def get_paginated_response_schema(self, view): schema = super().get_paginated_response_schema(view) schema['properties']['features'] = schema['properties'].pop('results') schema['properties'] = { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, **schema['properties'], } return schema would reformat rest_framework_gis/pagination.py --- rest_framework_gis/filters.py 2020-10-18 07:41:24.284564 +0000 +++ rest_framework_gis/filters.py 2020-10-18 07:42:12.564074 +0000 @@ -89,16 +89,14 @@ 'required': False, 'in': 'query', 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 4, 'maxItems': 4, - 'example': [0, 0, 10, 10] + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, }, ] @@ -154,14 +152,11 @@ { 'name': self.tile_param, 'required': False, 'in': 'query', 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, + 'schema': {'type': 'string', 'example': '12/56/34'}, }, ] class DistanceToPointFilter(BaseFilterBackend): @@ -243,34 +238,36 @@ return queryset.filter( Q(**{'%s__%s' % (filter_field, geoDjango_filter): (point, dist)}) ) def get_schema_operation_parameters(self, view): - return [{'name': self.dist_param, - 'required': False, - 'in': 'query', - 'schema': {'type': 'number', - 'format': 'float', - 'default': 1000, - }, - 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***{point_param}*** is passed.'.format(point_param=self.point_param)}, - {'name': self.point_param, - 'required': False, - 'in': 'query', - 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', - 'schema': {'type': 'array', - 'items': {'type': 'float', - }, - 'minItems': 2, - 'maxItems': 2, - 'example': [0, - 10]}, - 'style': 'form', - 'explode': False, - }] + return [ + { + 'name': self.dist_param, + 'required': False, + 'in': 'query', + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, + 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' + '***{point_param}*** is passed.'.format(point_param=self.point_param), + }, + { + 'name': self.point_param, + 'required': False, + 'in': 'query', + 'description': 'Point represented in **x,y** format. ' + 'Represents **point** in **Distance to point filter**', + 'schema': { + 'type': 'array', + 'items': {'type': 'float',}, + 'minItems': 2, + 'maxItems': 2, + 'example': [0, 10], + }, + 'style': 'form', + 'explode': False, + }, + ] class DistanceToPointOrderingFilter(DistanceToPointFilter): srid = 4326 order_param = 'order' @@ -294,25 +291,21 @@ else: return queryset.order_by(GeometryDistance(filter_field, point)) def get_schema_operation_parameters(self, view): params = super().get_schema_operation_parameters(view) - params.append({ - 'name': self.order_param, - 'required': False, - 'in': 'query', - 'description': '', - 'schema': { - 'type': 'enum', - 'items': { - 'type': 'string', - 'enum': [ - 'asc', - 'desc' - ] + params.append( + { + 'name': self.order_param, + 'required': False, + 'in': 'query', + 'description': '', + 'schema': { + 'type': 'enum', + 'items': {'type': 'string', 'enum': ['asc', 'desc']}, + 'example': 'desc', }, - 'example': 'desc' - }, - 'style': 'form', - 'explode': False, - }) - + 'style': 'form', + 'explode': False, + } + ) + would reformat rest_framework_gis/filters.py --- rest_framework_gis/schema.py 2020-10-18 07:41:24.284564 +0000 +++ rest_framework_gis/schema.py 2020-10-18 07:42:12.594439 +0000 @@ -12,14 +12,11 @@ class GeoFeatureAutoSchema(AutoSchema): COORDINATES_SCHEMA_FOR_POINT = { 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float', - }, + 'items': {'type': 'number', 'format': 'float',}, 'example': [12.9721, 77.5933], 'minItems': 2, 'maxItems': 3, } @@ -30,75 +27,72 @@ 'minItems': 2, } GEO_FIELD_TO_SCHEMA = { models.PointField: { - 'type': { - 'type': 'string', - 'enum': ['Point'], - }, + 'type': {'type': 'string', 'enum': ['Point'],}, 'coordinates': COORDINATES_SCHEMA_FOR_POINT, }, models.LineStringField: { - 'type': { - 'type': 'string', - 'enum': ['LineString'], - }, + 'type': {'type': 'string', 'enum': ['LineString'],}, 'coordinates': COORDINATES_SCHEMA_FOR_LINE_STRING, }, models.PolygonField: { - 'type': { - 'type': 'string', - 'enum': ['Polygon'], - }, + 'type': {'type': 'string', 'enum': ['Polygon'],}, 'coordinates': { 'type': 'array', - 'items': { - **COORDINATES_SCHEMA_FOR_LINE_STRING, - 'minItems': 4, - }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - } - } + 'items': {**COORDINATES_SCHEMA_FOR_LINE_STRING, 'minItems': 4,}, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], + }, + }, } MULTI_FIELD_MAPPING = { models.PointField: models.MultiPointField, models.LineStringField: models.MultiLineStringField, - models.PolygonField: models.MultiPolygonField + models.PolygonField: models.MultiPolygonField, } for singular_field, multi_field in MULTI_FIELD_MAPPING.items(): GEO_FIELD_TO_SCHEMA[multi_field] = { - 'type': { - 'type': 'string', - 'enum': [multi_field.geom_class.__name__], - }, + 'type': {'type': 'string', 'enum': [multi_field.geom_class.__name__],}, 'coordinates': { 'type': 'array', 'items': GEO_FIELD_TO_SCHEMA[singular_field]['coordinates'], 'example': [ GEO_FIELD_TO_SCHEMA[singular_field]['coordinates']['example'] - ] - } + ], + }, } def _map_geo_field(self, serializer, geo_field_name): field = serializer.fields[geo_field_name] if isinstance(field, GeometrySerializerMethodField): warnings.warn( 'Geometry generation for GeometrySerializerMethodField is not supported.'.format( - field=field)) + field=field + ) + ) return {} model_field_name = geo_field_name - geo_field = model_meta.get_field_info(serializer.Meta.model).fields[model_field_name] + geo_field = model_meta.get_field_info(serializer.Meta.model).fields[ + model_field_name + ] try: return self.GEO_FIELD_TO_SCHEMA[geo_field.__class__] except KeyError: - warnings.warn('Geometry generation for {field} is not supported.'.format(field=field)) + warnings.warn( + 'Geometry generation for {field} is not supported.'.format(field=field) + ) return {} def map_field(self, field): if isinstance(field, GeoFeatureModelListSerializer): return self._map_geo_feature_model_list_serializer(field) @@ -107,36 +101,30 @@ def _map_geo_feature_model_list_serializer(self, serializer): return { 'type': 'object', 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, 'features': { 'type': 'array', - 'items': self._map_serializer(serializer.child) - } - } + 'items': self._map_serializer(serializer.child), + }, + }, } def _map_geo_feature_model_serializer(self, serializer): schema = super().map_serializer(serializer) geo_json_schema = { 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - } + 'properties': {'type': {'type': 'string', 'enum': ['Feature']},}, } if serializer.Meta.id_field: - geo_json_schema['properties']['id'] = schema['properties'].pop(serializer.Meta.id_field) + geo_json_schema['properties']['id'] = schema['properties'].pop( + serializer.Meta.id_field + ) geo_field = serializer.Meta.geo_field geo_json_schema['properties']['geometry'] = { 'type': 'object', 'properties': self._map_geo_field(serializer, geo_field), @@ -144,13 +132,11 @@ schema['properties'].pop(geo_field) if serializer.Meta.auto_bbox or serializer.Meta.bbox_geo_field: geo_json_schema['properties']['bbox'] = { 'type': 'array', - 'items': { - 'type': 'number' - }, + 'items': {'type': 'number'}, 'minItems': 4, 'maxItems': 4, 'example': [12.9721, 77.5933, 12.9721, 77.5933], } if serializer.Meta.bbox_geo_field in schema['properties']: would reformat rest_framework_gis/schema.py --- tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 07:41:24.284564 +0000 +++ tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 07:42:12.972881 +0000 @@ -12,76 +12,127 @@ operations = [ migrations.CreateModel( name='LineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.LineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.LineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiLineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiPointField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiPointField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), ('location', django.contrib.gis.db.models.fields.PointField(srid=4326)), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.PolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.PolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), ] would reformat tests/django_restframework_gis_tests/migrations/0003_schema_models.py --- tests/django_restframework_gis_tests/serializers.py 2020-10-18 07:41:24.284564 +0000 +++ tests/django_restframework_gis_tests/serializers.py 2020-10-18 07:42:13.039130 +0000 @@ -234,10 +234,13 @@ model = Nullable geo_field = 'geometry' fields = '__all__' -class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer(BoxedLocationGeoFeatureSerializer): +class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer( + BoxedLocationGeoFeatureSerializer +): class Meta(BoxedLocationGeoFeatureSerializer.Meta): - fields = BoxedLocationGeoFeatureSerializer.Meta.fields + \ - [BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field] - + fields = BoxedLocationGeoFeatureSerializer.Meta.fields + [ + BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field + ] + would reformat tests/django_restframework_gis_tests/serializers.py --- tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 07:41:24.284564 +0000 +++ tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 07:42:14.302890 +0000 @@ -38,11 +38,10 @@ view = generator.create_view(view_cls.as_view(), method, request) return view class TestSchemaGeneration(TestCase): - def test_point_field_outer_most_gis_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = PointSerializer path = '/' @@ -53,123 +52,104 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) content.pop('type', None) content['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', + self.assertEqual( + content, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] + 'properties': { + 'random_field1': {'type': 'string', 'maxLength': 32}, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 + 'required': ['random_field1', 'random_field2', 'location'], + }, + } + }, + ) + + def test_point_field_inner_geo_serializer(self): + class TestPointFieldView(RetrieveAPIView): + serializer_class = ChildPointSerializer + + path = '/' + method = 'GET' + + view = create_view(TestPointFieldView, 'POST', create_request('/')) + inspector = GeoFeatureAutoSchema() + inspector.view = view + serializer = inspector.get_serializer(path, method) + content = inspector.map_serializer(serializer) + content.pop('type', None) + content['properties']['point'].pop('type', None) + content['properties']['point']['properties']['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'point': { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, } } }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - }) - - def test_point_field_inner_geo_serializer(self): - class TestPointFieldView(RetrieveAPIView): - serializer_class = ChildPointSerializer - - path = '/' - method = 'GET' - - view = create_view(TestPointFieldView, 'POST', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - serializer = inspector.get_serializer(path, method) - content = inspector.map_serializer(serializer) - content.pop('type', None) - content['properties']['point'].pop('type', None) - content['properties']['point']['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'point': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, - 'required': [ - 'point' - ] - }) + 'required': ['point'], + }, + ) def test_point_field_inner_geo_list_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = ListChildPointSerializer @@ -181,74 +161,73 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) content.pop('type', None) content['properties']['points'].pop('type', None) - content['properties']['points']['properties']['features']['items']['properties']['properties'].pop( - 'type', None) - self.assertEqual(content, { - 'properties': { - 'points': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, - 'features': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] + content['properties']['points']['properties']['features']['items'][ + 'properties' + ]['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'points': { + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'features': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': { + 'type': 'string', + 'enum': ['Point'], + }, + 'coordinates': { + 'type': 'array', + 'items': { + 'type': 'number', + 'format': 'float', + }, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, + }, + }, + } } - } - }, - 'required': ['points'] - }) + }, + 'required': ['points'], + }, + ) def test_line_string_field(self): class TestLineStringFieldView(RetrieveAPIView): serializer_class = LineStringSerializer @@ -260,33 +239,30 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['LineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['LineString']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 + }, } - } - }) + }, + ) def test_multi_polygon(self): class TestMultiPolygonFieldView(RetrieveAPIView): serializer_class = MultiPolygonSerializer @@ -298,43 +274,52 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPolygon'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPolygon']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 4 + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], + 'minItems': 4, + }, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - }, - 'example': [ - [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - ] + 'example': [ + [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ] + ], + }, } - } - }) + }, + ) def test_multi_line_string_field(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiLineStringSerializer @@ -346,37 +331,34 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiLineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiLineString']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 - }, - 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]] + 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]], + }, } - } - }) + }, + ) def test_multi_point(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -388,32 +370,29 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPoint'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPoint']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[12.9721, 77.5933]] + 'example': [[12.9721, 77.5933]], + }, } - } - }) + }, + ) def check_bbox_schema(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -424,33 +403,31 @@ inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) def test_warning_for_geometry_serializer_method_field(self): class TestGeometrySerializerMethodField(RetrieveAPIView): serializer_class = GeometrySerializerMethodFieldSerializer path = '/' method = 'GET' - view = create_view(TestGeometrySerializerMethodField, 'POST', create_request('/')) + view = create_view( + TestGeometrySerializerMethodField, 'POST', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) with self.assertWarns(Warning): inspector.map_serializer(serializer) @@ -471,148 +448,152 @@ def test_schema_for_bbox_geo_field(self): path = '/' method = 'GET' - class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView(GeojsonBoxedLocationDetails): + class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView( + GeojsonBoxedLocationDetails + ): serializer_class = BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer - view = create_view(GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/')) + view = create_view( + GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertNotIn('bbox_geometry', content['properties']['properties']['properties']) - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertNotIn( + 'bbox_geometry', content['properties']['properties']['properties'] + ) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) class TestPaginationSchemaGeneration(TestCase): - def test_geo_json_pagination_schema(self): - generated_schema = GeoJsonPagination().get_paginated_response_schema(geojson_location_list) + generated_schema = GeoJsonPagination().get_paginated_response_schema( + geojson_location_list + ) self.assertIn('features', generated_schema['properties']) generated_schema['properties'].pop('features') - self.assertDictEqual(generated_schema, { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] + self.assertDictEqual( + generated_schema, + { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'count': {'type': 'integer', 'example': 123,}, + 'next': { + 'type': 'string', + 'nullable': True, + 'format': 'uri', + 'example': 'http://api.example.org/accounts/?page=4', + }, + 'previous': { + 'type': 'string', + 'nullable': True, + 'format': 'uri', + 'example': 'http://api.example.org/accounts/?page=2', + }, }, - 'count': { - 'type': 'integer', - 'example': 123, - }, - 'next': { - 'type': 'string', - 'nullable': True, - 'format': 'uri', - 'example': 'http://api.example.org/accounts/?page=4', - }, - 'previous': { - 'type': 'string', - 'nullable': True, - 'format': 'uri', - 'example': 'http://api.example.org/accounts/?page=2', - }, - }, - }) + }, + ) class TestRestFrameworkGisFiltersSchema(TestCase): - def test_in_BBox_filter_schema(self): path = '/' method = 'GET' - view = create_view(GeojsonLocationContainedInBBoxList, 'GET', create_request('/')) + view = create_view( + GeojsonLocationContainedInBBoxList, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view generated_schema = inspector.get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'in_bbox', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', - 'schema': { - 'type': 'array', - 'items': { - 'type': 'float' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [0, 0, 10, 10]}, - 'style': 'form', - 'explode': False - }) - - def test_in_TMS_filter_schema(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationContainedInTileList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector.get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'tile', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, - }) - - def test_distance_to_point_filter(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector.get_filter_parameters(path, method) - self.assertListEqual(generated_schema, [ - { - 'name': 'dist', + self.assertDictEqual( + generated_schema[0], + { + 'name': 'in_bbox', 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, - 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' - '***point*** is passed.' - }, - { - 'name': 'point', - 'required': False, - 'in': 'query', - 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, - 'minItems': 2, - 'maxItems': 2, - 'example': [0, 10] + 'items': {'type': 'float'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, - } - ]) - + }, + ) + + def test_in_TMS_filter_schema(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationContainedInTileList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector.get_filter_parameters(path, method) + self.assertDictEqual( + generated_schema[0], + { + 'name': 'tile', + 'required': False, + 'in': 'query', + 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', + 'schema': {'type': 'string', 'example': '12/56/34'}, + }, + ) + + def test_distance_to_point_filter(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector.get_filter_parameters(path, method) + self.assertListEqual( + generated_schema, + [ + { + 'name': 'dist', + 'required': False, + 'in': 'query', + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, + 'description': 'Represents **Distance** in **Distance to point** filter. Default value is used only if ' + '***point*** is passed.', + }, + { + 'name': 'point', + 'required': False, + 'in': 'query', + 'description': 'Point represented in **x,y** format. ' + 'Represents **point** in **Distance to point filter**', + 'schema': { + 'type': 'array', + 'items': {'type': 'float',}, + 'minItems': 2, + 'maxItems': 2, + 'example': [0, 10], + }, + 'style': 'form', + 'explode': False, + }, + ], + ) + would reformat tests/django_restframework_gis_tests/test_schema_generation.py Oh no! 💥 💔 💥 6 files would be reformatted, 24 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? ./rest_framework_gis/filters.py:255:111: E501 line too long (121 > 110 characters) ./rest_framework_gis/schema.py:89:17: F522 '...'.format(...) has unused named argument(s): field ./tests/django_restframework_gis_tests/serializers.py:7:1: F403 'from .models import *' used; unable to detect undefined names ./tests/django_restframework_gis_tests/serializers.py:170:17: F405 'PointModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:185:17: F405 'LineStringModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:192:17: F405 'PolygonModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:199:17: F405 'MultiPolygonModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:206:17: F405 'MultiLineStringModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:213:17: F405 'MultiPointModel' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/serializers.py:234:17: F405 'Nullable' may be undefined, or defined from star imports: .models ./tests/django_restframework_gis_tests/test_schema_generation.py:596:111: E501 line too long (120 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:17:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:29:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:41:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:53:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:65:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:77:111: E501 line too long (114 > 110 characters) ERROR: Flake8 check failed! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: add name to AUTHORS ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@638abd9e247fc26fe18a7401b4e8d4bdbe986a20#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.10 travis run-test-pre: PYTHONHASHSEED='4054218542' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:99: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn('Geometry generation for {field} is not supported.'.format(field=field)) .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.846s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 7c8d42f0-1115-11eb-bfd1-1f84b849c73d
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

10th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! --- rest_framework_gis/pagination.py 2020-10-18 07:52:20.461323 +0000 +++ rest_framework_gis/pagination.py 2020-10-18 07:53:10.249876 +0000 @@ -26,13 +26,10 @@ def get_paginated_response_schema(self, view): schema = super().get_paginated_response_schema(view) schema['properties']['features'] = schema['properties'].pop('results') schema['properties'] = { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, **schema['properties'], } return schema would reformat rest_framework_gis/pagination.py --- rest_framework_gis/filters.py 2020-10-18 07:52:20.461323 +0000 +++ rest_framework_gis/filters.py 2020-10-18 07:53:10.467441 +0000 @@ -89,16 +89,14 @@ 'required': False, 'in': 'query', 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 4, 'maxItems': 4, - 'example': [0, 0, 10, 10] + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, }, ] @@ -154,14 +152,11 @@ { 'name': self.tile_param, 'required': False, 'in': 'query', 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, + 'schema': {'type': 'string', 'example': '12/56/34'}, }, ] class DistanceToPointFilter(BaseFilterBackend): @@ -243,34 +238,36 @@ return queryset.filter( Q(**{'%s__%s' % (filter_field, geoDjango_filter): (point, dist)}) ) def get_schema_operation_parameters(self, view): - return [{'name': self.dist_param, - 'required': False, - 'in': 'query', - 'schema': {'type': 'number', - 'format': 'float', - 'default': 1000, - }, - 'description': f'Represents **Distance** in **Distance to point** filter. ' - f'Default value is used only if ***{self.point_param}*** is passed.'}, - {'name': self.point_param, - 'required': False, - 'in': 'query', - 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', - 'schema': {'type': 'array', - 'items': {'type': 'float', - }, - 'minItems': 2, - 'maxItems': 2, - 'example': [0, - 10]}, - 'style': 'form', - 'explode': False, - }] + return [ + { + 'name': self.dist_param, + 'required': False, + 'in': 'query', + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, + 'description': f'Represents **Distance** in **Distance to point** filter. ' + f'Default value is used only if ***{self.point_param}*** is passed.', + }, + { + 'name': self.point_param, + 'required': False, + 'in': 'query', + 'description': 'Point represented in **x,y** format. ' + 'Represents **point** in **Distance to point filter**', + 'schema': { + 'type': 'array', + 'items': {'type': 'float',}, + 'minItems': 2, + 'maxItems': 2, + 'example': [0, 10], + }, + 'style': 'form', + 'explode': False, + }, + ] class DistanceToPointOrderingFilter(DistanceToPointFilter): srid = 4326 order_param = 'order' @@ -294,25 +291,21 @@ else: return queryset.order_by(GeometryDistance(filter_field, point)) def get_schema_operation_parameters(self, view): params = super().get_schema_operation_parameters(view) - params.append({ - 'name': self.order_param, - 'required': False, - 'in': 'query', - 'description': '', - 'schema': { - 'type': 'enum', - 'items': { - 'type': 'string', - 'enum': [ - 'asc', - 'desc' - ] + params.append( + { + 'name': self.order_param, + 'required': False, + 'in': 'query', + 'description': '', + 'schema': { + 'type': 'enum', + 'items': {'type': 'string', 'enum': ['asc', 'desc']}, + 'example': 'desc', }, - 'example': 'desc' - }, - 'style': 'form', - 'explode': False, - }) - + 'style': 'form', + 'explode': False, + } + ) + would reformat rest_framework_gis/filters.py --- rest_framework_gis/schema.py 2020-10-18 07:52:20.461323 +0000 +++ rest_framework_gis/schema.py 2020-10-18 07:53:10.483909 +0000 @@ -12,14 +12,11 @@ class GeoFeatureAutoSchema(AutoSchema): COORDINATES_SCHEMA_FOR_POINT = { 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float', - }, + 'items': {'type': 'number', 'format': 'float',}, 'example': [12.9721, 77.5933], 'minItems': 2, 'maxItems': 3, } @@ -30,73 +27,70 @@ 'minItems': 2, } GEO_FIELD_TO_SCHEMA = { models.PointField: { - 'type': { - 'type': 'string', - 'enum': ['Point'], - }, + 'type': {'type': 'string', 'enum': ['Point'],}, 'coordinates': COORDINATES_SCHEMA_FOR_POINT, }, models.LineStringField: { - 'type': { - 'type': 'string', - 'enum': ['LineString'], - }, + 'type': {'type': 'string', 'enum': ['LineString'],}, 'coordinates': COORDINATES_SCHEMA_FOR_LINE_STRING, }, models.PolygonField: { - 'type': { - 'type': 'string', - 'enum': ['Polygon'], - }, + 'type': {'type': 'string', 'enum': ['Polygon'],}, 'coordinates': { 'type': 'array', - 'items': { - **COORDINATES_SCHEMA_FOR_LINE_STRING, - 'minItems': 4, - }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - } - } + 'items': {**COORDINATES_SCHEMA_FOR_LINE_STRING, 'minItems': 4,}, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], + }, + }, } MULTI_FIELD_MAPPING = { models.PointField: models.MultiPointField, models.LineStringField: models.MultiLineStringField, - models.PolygonField: models.MultiPolygonField + models.PolygonField: models.MultiPolygonField, } for singular_field, multi_field in MULTI_FIELD_MAPPING.items(): GEO_FIELD_TO_SCHEMA[multi_field] = { - 'type': { - 'type': 'string', - 'enum': [multi_field.geom_class.__name__], - }, + 'type': {'type': 'string', 'enum': [multi_field.geom_class.__name__],}, 'coordinates': { 'type': 'array', 'items': GEO_FIELD_TO_SCHEMA[singular_field]['coordinates'], 'example': [ GEO_FIELD_TO_SCHEMA[singular_field]['coordinates']['example'] - ] - } + ], + }, } def _map_geo_field(self, serializer, geo_field_name): field = serializer.fields[geo_field_name] if isinstance(field, GeometrySerializerMethodField): - warnings.warn('Geometry generation for GeometrySerializerMethodField is not supported.') + warnings.warn( + 'Geometry generation for GeometrySerializerMethodField is not supported.' + ) return {} model_field_name = geo_field_name - geo_field = model_meta.get_field_info(serializer.Meta.model).fields[model_field_name] + geo_field = model_meta.get_field_info(serializer.Meta.model).fields[ + model_field_name + ] try: return self.GEO_FIELD_TO_SCHEMA[geo_field.__class__] except KeyError: - warnings.warn('Geometry generation for {field} is not supported.'.format(field=field)) + warnings.warn( + 'Geometry generation for {field} is not supported.'.format(field=field) + ) return {} def map_field(self, field): if isinstance(field, GeoFeatureModelListSerializer): return self._map_geo_feature_model_list_serializer(field) @@ -105,36 +99,30 @@ def _map_geo_feature_model_list_serializer(self, serializer): return { 'type': 'object', 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, 'features': { 'type': 'array', - 'items': self._map_serializer(serializer.child) - } - } + 'items': self._map_serializer(serializer.child), + }, + }, } def _map_geo_feature_model_serializer(self, serializer): schema = super().map_serializer(serializer) geo_json_schema = { 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - } + 'properties': {'type': {'type': 'string', 'enum': ['Feature']},}, } if serializer.Meta.id_field: - geo_json_schema['properties']['id'] = schema['properties'].pop(serializer.Meta.id_field) + geo_json_schema['properties']['id'] = schema['properties'].pop( + serializer.Meta.id_field + ) geo_field = serializer.Meta.geo_field geo_json_schema['properties']['geometry'] = { 'type': 'object', 'properties': self._map_geo_field(serializer, geo_field), @@ -142,13 +130,11 @@ schema['properties'].pop(geo_field) if serializer.Meta.auto_bbox or serializer.Meta.bbox_geo_field: geo_json_schema['properties']['bbox'] = { 'type': 'array', - 'items': { - 'type': 'number' - }, + 'items': {'type': 'number'}, 'minItems': 4, 'maxItems': 4, 'example': [12.9721, 77.5933, 12.9721, 77.5933], } if serializer.Meta.bbox_geo_field in schema['properties']: would reformat rest_framework_gis/schema.py --- tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 07:52:20.461323 +0000 +++ tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 07:53:10.887474 +0000 @@ -12,76 +12,127 @@ operations = [ migrations.CreateModel( name='LineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.LineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.LineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiLineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiPointField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiPointField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), ('location', django.contrib.gis.db.models.fields.PointField(srid=4326)), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.PolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.PolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), ] would reformat tests/django_restframework_gis_tests/migrations/0003_schema_models.py --- tests/django_restframework_gis_tests/serializers.py 2020-10-18 07:52:20.465323 +0000 +++ tests/django_restframework_gis_tests/serializers.py 2020-10-18 07:53:10.945313 +0000 @@ -243,10 +243,13 @@ model = Nullable geo_field = 'geometry' fields = '__all__' -class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer(BoxedLocationGeoFeatureSerializer): +class BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer( + BoxedLocationGeoFeatureSerializer +): class Meta(BoxedLocationGeoFeatureSerializer.Meta): - fields = BoxedLocationGeoFeatureSerializer.Meta.fields + \ - [BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field] - + fields = BoxedLocationGeoFeatureSerializer.Meta.fields + [ + BoxedLocationGeoFeatureSerializer.Meta.bbox_geo_field + ] + would reformat tests/django_restframework_gis_tests/serializers.py --- tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 07:52:20.465323 +0000 +++ tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 07:53:12.223969 +0000 @@ -38,11 +38,10 @@ view = generator.create_view(view_cls.as_view(), method, request) return view class TestSchemaGeneration(TestCase): - def test_point_field_outer_most_gis_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = PointSerializer path = '/' @@ -53,123 +52,104 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) content.pop('type', None) content['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', + self.assertEqual( + content, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] + 'properties': { + 'random_field1': {'type': 'string', 'maxLength': 32}, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 + 'required': ['random_field1', 'random_field2', 'location'], + }, + } + }, + ) + + def test_point_field_inner_geo_serializer(self): + class TestPointFieldView(RetrieveAPIView): + serializer_class = ChildPointSerializer + + path = '/' + method = 'GET' + + view = create_view(TestPointFieldView, 'POST', create_request('/')) + inspector = GeoFeatureAutoSchema() + inspector.view = view + serializer = inspector.get_serializer(path, method) + content = inspector.map_serializer(serializer) + content.pop('type', None) + content['properties']['point'].pop('type', None) + content['properties']['point']['properties']['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'point': { + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Point']}, + 'coordinates': { + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, } } }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - }) - - def test_point_field_inner_geo_serializer(self): - class TestPointFieldView(RetrieveAPIView): - serializer_class = ChildPointSerializer - - path = '/' - method = 'GET' - - view = create_view(TestPointFieldView, 'POST', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - serializer = inspector.get_serializer(path, method) - content = inspector.map_serializer(serializer) - content.pop('type', None) - content['properties']['point'].pop('type', None) - content['properties']['point']['properties']['properties'].pop('type', None) - self.assertEqual(content, { - 'properties': { - 'point': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] - }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, - 'required': [ - 'point' - ] - }) + 'required': ['point'], + }, + ) def test_point_field_inner_geo_list_serializer(self): class TestPointFieldView(RetrieveAPIView): serializer_class = ListChildPointSerializer @@ -181,74 +161,73 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) content.pop('type', None) content['properties']['points'].pop('type', None) - content['properties']['points']['properties']['features']['items']['properties']['properties'].pop( - 'type', None) - self.assertEqual(content, { - 'properties': { - 'points': { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] - }, - 'features': { - 'type': 'array', - 'items': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Feature'] + content['properties']['points']['properties']['features']['items'][ + 'properties' + ]['properties'].pop('type', None) + self.assertEqual( + content, + { + 'properties': { + 'points': { + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'features': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['Feature']}, + 'id': {'type': 'integer', 'readOnly': True}, + 'geometry': { + 'type': 'object', + 'properties': { + 'type': { + 'type': 'string', + 'enum': ['Point'], + }, + 'coordinates': { + 'type': 'array', + 'items': { + 'type': 'number', + 'format': 'float', + }, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + }, + }, + 'properties': { + 'properties': { + 'random_field1': { + 'type': 'string', + 'maxLength': 32, + }, + 'random_field2': { + 'type': 'integer', + 'maximum': 2147483647, + 'minimum': -2147483648, + }, + }, + 'required': [ + 'random_field1', + 'random_field2', + 'location', + ], + }, }, - 'id': { - 'type': 'integer', - 'readOnly': True - }, - 'geometry': { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['Point'] - }, - 'coordinates': { - 'type': 'array', - 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - } - } - }, - 'properties': { - 'properties': { - 'random_field1': { - 'type': 'string', - 'maxLength': 32 - }, - 'random_field2': { - 'type': 'integer', - 'maximum': 2147483647, - 'minimum': -2147483648 - } - }, - 'required': ['random_field1', 'random_field2', 'location'] - } - } - } - }, + }, + }, + } } - } - }, - 'required': ['points'] - }) + }, + 'required': ['points'], + }, + ) def test_line_string_field(self): class TestLineStringFieldView(RetrieveAPIView): serializer_class = LineStringSerializer @@ -260,33 +239,30 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['LineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['LineString']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 + }, } - } - }) + }, + ) def test_multi_polygon(self): class TestMultiPolygonFieldView(RetrieveAPIView): serializer_class = MultiPolygonSerializer @@ -298,43 +274,52 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPolygon'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPolygon']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 4 + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], + 'minItems': 4, + }, + 'example': [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ], }, - 'example': [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - }, - 'example': [ - [[0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], [0.0, 0.0]] - ] + 'example': [ + [ + [0.0, 0.0], + [0.0, 50.0], + [50.0, 50.0], + [50.0, 0.0], + [0.0, 0.0], + ] + ], + }, } - } - }) + }, + ) def test_multi_line_string_field(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiLineStringSerializer @@ -346,37 +331,34 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiLineString'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiLineString']}, + 'coordinates': { 'type': 'array', 'items': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' - }, - 'example': [12.9721, 77.5933], + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, + }, + 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], 'minItems': 2, - 'maxItems': 3 }, - 'example': [[22.4707, 70.0577], [12.9721, 77.5933]], - 'minItems': 2 - }, - 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]] + 'example': [[[22.4707, 70.0577], [12.9721, 77.5933]]], + }, } - } - }) + }, + ) def test_multi_point(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -388,32 +370,29 @@ inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) geometry_schema = content['properties']['geometry'] geometry_schema.pop('type', None) - self.assertEqual(geometry_schema, { - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['MultiPoint'] - }, - 'coordinates': { - 'type': 'array', - 'items': { + self.assertEqual( + geometry_schema, + { + 'properties': { + 'type': {'type': 'string', 'enum': ['MultiPoint']}, + 'coordinates': { 'type': 'array', 'items': { - 'type': 'number', - 'format': 'float' + 'type': 'array', + 'items': {'type': 'number', 'format': 'float'}, + 'example': [12.9721, 77.5933], + 'minItems': 2, + 'maxItems': 3, }, - 'example': [12.9721, 77.5933], - 'minItems': 2, - 'maxItems': 3 - }, - 'example': [[12.9721, 77.5933]] + 'example': [[12.9721, 77.5933]], + }, } - } - }) + }, + ) def check_bbox_schema(self): class TestMultiLineStringFieldView(RetrieveAPIView): serializer_class = MultiPointSerializer @@ -424,33 +403,31 @@ inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) def test_warning_for_geometry_serializer_method_field(self): class TestGeometrySerializerMethodField(RetrieveAPIView): serializer_class = GeometrySerializerMethodFieldSerializer path = '/' method = 'GET' - view = create_view(TestGeometrySerializerMethodField, 'POST', create_request('/')) + view = create_view( + TestGeometrySerializerMethodField, 'POST', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) with self.assertWarns(Warning): inspector.map_serializer(serializer) @@ -471,148 +448,152 @@ def test_schema_for_bbox_geo_field(self): path = '/' method = 'GET' - class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView(GeojsonBoxedLocationDetails): + class GeojsonBoxedLocationDetailsWithBBoxGeoFieldView( + GeojsonBoxedLocationDetails + ): serializer_class = BoxedLocationGeoFeatureWithBBoxGeoFieldSerializer - view = create_view(GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/')) + view = create_view( + GeojsonBoxedLocationDetailsWithBBoxGeoFieldView, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view serializer = inspector.get_serializer(path, method) content = inspector.map_serializer(serializer) bbox_schema = content['properties']['bbox'] - self.assertNotIn('bbox_geometry', content['properties']['properties']['properties']) - self.assertEqual(bbox_schema, { - 'type': 'array', - 'items': { - 'type': 'number' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [ - 12.9721, - 77.5933, - 12.9721, - 77.5933 - ] - }) + self.assertNotIn( + 'bbox_geometry', content['properties']['properties']['properties'] + ) + self.assertEqual( + bbox_schema, + { + 'type': 'array', + 'items': {'type': 'number'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [12.9721, 77.5933, 12.9721, 77.5933], + }, + ) class TestPaginationSchemaGeneration(TestCase): - def test_geo_json_pagination_schema(self): - generated_schema = GeoJsonPagination().get_paginated_response_schema(geojson_location_list) + generated_schema = GeoJsonPagination().get_paginated_response_schema( + geojson_location_list + ) self.assertIn('features', generated_schema['properties']) generated_schema['properties'].pop('features') - self.assertDictEqual(generated_schema, { - 'type': 'object', - 'properties': { - 'type': { - 'type': 'string', - 'enum': ['FeatureCollection'] + self.assertDictEqual( + generated_schema, + { + 'type': 'object', + 'properties': { + 'type': {'type': 'string', 'enum': ['FeatureCollection']}, + 'count': {'type': 'integer', 'example': 123,}, + 'next': { + 'type': 'string', + 'nullable': True, + 'format': 'uri', + 'example': 'http://api.example.org/accounts/?page=4', + }, + 'previous': { + 'type': 'string', + 'nullable': True, + 'format': 'uri', + 'example': 'http://api.example.org/accounts/?page=2', + }, }, - 'count': { - 'type': 'integer', - 'example': 123, - }, - 'next': { - 'type': 'string', - 'nullable': True, - 'format': 'uri', - 'example': 'http://api.example.org/accounts/?page=4', - }, - 'previous': { - 'type': 'string', - 'nullable': True, - 'format': 'uri', - 'example': 'http://api.example.org/accounts/?page=2', - }, - }, - }) + }, + ) class TestRestFrameworkGisFiltersSchema(TestCase): - def test_in_BBox_filter_schema(self): path = '/' method = 'GET' - view = create_view(GeojsonLocationContainedInBBoxList, 'GET', create_request('/')) + view = create_view( + GeojsonLocationContainedInBBoxList, 'GET', create_request('/') + ) inspector = GeoFeatureAutoSchema() inspector.view = view generated_schema = inspector.get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'in_bbox', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', - 'schema': { - 'type': 'array', - 'items': { - 'type': 'float' - }, - 'minItems': 4, - 'maxItems': 4, - 'example': [0, 0, 10, 10]}, - 'style': 'form', - 'explode': False - }) - - def test_in_TMS_filter_schema(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationContainedInTileList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector.get_filter_parameters(path, method) - self.assertDictEqual(generated_schema[0], { - 'name': 'tile', - 'required': False, - 'in': 'query', - 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, - }) - - def test_distance_to_point_filter(self): - path = '/' - method = 'GET' - view = create_view(GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/')) - inspector = GeoFeatureAutoSchema() - inspector.view = view - generated_schema = inspector.get_filter_parameters(path, method) - self.assertListEqual(generated_schema, [ - { - 'name': 'dist', + self.assertDictEqual( + generated_schema[0], + { + 'name': 'in_bbox', 'required': False, 'in': 'query', - 'schema': { - 'type': 'number', - 'format': 'float', - 'default': 1000, - }, - 'description': 'Represents **Distance** in **Distance to point** filter. ' - 'Default value is used only if ***point*** is passed.' - }, - { - 'name': 'point', - 'required': False, - 'in': 'query', - 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', + 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, - 'minItems': 2, - 'maxItems': 2, - 'example': [0, 10] + 'items': {'type': 'float'}, + 'minItems': 4, + 'maxItems': 4, + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, - } - ]) - + }, + ) + + def test_in_TMS_filter_schema(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationContainedInTileList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector.get_filter_parameters(path, method) + self.assertDictEqual( + generated_schema[0], + { + 'name': 'tile', + 'required': False, + 'in': 'query', + 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', + 'schema': {'type': 'string', 'example': '12/56/34'}, + }, + ) + + def test_distance_to_point_filter(self): + path = '/' + method = 'GET' + view = create_view( + GeojsonLocationWithinDistanceOfPointList, 'GET', create_request('/') + ) + inspector = GeoFeatureAutoSchema() + inspector.view = view + generated_schema = inspector.get_filter_parameters(path, method) + self.assertListEqual( + generated_schema, + [ + { + 'name': 'dist', + 'required': False, + 'in': 'query', + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, + 'description': 'Represents **Distance** in **Distance to point** filter. ' + 'Default value is used only if ***point*** is passed.', + }, + { + 'name': 'point', + 'required': False, + 'in': 'query', + 'description': 'Point represented in **x,y** format. ' + 'Represents **point** in **Distance to point filter**', + 'schema': { + 'type': 'array', + 'items': {'type': 'float',}, + 'minItems': 2, + 'maxItems': 2, + 'example': [0, 10], + }, + 'style': 'form', + 'explode': False, + }, + ], + ) + would reformat tests/django_restframework_gis_tests/test_schema_generation.py Oh no! 💥 💔 💥 6 files would be reformatted, 24 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:17:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:29:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:41:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:53:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:65:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:77:111: E501 line too long (114 > 110 characters) ERROR: Flake8 check failed! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: fix linting issues ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@314db2821e3b6fb4068a64a0365fff1cab8845bb#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.10 travis run-test-pre: PYTHONHASHSEED='1425458394' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... ...../home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.904s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 04ac1ac0-1117-11eb-bfd1-1f84b849c73d
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

10th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! --- rest_framework_gis/filters.py 2020-10-18 08:09:00.456427 +0000 +++ rest_framework_gis/filters.py 2020-10-18 08:09:48.950379 +0000 @@ -89,16 +89,14 @@ 'required': False, 'in': 'query', 'description': 'Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat', 'schema': { 'type': 'array', - 'items': { - 'type': 'float', - }, + 'items': {'type': 'float',}, 'minItems': 4, 'maxItems': 4, - 'example': [0, 0, 10, 10] + 'example': [0, 0, 10, 10], }, 'style': 'form', 'explode': False, }, ] @@ -154,14 +152,11 @@ { 'name': self.tile_param, 'required': False, 'in': 'query', 'description': 'Specify a bounding box filter defined by a TMS tile address: tile=Z/X/Y', - 'schema': { - 'type': 'string', - 'example': '12/56/34' - }, + 'schema': {'type': 'string', 'example': '12/56/34'}, }, ] class DistanceToPointFilter(BaseFilterBackend): @@ -243,34 +238,36 @@ return queryset.filter( Q(**{'%s__%s' % (filter_field, geoDjango_filter): (point, dist)}) ) def get_schema_operation_parameters(self, view): - return [{'name': self.dist_param, - 'required': False, - 'in': 'query', - 'schema': {'type': 'number', - 'format': 'float', - 'default': 1000, - }, - 'description': f'Represents **Distance** in **Distance to point** filter. ' - f'Default value is used only if ***{self.point_param}*** is passed.'}, - {'name': self.point_param, - 'required': False, - 'in': 'query', - 'description': 'Point represented in **x,y** format. ' - 'Represents **point** in **Distance to point filter**', - 'schema': {'type': 'array', - 'items': {'type': 'float', - }, - 'minItems': 2, - 'maxItems': 2, - 'example': [0, - 10]}, - 'style': 'form', - 'explode': False, - }] + return [ + { + 'name': self.dist_param, + 'required': False, + 'in': 'query', + 'schema': {'type': 'number', 'format': 'float', 'default': 1000,}, + 'description': f'Represents **Distance** in **Distance to point** filter. ' + f'Default value is used only if ***{self.point_param}*** is passed.', + }, + { + 'name': self.point_param, + 'required': False, + 'in': 'query', + 'description': 'Point represented in **x,y** format. ' + 'Represents **point** in **Distance to point filter**', + 'schema': { + 'type': 'array', + 'items': {'type': 'float',}, + 'minItems': 2, + 'maxItems': 2, + 'example': [0, 10], + }, + 'style': 'form', + 'explode': False, + }, + ] class DistanceToPointOrderingFilter(DistanceToPointFilter): srid = 4326 order_param = 'order' @@ -294,25 +291,21 @@ else: return queryset.order_by(GeometryDistance(filter_field, point)) def get_schema_operation_parameters(self, view): params = super().get_schema_operation_parameters(view) - params.append({ - 'name': self.order_param, - 'required': False, - 'in': 'query', - 'description': '', - 'schema': { - 'type': 'enum', - 'items': { - 'type': 'string', - 'enum': [ - 'asc', - 'desc' - ] + params.append( + { + 'name': self.order_param, + 'required': False, + 'in': 'query', + 'description': '', + 'schema': { + 'type': 'enum', + 'items': {'type': 'string', 'enum': ['asc', 'desc']}, + 'example': 'desc', }, - 'example': 'desc' - }, - 'style': 'form', - 'explode': False, - }) - + 'style': 'form', + 'explode': False, + } + ) + would reformat rest_framework_gis/filters.py --- tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 08:09:00.456427 +0000 +++ tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 08:09:49.229700 +0000 @@ -12,76 +12,127 @@ operations = [ migrations.CreateModel( name='LineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.LineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.LineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiLineStringModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('points', django.contrib.gis.db.models.fields.MultiPointField(srid=4326)), + ( + 'points', + django.contrib.gis.db.models.fields.MultiPointField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='MultiPolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PointModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), ('location', django.contrib.gis.db.models.fields.PointField(srid=4326)), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), migrations.CreateModel( name='PolygonModel', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ( + 'id', + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name='ID', + ), + ), ('random_field1', models.CharField(max_length=32)), ('random_field2', models.IntegerField()), - ('polygon', django.contrib.gis.db.models.fields.PolygonField(srid=4326)), + ( + 'polygon', + django.contrib.gis.db.models.fields.PolygonField(srid=4326), + ), ], - options={ - 'abstract': False, - }, + options={'abstract': False,}, ), ] would reformat tests/django_restframework_gis_tests/migrations/0003_schema_models.py Oh no! 💥 💔 💥 2 files would be reformatted, 28 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? ./rest_framework_gis/schema.py:17:54: E231 missing whitespace after ',' ./rest_framework_gis/schema.py:32:57: E231 missing whitespace after ',' ./rest_framework_gis/schema.py:36:62: E231 missing whitespace after ',' ./rest_framework_gis/schema.py:40:59: E231 missing whitespace after ',' ./rest_framework_gis/schema.py:43:78: E231 missing whitespace after ',' ./rest_framework_gis/schema.py:63:81: E231 missing whitespace after ',' ./rest_framework_gis/schema.py:117:75: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/test_schema_generation.py:494:64: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/test_schema_generation.py:577:84: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/test_schema_generation.py:589:50: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:17:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:29:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:41:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:53:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:65:111: E501 line too long (114 > 110 characters) ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:77:111: E501 line too long (114 > 110 characters) ERROR: Flake8 check failed! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: fix linting issues using black ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@9bb32af23b143ebdfa0d68d4efa8eb8101df7846#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.10 travis run-test-pre: PYTHONHASHSEED='394155680' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.774s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 56d6e2b0-1119-11eb-bfd1-1f84b849c73d
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

10th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! --- rest_framework_gis/schema.py 2020-10-18 08:38:14.199345 +0000 +++ rest_framework_gis/schema.py 2020-10-18 08:39:05.183356 +0000 @@ -12,11 +12,11 @@ class GeoFeatureAutoSchema(AutoSchema): COORDINATES_SCHEMA_FOR_POINT = { "type": "array", - "items": {"type": "number", "format": "float", }, + "items": {"type": "number", "format": "float",}, "example": [12.9721, 77.5933], "minItems": 2, "maxItems": 3, } @@ -27,22 +27,22 @@ "minItems": 2, } GEO_FIELD_TO_SCHEMA = { models.PointField: { - "type": {"type": "string", "enum": ["Point"], }, + "type": {"type": "string", "enum": ["Point"],}, "coordinates": COORDINATES_SCHEMA_FOR_POINT, }, models.LineStringField: { - "type": {"type": "string", "enum": ["LineString"], }, + "type": {"type": "string", "enum": ["LineString"],}, "coordinates": COORDINATES_SCHEMA_FOR_LINE_STRING, }, models.PolygonField: { - "type": {"type": "string", "enum": ["Polygon"], }, + "type": {"type": "string", "enum": ["Polygon"],}, "coordinates": { "type": "array", - "items": {**COORDINATES_SCHEMA_FOR_LINE_STRING, "minItems": 4, }, + "items": {**COORDINATES_SCHEMA_FOR_LINE_STRING, "minItems": 4,}, "example": [ [0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], @@ -58,11 +58,11 @@ models.PolygonField: models.MultiPolygonField, } for singular_field, multi_field in MULTI_FIELD_MAPPING.items(): GEO_FIELD_TO_SCHEMA[multi_field] = { - "type": {"type": "string", "enum": [multi_field.geom_class.__name__], }, + "type": {"type": "string", "enum": [multi_field.geom_class.__name__],}, "coordinates": { "type": "array", "items": GEO_FIELD_TO_SCHEMA[singular_field]["coordinates"], "example": [ GEO_FIELD_TO_SCHEMA[singular_field]["coordinates"]["example"] @@ -112,11 +112,11 @@ def _map_geo_feature_model_serializer(self, serializer): schema = super().map_serializer(serializer) geo_json_schema = { "type": "object", - "properties": {"type": {"type": "string", "enum": ["Feature"]}, }, + "properties": {"type": {"type": "string", "enum": ["Feature"]},}, } if serializer.Meta.id_field: geo_json_schema["properties"]["id"] = schema["properties"].pop( serializer.Meta.id_field would reformat rest_framework_gis/schema.py Oh no! 💥 💔 💥 1 file would be reformatted, 29 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? ./rest_framework_gis/filters.py:94:46: E231 missing whitespace after ',' ./rest_framework_gis/filters.py:248:80: E231 missing whitespace after ',' ./rest_framework_gis/filters.py:260:46: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/test_schema_generation.py:494:64: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/test_schema_generation.py:577:84: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/test_schema_generation.py:589:50: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:33:39: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:54:39: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:75:39: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:96:39: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:114:39: E231 missing whitespace after ',' ./tests/django_restframework_gis_tests/migrations/0003_schema_models.py:135:39: E231 missing whitespace after ',' ERROR: Flake8 check failed! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: fix linting issues using black ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@54986ae77daa2293f8317482c9d33effe1d2a09e#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.10 travis run-test-pre: PYTHONHASHSEED='209761952' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.935s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 6e1d4d70-111d-11eb-bfd1-1f84b849c73d
dhaval-mehta commented 4 years ago

@nemesisdesign Please check the last run. All openwisp-qa-check errors are false positive.

TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

10th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! --- rest_framework_gis/schema.py 2020-10-18 08:48:17.128240 +0000 +++ rest_framework_gis/schema.py 2020-10-18 08:49:06.972880 +0000 @@ -12,11 +12,11 @@ class GeoFeatureAutoSchema(AutoSchema): COORDINATES_SCHEMA_FOR_POINT = { "type": "array", - "items": {"type": "number", "format": "float", }, + "items": {"type": "number", "format": "float",}, "example": [12.9721, 77.5933], "minItems": 2, "maxItems": 3, } @@ -27,22 +27,22 @@ "minItems": 2, } GEO_FIELD_TO_SCHEMA = { models.PointField: { - "type": {"type": "string", "enum": ["Point"], }, + "type": {"type": "string", "enum": ["Point"],}, "coordinates": COORDINATES_SCHEMA_FOR_POINT, }, models.LineStringField: { - "type": {"type": "string", "enum": ["LineString"], }, + "type": {"type": "string", "enum": ["LineString"],}, "coordinates": COORDINATES_SCHEMA_FOR_LINE_STRING, }, models.PolygonField: { - "type": {"type": "string", "enum": ["Polygon"], }, + "type": {"type": "string", "enum": ["Polygon"],}, "coordinates": { "type": "array", - "items": {**COORDINATES_SCHEMA_FOR_LINE_STRING, "minItems": 4, }, + "items": {**COORDINATES_SCHEMA_FOR_LINE_STRING, "minItems": 4,}, "example": [ [0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], @@ -58,11 +58,11 @@ models.PolygonField: models.MultiPolygonField, } for singular_field, multi_field in MULTI_FIELD_MAPPING.items(): GEO_FIELD_TO_SCHEMA[multi_field] = { - "type": {"type": "string", "enum": [multi_field.geom_class.__name__], }, + "type": {"type": "string", "enum": [multi_field.geom_class.__name__],}, "coordinates": { "type": "array", "items": GEO_FIELD_TO_SCHEMA[singular_field]["coordinates"], "example": [ GEO_FIELD_TO_SCHEMA[singular_field]["coordinates"]["example"] @@ -112,11 +112,11 @@ def _map_geo_feature_model_serializer(self, serializer): schema = super().map_serializer(serializer) geo_json_schema = { "type": "object", - "properties": {"type": {"type": "string", "enum": ["Feature"]}, }, + "properties": {"type": {"type": "string", "enum": ["Feature"]},}, } if serializer.Meta.id_field: geo_json_schema["properties"]["id"] = schema["properties"].pop( serializer.Meta.id_field would reformat rest_framework_gis/schema.py --- rest_framework_gis/filters.py 2020-10-18 08:48:17.128240 +0000 +++ rest_framework_gis/filters.py 2020-10-18 08:49:06.984139 +0000 @@ -89,11 +89,11 @@ "required": False, "in": "query", "description": "Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat", "schema": { "type": "array", - "items": {"type": "float", }, + "items": {"type": "float",}, "minItems": 4, "maxItems": 4, "example": [0, 0, 10, 10], }, "style": "form", @@ -243,11 +243,11 @@ return [ { "name": self.dist_param, "required": False, "in": "query", - "schema": {"type": "number", "format": "float", "default": 1000, }, + "schema": {"type": "number", "format": "float", "default": 1000,}, "description": f"Represents **Distance** in **Distance to point** filter. " f"Default value is used only if ***{self.point_param}*** is passed.", }, { "name": self.point_param, @@ -255,11 +255,11 @@ "in": "query", "description": "Point represented in **x,y** format. " "Represents **point** in **Distance to point filter**", "schema": { "type": "array", - "items": {"type": "float", }, + "items": {"type": "float",}, "minItems": 2, "maxItems": 2, "example": [0, 10], }, "style": "form", would reformat rest_framework_gis/filters.py --- tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 08:48:17.128240 +0000 +++ tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-18 08:49:07.362843 +0000 @@ -27,11 +27,11 @@ ( "points", django.contrib.gis.db.models.fields.LineStringField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="MultiLineStringModel", fields=[ ( @@ -48,11 +48,11 @@ ( "points", django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="MultiPointModel", fields=[ ( @@ -69,11 +69,11 @@ ( "points", django.contrib.gis.db.models.fields.MultiPointField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="MultiPolygonModel", fields=[ ( @@ -90,11 +90,11 @@ ( "polygon", django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="PointModel", fields=[ ( @@ -108,11 +108,11 @@ ), ("random_field1", models.CharField(max_length=32)), ("random_field2", models.IntegerField()), ("location", django.contrib.gis.db.models.fields.PointField(srid=4326)), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="PolygonModel", fields=[ ( @@ -129,9 +129,9 @@ ( "polygon", django.contrib.gis.db.models.fields.PolygonField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), ] would reformat tests/django_restframework_gis_tests/migrations/0003_schema_models.py --- tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 08:48:17.128240 +0000 +++ tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-18 08:49:08.694555 +0000 @@ -489,11 +489,11 @@ generated_schema, { "type": "object", "properties": { "type": {"type": "string", "enum": ["FeatureCollection"]}, - "count": {"type": "integer", "example": 123, }, + "count": {"type": "integer", "example": 123,}, "next": { "type": "string", "nullable": True, "format": "uri", "example": "http://api.example.org/accounts/?page=4", @@ -572,23 +572,23 @@ [ { "name": "dist", "required": False, "in": "query", - "schema": {"type": "number", "format": "float", "default": 1000, }, + "schema": {"type": "number", "format": "float", "default": 1000,}, "description": "Represents **Distance** in **Distance to point** filter. " - "Default value is used only if ***point*** is passed.", + "Default value is used only if ***point*** is passed.", }, { "name": "point", "required": False, "in": "query", "description": "Point represented in **x,y** format. " - "Represents **point** in **Distance to point filter**", + "Represents **point** in **Distance to point filter**", "schema": { "type": "array", - "items": {"type": "float", }, + "items": {"type": "float",}, "minItems": 2, "maxItems": 2, "example": [0, 10], }, "style": "form", would reformat tests/django_restframework_gis_tests/test_schema_generation.py Oh no! 💥 💔 💥 4 files would be reformatted, 26 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? SUCCESS: Flake8 check successful! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: fix linting issues using black ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@aedc912bedda8cc50903768f94bede3f9135a6d3#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.10 travis run-test-pre: PYTHONHASHSEED='467348817' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.916s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: d58ed1d0-111e-11eb-bfd1-1f84b849c73d
nemesifier commented 4 years ago

dhaval-mehta, try running: openwisp-qa-format, I've taken the chance to update the README about this: https://github.com/openwisp/django-rest-framework-gis#running-qa-checks

dhaval-mehta commented 4 years ago

@nemesisdesign In first screenshot openwisp-qa-check suggests removing empty space after the comma. If I do so, flake8 gives me suggestions to add empty space after the comma. The second screenshot describes the suggestions given by flake8.

As per my initial impressions, this is happening only for dictionaries defined in a single line.

Screenshot 2020-10-18 at 8 49 21 PM Screenshot 2020-10-18 at 8 51 36 PM
nemesifier commented 4 years ago

@dhaval-mehta in these cases a manual correction is needed. Will try to help asap. I should be able to edit the file from the github interface.

What about the rest of the implementation? Anyone has any feedback for @dhaval-mehta?

dhaval-mehta commented 4 years ago

@dhaval-mehta in these cases a manual correction is needed. Will try to help asap. I should be able to edit the file from the github interface.

What about the rest of the implementation? Anyone has any feedback for @dhaval-mehta?

It is a bug at the black end. There is also one solution. Let me try. Ref: https://github.com/psf/black/issues/1289

TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

8th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! --- rest_framework_gis/schema.py 2020-10-19 19:14:54.418356 +0000 +++ rest_framework_gis/schema.py 2020-10-19 19:15:45.338330 +0000 @@ -12,11 +12,11 @@ class GeoFeatureAutoSchema(AutoSchema): COORDINATES_SCHEMA_FOR_POINT = { "type": "array", - "items": {"type": "number", "format": "float", }, + "items": {"type": "number", "format": "float",}, "example": [12.9721, 77.5933], "minItems": 2, "maxItems": 3, } @@ -27,22 +27,22 @@ "minItems": 2, } GEO_FIELD_TO_SCHEMA = { models.PointField: { - "type": {"type": "string", "enum": ["Point"], }, + "type": {"type": "string", "enum": ["Point"],}, "coordinates": COORDINATES_SCHEMA_FOR_POINT, }, models.LineStringField: { - "type": {"type": "string", "enum": ["LineString"], }, + "type": {"type": "string", "enum": ["LineString"],}, "coordinates": COORDINATES_SCHEMA_FOR_LINE_STRING, }, models.PolygonField: { - "type": {"type": "string", "enum": ["Polygon"], }, + "type": {"type": "string", "enum": ["Polygon"],}, "coordinates": { "type": "array", - "items": {**COORDINATES_SCHEMA_FOR_LINE_STRING, "minItems": 4, }, + "items": {**COORDINATES_SCHEMA_FOR_LINE_STRING, "minItems": 4,}, "example": [ [0.0, 0.0], [0.0, 50.0], [50.0, 50.0], [50.0, 0.0], @@ -58,11 +58,11 @@ models.PolygonField: models.MultiPolygonField, } for singular_field, multi_field in MULTI_FIELD_MAPPING.items(): GEO_FIELD_TO_SCHEMA[multi_field] = { - "type": {"type": "string", "enum": [multi_field.geom_class.__name__], }, + "type": {"type": "string", "enum": [multi_field.geom_class.__name__],}, "coordinates": { "type": "array", "items": GEO_FIELD_TO_SCHEMA[singular_field]["coordinates"], "example": [ GEO_FIELD_TO_SCHEMA[singular_field]["coordinates"]["example"] @@ -112,11 +112,11 @@ def _map_geo_feature_model_serializer(self, serializer): schema = super().map_serializer(serializer) geo_json_schema = { "type": "object", - "properties": {"type": {"type": "string", "enum": ["Feature"]}, }, + "properties": {"type": {"type": "string", "enum": ["Feature"]},}, } if serializer.Meta.id_field: geo_json_schema["properties"]["id"] = schema["properties"].pop( serializer.Meta.id_field would reformat rest_framework_gis/schema.py --- rest_framework_gis/filters.py 2020-10-19 19:14:54.418356 +0000 +++ rest_framework_gis/filters.py 2020-10-19 19:15:45.355028 +0000 @@ -89,11 +89,11 @@ "required": False, "in": "query", "description": "Specify a bounding box as filter: in_bbox=min_lon,min_lat,max_lon,max_lat", "schema": { "type": "array", - "items": {"type": "float", }, + "items": {"type": "float",}, "minItems": 4, "maxItems": 4, "example": [0, 0, 10, 10], }, "style": "form", @@ -243,11 +243,11 @@ return [ { "name": self.dist_param, "required": False, "in": "query", - "schema": {"type": "number", "format": "float", "default": 1000, }, + "schema": {"type": "number", "format": "float", "default": 1000,}, "description": f"Represents **Distance** in **Distance to point** filter. " f"Default value is used only if ***{self.point_param}*** is passed.", }, { "name": self.point_param, @@ -255,11 +255,11 @@ "in": "query", "description": "Point represented in **x,y** format. " "Represents **point** in **Distance to point filter**", "schema": { "type": "array", - "items": {"type": "float", }, + "items": {"type": "float",}, "minItems": 2, "maxItems": 2, "example": [0, 10], }, "style": "form", would reformat rest_framework_gis/filters.py --- tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-19 19:14:54.418356 +0000 +++ tests/django_restframework_gis_tests/migrations/0003_schema_models.py 2020-10-19 19:15:45.752804 +0000 @@ -27,11 +27,11 @@ ( "points", django.contrib.gis.db.models.fields.LineStringField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="MultiLineStringModel", fields=[ ( @@ -48,11 +48,11 @@ ( "points", django.contrib.gis.db.models.fields.MultiLineStringField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="MultiPointModel", fields=[ ( @@ -69,11 +69,11 @@ ( "points", django.contrib.gis.db.models.fields.MultiPointField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="MultiPolygonModel", fields=[ ( @@ -90,11 +90,11 @@ ( "polygon", django.contrib.gis.db.models.fields.MultiPolygonField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="PointModel", fields=[ ( @@ -108,11 +108,11 @@ ), ("random_field1", models.CharField(max_length=32)), ("random_field2", models.IntegerField()), ("location", django.contrib.gis.db.models.fields.PointField(srid=4326)), ], - options={"abstract": False, }, + options={"abstract": False,}, ), migrations.CreateModel( name="PolygonModel", fields=[ ( @@ -129,9 +129,9 @@ ( "polygon", django.contrib.gis.db.models.fields.PolygonField(srid=4326), ), ], - options={"abstract": False, }, + options={"abstract": False,}, ), ] would reformat tests/django_restframework_gis_tests/migrations/0003_schema_models.py --- tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-19 19:14:54.418356 +0000 +++ tests/django_restframework_gis_tests/test_schema_generation.py 2020-10-19 19:15:47.104046 +0000 @@ -574,18 +574,18 @@ "name": "dist", "required": False, "in": "query", "schema": {"type": "number", "format": "float", "default": 1000}, "description": "Represents **Distance** in **Distance to point** filter. " - "Default value is used only if ***point*** is passed.", + "Default value is used only if ***point*** is passed.", }, { "name": "point", "required": False, "in": "query", "description": "Point represented in **x,y** format. " - "Represents **point** in **Distance to point filter**", + "Represents **point** in **Distance to point filter**", "schema": { "type": "array", "items": {"type": "float"}, "minItems": 2, "maxItems": 2, would reformat tests/django_restframework_gis_tests/test_schema_generation.py Oh no! 💥 💔 💥 4 files would be reformatted, 26 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? SUCCESS: Flake8 check successful! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: try to fix conflicts between black and flake8 ERROR: Commit message check failed! travis_time:end:1cd24264:start=1603134944359038517,finish=1603134948365425319,duration=4006386802,event=script ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@a56748ec3864875c44a0b57da18755b9633733ac#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,importlib-metadata==2.0.0,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11,zipp==3.3.1 travis run-test-pre: PYTHONHASHSEED='2844251201' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:90: UserWarning: Geometry generation for GeometryField() is not supported. "Geometry generation for {field} is not supported.".format(field=field) .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.7/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.868s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed travis_time:end:0b4579de:start=1603134948370565861,finish=1603134963528405508,duration=15157839647,event=script ```

10th Build

View build log

./run-qa-checks ``` fatal: bad object 399c905777d1132b2bc4877b24ff99059837ee29 SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! All done! ✨ 🍰 ✨ 30 files would be left unchanged. SUCCESS: Black check successful! SUCCESS: Flake8 check successful! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: Merge e50b08e2627e6f21ec04cfe6cc59eb2511deb604 into 624973e7013a44ad05dde5b40a455d4c4d4b8261 ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@bb813232d3fa8eae48552157a4c7b3632c238da7#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11 travis run-test-pre: PYTHONHASHSEED='2514630189' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.827s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 24c96f40-1240-11eb-af4f-e3a6e0ba4ce0
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

10th Build

View build log

./run-qa-checks ``` fatal: bad object e50b08e2627e6f21ec04cfe6cc59eb2511deb604 SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! All done! ✨ 🍰 ✨ 30 files would be left unchanged. SUCCESS: Black check successful! SUCCESS: Flake8 check successful! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: Merge b381ddaaa5bf4d9ae261b7446aed6c42c0bc1c67 into 624973e7013a44ad05dde5b40a455d4c4d4b8261 ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@48979f1b78e9d1f51b0b00398bea20264e53c7f5#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11 travis run-test-pre: PYTHONHASHSEED='1344751481' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.784s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 8bbaee30-1241-11eb-af4f-e3a6e0ba4ce0
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

10th Build

View build log

./run-qa-checks ``` fatal: bad object b381ddaaa5bf4d9ae261b7446aed6c42c0bc1c67 SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! All done! ✨ 🍰 ✨ 30 files would be left unchanged. SUCCESS: Black check successful! SUCCESS: Flake8 check successful! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: Merge 6ae39318a2c2f62d8d7a63edbcb3ee1621fa1d64 into 624973e7013a44ad05dde5b40a455d4c4d4b8261 ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@b4eaba7dfe602d7f3d02e15f29606efc4fde88aa#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11 travis run-test-pre: PYTHONHASHSEED='1072777130' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.910s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 5a4e1eb0-1243-11eb-af4f-e3a6e0ba4ce0
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

6th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! All done! ✨ 🍰 ✨ 30 files would be left unchanged. SUCCESS: Black check successful! SUCCESS: Flake8 check successful! Your commit message does not follow our commit message style guidelines: - please add a capital letter after the prefix Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: [fix] conflicts between black and flake8 ERROR: Commit message check failed! travis_time:end:16ff3700:start=1603136835832644795,finish=1603136839571336870,duration=3738692075,event=script ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@b4eaba7dfe602d7f3d02e15f29606efc4fde88aa#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,importlib-metadata==2.0.0,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11,zipp==3.3.1 travis run-test-pre: PYTHONHASHSEED='3170879178' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:90: UserWarning: Geometry generation for GeometryField() is not supported. "Geometry generation for {field} is not supported.".format(field=field) .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.7/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.963s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed travis_time:end:1a8e5e23:start=1603136839576906793,finish=1603136855438867589,duration=15861960796,event=script ```

10th Build

View build log

./run-qa-checks ``` fatal: bad object 6ae39318a2c2f62d8d7a63edbcb3ee1621fa1d64 SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! All done! ✨ 🍰 ✨ 30 files would be left unchanged. SUCCESS: Black check successful! SUCCESS: Flake8 check successful! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: Merge 1aefe4618b003871a4a1770427a7258defbabd3b into 624973e7013a44ad05dde5b40a455d4c4d4b8261 ERROR: Commit message check failed! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@89832d573e4a53c430f8b551f4bc278dd4251a85#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11 travis run-test-pre: PYTHONHASHSEED='3503633979' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.720s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 7606b800-1244-11eb-af4f-e3a6e0ba4ce0
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

10th Build

View build log

tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: djangorestframework~=3.12, -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@89832d573e4a53c430f8b551f4bc278dd4251a85#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pytz==2020.1,regex==2020.10.15,requests==2.24.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11 travis run-test-pre: PYTHONHASHSEED='2017258315' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......s......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ---------------------------------------------------------------------- Ran 90 tests in 0.895s OK (skipped=2) Destroying test database for alias 'default'... free(): invalid pointer ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code -6 (SIGABRT)) (exited with code -6) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 0b4c69e0-1246-11eb-af4f-e3a6e0ba4ce0
TravisBuddy commented 4 years ago

Hey @dhaval-mehta, Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: fe781d10-16ad-11eb-a761-09290313622d
TravisBuddy commented 4 years ago

Hey @dhaval-mehta, Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 018826c0-16af-11eb-a761-09290313622d
TravisBuddy commented 4 years ago

Hey @dhaval-mehta, Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: faa020c0-16b2-11eb-a761-09290313622d
TravisBuddy commented 4 years ago

Hey @dhaval-mehta, Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: 48567790-16b5-11eb-a761-09290313622d
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

3rd Build

View build log

./run-qa-checks ``` fatal: bad object e9dd5534030a7c02560b1513e55d40b8c35d6389 SUCCESS: Blank endline check successful! Skipped 1 files SUCCESS: Isort check successful! All done! ✨ 🍰 ✨ 30 files would be left unchanged. SUCCESS: Black check successful! SUCCESS: Flake8 check successful! Your commit message does not follow our commit message style guidelines: - missing prefix in the commit short description Eg: "[feature/fix/change] Action performed" Please read our guidelines at: http://openwisp.io/docs/developer/contributing.html#commit-message-style-guidelines Checked commit message: Merge af74caf26f938edf307eae4113ee934c59fa0772 into 624973e7013a44ad05dde5b40a455d4c4d4b8261 ERROR: Commit message check failed! ```
TravisBuddy Request Identifier: e4461830-16b6-11eb-a761-09290313622d
TravisBuddy commented 4 years ago

Hey @dhaval-mehta, Something went wrong with the build.

TravisCI finished with status errored, which means the build failed because of something unrelated to the tests, such as a problem with a dependency or the build process itself.

View build log

TravisBuddy Request Identifier: af150a30-16b7-11eb-a761-09290313622d
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

8th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:before 2020-10-25 14:58:21.772999 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:after 2020-10-25 14:58:48.231581 @@ -22,7 +22,6 @@ MultiPolygonSerializer, PointSerializer, ) - from .views import ( GeojsonBoxedLocationDetails, GeojsonLocationContainedInBBoxList, Skipped 1 files ERROR: Isort check failed! Hint: did you forget running openwisp-qa-format? --- tests/django_restframework_gis_tests/test_filters.py 2020-10-25 14:58:21.768998 +0000 +++ tests/django_restframework_gis_tests/test_filters.py 2020-10-25 14:58:49.759217 +0000 @@ -23,10 +23,11 @@ == 'django.contrib.gis.db.backends.spatialite' ) try: from django.contrib.gis.db.models.functions import GeometryDistance + has_geometry_distance = True except ImportError: has_geometry_distance = False would reformat tests/django_restframework_gis_tests/test_filters.py Oh no! 💥 💔 💥 1 file would be reformatted, 29 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? ./tests/django_restframework_gis_tests/test_filters.py:27:5: F401 'django.contrib.gis.db.models.functions.GeometryDistance' imported but unused ./tests/django_restframework_gis_tests/tests.py:18:1: F401 'rest_framework' imported but unused ERROR: Flake8 check failed! SUCCESS: Commit message check successful! travis_time:end:389228f8:start=1603637927901650419,finish=1603637931568538643,duration=3666888224,event=script ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@e4781bd74da0086435e51e3caccb94b9fbd0ea6e#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,importlib-metadata==2.0.0,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,packaging==20.4,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pyparsing==2.4.7,pytz==2020.1,regex==2020.10.23,requests==2.24.0,six==1.15.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11,zipp==3.3.2 travis run-test-pre: PYTHONHASHSEED='2602799870' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:90: UserWarning: Geometry generation for GeometryField() is not supported. "Geometry generation for {field} is not supported.".format(field=field) .......F......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.7/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ====================================================================== FAIL: test_geojson_HTML_widget_value (django_restframework_gis_tests.tests.TestRestFrameworkGis) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/tests.py", line 530, in test_geojson_HTML_widget_value self.assertContains(response, '"type": "Point"') File "/home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.7/site-packages/django/test/testcases.py", line 470, in assertContains self.assertTrue(real_count != 0, msg_prefix + "Couldn't find %s in response" % text_repr) AssertionError: False is not true : Couldn't find '"type": "Point"' in response ---------------------------------------------------------------------- Ran 90 tests in 0.791s FAILED (failures=1, skipped=1) Destroying test database for alias 'default'... ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code 1) ___________________________________ summary ____________________________________ ERROR: travis: commands failed travis_time:end:00e92072:start=1603637931573290128,finish=1603637946501044381,duration=14927754253,event=script ```

10th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:before 2020-10-25 15:01:46.803142 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:after 2020-10-25 15:02:14.681485 @@ -22,7 +22,6 @@ MultiPolygonSerializer, PointSerializer, ) - from .views import ( GeojsonBoxedLocationDetails, GeojsonLocationContainedInBBoxList, Skipped 1 files ERROR: Isort check failed! Hint: did you forget running openwisp-qa-format? --- tests/django_restframework_gis_tests/test_filters.py 2020-10-25 15:01:46.803142 +0000 +++ tests/django_restframework_gis_tests/test_filters.py 2020-10-25 15:02:16.205201 +0000 @@ -23,10 +23,11 @@ == 'django.contrib.gis.db.backends.spatialite' ) try: from django.contrib.gis.db.models.functions import GeometryDistance + has_geometry_distance = GeometryDistance and True except ImportError: has_geometry_distance = False would reformat tests/django_restframework_gis_tests/test_filters.py Oh no! 💥 💔 💥 1 file would be reformatted, 29 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? SUCCESS: Flake8 check successful! SUCCESS: Commit message check successful! ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@9dd28acd7a7f126fa16dc4490d6687415fc19444#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,packaging==20.4,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pyparsing==2.4.7,pytz==2020.1,regex==2020.10.23,requests==2.24.0,six==1.15.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11 travis run-test-pre: PYTHONHASHSEED='2693023024' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......F......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ====================================================================== FAIL: test_geojson_HTML_widget_value (django_restframework_gis_tests.tests.TestRestFrameworkGis) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/tests.py", line 529, in test_geojson_HTML_widget_value self.assertContains(response, '"type": "Point"') File "/home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/django/test/testcases.py", line 470, in assertContains self.assertTrue(real_count != 0, msg_prefix + "Couldn't find %s in response" % text_repr) AssertionError: False is not true : Couldn't find '"type": "Point"' in response ---------------------------------------------------------------------- Ran 90 tests in 0.868s FAILED (failures=1, skipped=1) Destroying test database for alias 'default'... ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code 1) ___________________________________ summary ____________________________________ ERROR: travis: commands failed ```
TravisBuddy Request Identifier: 1e2f02c0-16d3-11eb-a761-09290313622d
TravisBuddy commented 4 years ago

Travis tests have failed

Hey @dhaval-mehta, Please read the following log in order to understand the failure reason. It'll be awesome if you fix what's wrong and commit the changes.

8th Build

View build log

./run-qa-checks ``` SUCCESS: Blank endline check successful! ERROR: /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py Imports are incorrectly sorted and/or formatted. --- /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:before 2020-10-25 15:11:45.404001 +++ /home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/test_schema_generation.py:after 2020-10-25 15:12:23.639082 @@ -22,7 +22,6 @@ MultiPolygonSerializer, PointSerializer, ) - from .views import ( GeojsonBoxedLocationDetails, GeojsonLocationContainedInBBoxList, Skipped 1 files ERROR: Isort check failed! Hint: did you forget running openwisp-qa-format? --- tests/django_restframework_gis_tests/test_filters.py 2020-10-25 15:11:45.404001 +0000 +++ tests/django_restframework_gis_tests/test_filters.py 2020-10-25 15:12:25.165305 +0000 @@ -23,10 +23,11 @@ == 'django.contrib.gis.db.backends.spatialite' ) try: from django.contrib.gis.db.models.functions import GeometryDistance + has_geometry_distance = GeometryDistance and True except ImportError: has_geometry_distance = False would reformat tests/django_restframework_gis_tests/test_filters.py Oh no! 💥 💔 💥 1 file would be reformatted, 29 files would be left unchanged. ERROR: Black check failed! Hint: did you forget running openwisp-qa-format? SUCCESS: Flake8 check successful! SUCCESS: Commit message check successful! travis_time:end:003f45ee:start=1603638743315097932,finish=1603638746897726339,duration=3582628407,event=script ```
tox -e travis ``` travis create: /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis travis installdeps: -rrequirements-test.txt travis develop-inst: /home/travis/build/openwisp/django-rest-framework-gis travis installed: appdirs==1.4.4,asgiref==3.2.10,attrs==20.2.0,black==19.10b0,certifi==2020.6.20,chardet==3.0.4,click==7.1.2,contexttimer==0.3.3,coverage==5.3,coveralls==2.1.2,Django==3.1.2,django-filter==2.4.0,django-model-utils==4.0.0,djangorestframework==3.12.1,-e git+https://github.com/openwisp/django-rest-framework-gis.git@9dd28acd7a7f126fa16dc4490d6687415fc19444#egg=djangorestframework_gis,docopt==0.6.2,flake8==3.8.4,idna==2.10,isort==5.6.4,mccabe==0.6.1,openwisp-utils==0.6.3,packaging==20.4,pathspec==0.8.0,psycopg2==2.8.6,pycodestyle==2.6.0,pyflakes==2.2.0,pyparsing==2.4.7,pytz==2020.1,regex==2020.10.23,requests==2.24.0,six==1.15.0,sqlparse==0.4.1,toml==0.10.1,typed-ast==1.4.1,urllib3==1.25.11 travis run-test-pre: PYTHONHASHSEED='82362267' travis run-test: commands[0] | coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests Creating test database for alias 'default'... System check identified no issues (0 silenced). ..........................s..................../home/travis/build/openwisp/django-rest-framework-gis/rest_framework_gis/schema.py:89: UserWarning: Geometry generation for GeometryField() is not supported. warnings.warn( .......F......./home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/rest_framework/pagination.py:200: UnorderedObjectListWarning: Pagination may yield inconsistent results with an unordered object_list: QuerySet. paginator = self.django_paginator_class(queryset, page_size) ............................ ====================================================================== FAIL: test_geojson_HTML_widget_value (django_restframework_gis_tests.tests.TestRestFrameworkGis) ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/travis/build/openwisp/django-rest-framework-gis/tests/django_restframework_gis_tests/tests.py", line 529, in test_geojson_HTML_widget_value self.assertContains(response, '"type": "Point"') File "/home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/lib/python3.8/site-packages/django/test/testcases.py", line 470, in assertContains self.assertTrue(real_count != 0, msg_prefix + "Couldn't find %s in response" % text_repr) AssertionError: False is not true : Couldn't find '"type": "Point"' in response ---------------------------------------------------------------------- Ran 90 tests in 0.852s FAILED (failures=1, skipped=1) Destroying test database for alias 'default'... ERROR: InvocationError for command /home/travis/build/openwisp/django-rest-framework-gis/.tox/travis/bin/coverage run --source=rest_framework_gis ./tests/manage.py test tests/django_restframework_gis_tests (exited with code 1) ___________________________________ summary ____________________________________ ERROR: travis: commands failed travis_time:end:0bb99640:start=1603638746902358254,finish=1603638762131566526,duration=15229208272,event=script ```
TravisBuddy Request Identifier: 753f0990-16d6-11eb-a761-09290313622d
dhaval-mehta commented 4 years ago

@nemesisdesign @auvipy Code is ready for the final review. 🔥 This PR does not implement schema generation for geometry collection and geometry field. I will raise separate PR soon(may take up to 2 months).

jayvdb commented 4 years ago

This PR does not implement schema generation for geometry collection and geometry field. I will raise separate PR soon(may take up to 2 months).

If it isnt going to be done in this PR, please create an issue about it after this PR is merge, as this should hold up a release, or at least be relnoted prominently, otherwise users will data using those types will have a broken schema, and how this might effect their systems feels like it could be unpredictable.

dhaval-mehta commented 4 years ago

@auvipy done

dhaval-mehta commented 4 years ago

why?

These commits are no longer required. #248 fixes PostgreSQL integration problem.

dhaval-mehta commented 3 years ago

@auvipy Gentle reminder. I have merged the latest master.

dhaval-mehta commented 3 years ago

I guess the only way to get feedback on this feature is to publish it and see what happens, @dhaval-mehta will you stick around to help us maintain it?

Sure. It will be my pleasure to maintain this project.

nemesifier commented 3 years ago

@dhaval-mehta your work is now released! I expect feedback from users of this library in the coming months. I sent you an invite to have write access to this repository in the hope that you can help us maintain this feature as feedback from users comes in.

Pushes to master are restricted to admins, but pushes to other branches are allowed :+1:.

dhaval-mehta commented 3 years ago

I will ask my network to test this as well. It will help us to improve the schema generation quickly.

dhaval-mehta commented 3 years ago

@dhaval-mehta your work is now released! I expect feedback from users of this library in the coming months. I sent you an invite to have write access to this repository in the hope that you can help us maintain this feature as feedback from users comes in.

Pushes to master are restricted to admins, but pushes to other branches are allowed 👍.

Thank you so much for providing me this opportunity. It would be my pleasure to contribute to this repo.

christiaan-dockbite commented 3 years ago

Requiring users to set REST_FRAMEWORK.DEFAULT_SCHEMA_CLASS to a custom GIS specific class will limit the utility of this. The default DRF schema generator is rarely used for serious projects because there are so many unsolved problems in it. Most medium to large projects will use drf-yasg, or similar (including drf-spectacular which is new but quite good), and they use their own mechanism, either requiring that DEFAULT_SCHEMA_CLASS is set to their own class, or they ignore DEFAULT_SCHEMA_CLASS altogether. And many projects need to sub-class DRF's AutoSchema to add their own behaviour. I've tried to do a WIP for drf-spectacular to use the standard AutoSchema inheritance at tfranzel/drf-spectacular#46 , but it has has some curly problems.

Keeping GeoFeatureAutoSchema is ok, but it would be better as a thin wrapper only, using functionality that exists outside of the class.

i.e. the schemas and functions that are embedded here inside this class should be in the module namespace, so they can be used with other generators. The code in this custom AutoSchema only uses self. to reference the new code below -- it doesnt rely on any of the inner workings of DRF AutoSchema.

@dhaval-mehta Is there any way now that the schema generation is compatible with other schema generators, such as drf-spectacular? If not, is there a way we can make it compatible?

dhaval-mehta commented 3 years ago

Requiring users to set REST_FRAMEWORK.DEFAULT_SCHEMA_CLASS to a custom GIS specific class will limit the utility of this. The default DRF schema generator is rarely used for serious projects because there are so many unsolved problems in it. Most medium to large projects will use drf-yasg, or similar (including drf-spectacular which is new but quite good), and they use their own mechanism, either requiring that DEFAULT_SCHEMA_CLASS is set to their own class, or they ignore DEFAULT_SCHEMA_CLASS altogether. And many projects need to sub-class DRF's AutoSchema to add their own behaviour. I've tried to do a WIP for drf-spectacular to use the standard AutoSchema inheritance at tfranzel/drf-spectacular#46 , but it has has some curly problems. Keeping GeoFeatureAutoSchema is ok, but it would be better as a thin wrapper only, using functionality that exists outside of the class. i.e. the schemas and functions that are embedded here inside this class should be in the module namespace, so they can be used with other generators. The code in this custom AutoSchema only uses self. to reference the new code below -- it doesnt rely on any of the inner workings of DRF AutoSchema.

@dhaval-mehta Is there any way now that the schema generation is compatible with other schema generators, such as drf-spectacular? If not, is there a way we can make it compatible?

This implementation is compatible with all libraries which are compatible with DRF schema generation. As per my knowledge, implementation of drf-spectacular is not compatible with DRF's schema generation. Hence I think, there is no way to make it compatible with drf-spectacular.

https://github.com/tfranzel/drf-spectacular/pull/38 This PR is open. This can bring support for open API schema generation for drf-spectacular.