Skip to content

Commit

Permalink
[tests] Updated test to support restframework 3.15
Browse files Browse the repository at this point in the history
  • Loading branch information
pandafy committed Aug 17, 2024
1 parent 977d05b commit 33614f7
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions tests/django_restframework_gis_tests/test_schema_generation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from django.test import RequestFactory, TestCase
from packaging.version import parse as parse_version
from rest_framework import VERSION as DRF_VERSION
from rest_framework.generics import RetrieveAPIView
from rest_framework.request import Request
from rest_framework.schemas.openapi import SchemaGenerator
Expand Down Expand Up @@ -489,28 +491,28 @@ def test_geo_json_pagination_schema(self):
)
self.assertIn("features", generated_schema["properties"])
generated_schema["properties"].pop("features")
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",
},
expected_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",
},
},
)
}
if parse_version(DRF_VERSION) >= parse_version('3.15'):
expected_schema['required'] = ['count', 'results']
self.assertDictEqual(generated_schema, expected_schema)


class TestRestFrameworkGisFiltersSchema(TestCase):
Expand Down

0 comments on commit 33614f7

Please sign in to comment.