|
1 | 1 | from django.test import RequestFactory, TestCase
|
| 2 | +from packaging.version import parse as parse_version |
| 3 | +from rest_framework import VERSION as DRF_VERSION |
2 | 4 | from rest_framework.generics import RetrieveAPIView
|
3 | 5 | from rest_framework.request import Request
|
4 | 6 | from rest_framework.schemas.openapi import SchemaGenerator
|
@@ -489,28 +491,28 @@ def test_geo_json_pagination_schema(self):
|
489 | 491 | )
|
490 | 492 | self.assertIn("features", generated_schema["properties"])
|
491 | 493 | generated_schema["properties"].pop("features")
|
492 |
| - self.assertDictEqual( |
493 |
| - generated_schema, |
494 |
| - { |
495 |
| - "type": "object", |
496 |
| - "properties": { |
497 |
| - "type": {"type": "string", "enum": ["FeatureCollection"]}, |
498 |
| - "count": {"type": "integer", "example": 123}, |
499 |
| - "next": { |
500 |
| - "type": "string", |
501 |
| - "nullable": True, |
502 |
| - "format": "uri", |
503 |
| - "example": "http://api.example.org/accounts/?page=4", |
504 |
| - }, |
505 |
| - "previous": { |
506 |
| - "type": "string", |
507 |
| - "nullable": True, |
508 |
| - "format": "uri", |
509 |
| - "example": "http://api.example.org/accounts/?page=2", |
510 |
| - }, |
| 494 | + expected_schema = { |
| 495 | + "type": "object", |
| 496 | + "properties": { |
| 497 | + "type": {"type": "string", "enum": ["FeatureCollection"]}, |
| 498 | + "count": {"type": "integer", "example": 123}, |
| 499 | + "next": { |
| 500 | + "type": "string", |
| 501 | + "nullable": True, |
| 502 | + "format": "uri", |
| 503 | + "example": "http://api.example.org/accounts/?page=4", |
| 504 | + }, |
| 505 | + "previous": { |
| 506 | + "type": "string", |
| 507 | + "nullable": True, |
| 508 | + "format": "uri", |
| 509 | + "example": "http://api.example.org/accounts/?page=2", |
511 | 510 | },
|
512 | 511 | },
|
513 |
| - ) |
| 512 | + } |
| 513 | + if parse_version(DRF_VERSION) >= parse_version('3.15'): |
| 514 | + expected_schema['required'] = ['count', 'results'] |
| 515 | + self.assertDictEqual(generated_schema, expected_schema) |
514 | 516 |
|
515 | 517 |
|
516 | 518 | class TestRestFrameworkGisFiltersSchema(TestCase):
|
|
0 commit comments