@@ -173,9 +173,15 @@ def test_anonymous_request(self):
173
173
url = '/example/' ,
174
174
action = 'get' ,
175
175
fields = [
176
- coreapi .Field ('page' , required = False , location = 'query' , schema = coreschema .Integer (title = 'Page' , description = 'A page number within the paginated result set.' )),
177
- coreapi .Field ('page_size' , required = False , location = 'query' , schema = coreschema .Integer (title = 'Page size' , description = 'Number of results to return per page.' )),
178
- coreapi .Field ('ordering' , required = False , location = 'query' , schema = coreschema .String (title = 'Ordering' , description = 'Which field to use when ordering the results.' ))
176
+ coreapi .Field ('page' , required = False , location = 'query' ,
177
+ schema = coreschema .Integer (title = 'Page' ,
178
+ description = 'A page number within the paginated result set.' )),
179
+ coreapi .Field ('page_size' , required = False , location = 'query' ,
180
+ schema = coreschema .Integer (title = 'Page size' ,
181
+ description = 'Number of results to return per page.' )),
182
+ coreapi .Field ('ordering' , required = False , location = 'query' ,
183
+ schema = coreschema .String (title = 'Ordering' ,
184
+ description = 'Which field to use when ordering the results.' ))
179
185
]
180
186
),
181
187
'custom_list_action' : coreapi .Link (
@@ -201,7 +207,9 @@ def test_anonymous_request(self):
201
207
action = 'get' ,
202
208
fields = [
203
209
coreapi .Field ('id' , required = True , location = 'path' , schema = coreschema .String ()),
204
- coreapi .Field ('ordering' , required = False , location = 'query' , schema = coreschema .String (title = 'Ordering' , description = 'Which field to use when ordering the results.' ))
210
+ coreapi .Field ('ordering' , required = False , location = 'query' ,
211
+ schema = coreschema .String (title = 'Ordering' ,
212
+ description = 'Which field to use when ordering the results.' ))
205
213
]
206
214
)
207
215
}
@@ -223,17 +231,24 @@ def test_authenticated_request(self):
223
231
url = '/example/' ,
224
232
action = 'get' ,
225
233
fields = [
226
- coreapi .Field ('page' , required = False , location = 'query' , schema = coreschema .Integer (title = 'Page' , description = 'A page number within the paginated result set.' )),
227
- coreapi .Field ('page_size' , required = False , location = 'query' , schema = coreschema .Integer (title = 'Page size' , description = 'Number of results to return per page.' )),
228
- coreapi .Field ('ordering' , required = False , location = 'query' , schema = coreschema .String (title = 'Ordering' , description = 'Which field to use when ordering the results.' ))
234
+ coreapi .Field ('page' , required = False , location = 'query' ,
235
+ schema = coreschema .Integer (title = 'Page' ,
236
+ description = 'A page number within the paginated result set.' )),
237
+ coreapi .Field ('page_size' , required = False , location = 'query' ,
238
+ schema = coreschema .Integer (title = 'Page size' ,
239
+ description = 'Number of results to return per page.' )),
240
+ coreapi .Field ('ordering' , required = False , location = 'query' ,
241
+ schema = coreschema .String (title = 'Ordering' ,
242
+ description = 'Which field to use when ordering the results.' ))
229
243
]
230
244
),
231
245
'create' : coreapi .Link (
232
246
url = '/example/' ,
233
247
action = 'post' ,
234
248
encoding = 'application/json' ,
235
249
fields = [
236
- coreapi .Field ('a' , required = True , location = 'form' , schema = coreschema .String (title = 'A' , description = 'A field description' )),
250
+ coreapi .Field ('a' , required = True , location = 'form' ,
251
+ schema = coreschema .String (title = 'A' , description = 'A field description' )),
237
252
coreapi .Field ('b' , required = False , location = 'form' , schema = coreschema .String (title = 'B' ))
238
253
]
239
254
),
@@ -242,7 +257,9 @@ def test_authenticated_request(self):
242
257
action = 'get' ,
243
258
fields = [
244
259
coreapi .Field ('id' , required = True , location = 'path' , schema = coreschema .String ()),
245
- coreapi .Field ('ordering' , required = False , location = 'query' , schema = coreschema .String (title = 'Ordering' , description = 'Which field to use when ordering the results.' ))
260
+ coreapi .Field ('ordering' , required = False , location = 'query' ,
261
+ schema = coreschema .String (title = 'Ordering' ,
262
+ description = 'Which field to use when ordering the results.' ))
246
263
]
247
264
),
248
265
'custom_action' : coreapi .Link (
@@ -273,8 +290,10 @@ def test_authenticated_request(self):
273
290
description = 'A custom action using both list field and list serializer in the serializer.' ,
274
291
fields = [
275
292
coreapi .Field ('id' , required = True , location = 'path' , schema = coreschema .String ()),
276
- coreapi .Field ('a' , required = True , location = 'form' , schema = coreschema .Array (title = 'A' , items = coreschema .Integer ())),
277
- coreapi .Field ('b' , required = True , location = 'form' , schema = coreschema .Array (title = 'B' , items = coreschema .String ())),
293
+ coreapi .Field ('a' , required = True , location = 'form' ,
294
+ schema = coreschema .Array (title = 'A' , items = coreschema .Integer ())),
295
+ coreapi .Field ('b' , required = True , location = 'form' ,
296
+ schema = coreschema .Array (title = 'B' , items = coreschema .String ())),
278
297
]
279
298
),
280
299
'custom_list_action' : coreapi .Link (
@@ -310,7 +329,8 @@ def test_authenticated_request(self):
310
329
description = 'A description of the post method on the custom action.' ,
311
330
encoding = 'application/json' ,
312
331
fields = [
313
- coreapi .Field ('a' , required = True , location = 'form' , schema = coreschema .String (title = 'A' , description = 'A field description' )),
332
+ coreapi .Field ('a' , required = True , location = 'form' ,
333
+ schema = coreschema .String (title = 'A' , description = 'A field description' )),
314
334
coreapi .Field ('b' , required = False , location = 'form' , schema = coreschema .String (title = 'B' ))
315
335
]
316
336
),
@@ -320,7 +340,8 @@ def test_authenticated_request(self):
320
340
description = 'A description of the put method on the custom action from mapping.' ,
321
341
encoding = 'application/json' ,
322
342
fields = [
323
- coreapi .Field ('a' , required = True , location = 'form' , schema = coreschema .String (title = 'A' , description = 'A field description' )),
343
+ coreapi .Field ('a' , required = True , location = 'form' ,
344
+ schema = coreschema .String (title = 'A' , description = 'A field description' )),
324
345
coreapi .Field ('b' , required = False , location = 'form' , schema = coreschema .String (title = 'B' ))
325
346
]
326
347
),
@@ -331,9 +352,12 @@ def test_authenticated_request(self):
331
352
encoding = 'application/json' ,
332
353
fields = [
333
354
coreapi .Field ('id' , required = True , location = 'path' , schema = coreschema .String ()),
334
- coreapi .Field ('a' , required = True , location = 'form' , schema = coreschema .String (title = 'A' , description = ('A field description' ))),
355
+ coreapi .Field ('a' , required = True , location = 'form' ,
356
+ schema = coreschema .String (title = 'A' , description = ('A field description' ))),
335
357
coreapi .Field ('b' , required = False , location = 'form' , schema = coreschema .String (title = 'B' )),
336
- coreapi .Field ('ordering' , required = False , location = 'query' , schema = coreschema .String (title = 'Ordering' , description = 'Which field to use when ordering the results.' ))
358
+ coreapi .Field ('ordering' , required = False , location = 'query' ,
359
+ schema = coreschema .String (title = 'Ordering' ,
360
+ description = 'Which field to use when ordering the results.' ))
337
361
]
338
362
),
339
363
'partial_update' : coreapi .Link (
@@ -342,17 +366,22 @@ def test_authenticated_request(self):
342
366
encoding = 'application/json' ,
343
367
fields = [
344
368
coreapi .Field ('id' , required = True , location = 'path' , schema = coreschema .String ()),
345
- coreapi .Field ('a' , required = False , location = 'form' , schema = coreschema .String (title = 'A' , description = 'A field description' )),
369
+ coreapi .Field ('a' , required = False , location = 'form' ,
370
+ schema = coreschema .String (title = 'A' , description = 'A field description' )),
346
371
coreapi .Field ('b' , required = False , location = 'form' , schema = coreschema .String (title = 'B' )),
347
- coreapi .Field ('ordering' , required = False , location = 'query' , schema = coreschema .String (title = 'Ordering' , description = 'Which field to use when ordering the results.' ))
372
+ coreapi .Field ('ordering' , required = False , location = 'query' ,
373
+ schema = coreschema .String (title = 'Ordering' ,
374
+ description = 'Which field to use when ordering the results.' ))
348
375
]
349
376
),
350
377
'delete' : coreapi .Link (
351
378
url = '/example/{id}/' ,
352
379
action = 'delete' ,
353
380
fields = [
354
381
coreapi .Field ('id' , required = True , location = 'path' , schema = coreschema .String ()),
355
- coreapi .Field ('ordering' , required = False , location = 'query' , schema = coreschema .String (title = 'Ordering' , description = 'Which field to use when ordering the results.' ))
382
+ coreapi .Field ('ordering' , required = False , location = 'query' ,
383
+ schema = coreschema .String (title = 'Ordering' ,
384
+ description = 'Which field to use when ordering the results.' ))
356
385
]
357
386
)
358
387
}
@@ -597,9 +626,15 @@ def test_schema_for_regular_views(self):
597
626
url = '/example1/' ,
598
627
action = 'get' ,
599
628
fields = [
600
- coreapi .Field ('page' , required = False , location = 'query' , schema = coreschema .Integer (title = 'Page' , description = 'A page number within the paginated result set.' )),
601
- coreapi .Field ('page_size' , required = False , location = 'query' , schema = coreschema .Integer (title = 'Page size' , description = 'Number of results to return per page.' )),
602
- coreapi .Field ('ordering' , required = False , location = 'query' , schema = coreschema .String (title = 'Ordering' , description = 'Which field to use when ordering the results.' ))
629
+ coreapi .Field ('page' , required = False , location = 'query' ,
630
+ schema = coreschema .Integer (title = 'Page' ,
631
+ description = 'A page number within the paginated result set.' )),
632
+ coreapi .Field ('page_size' , required = False , location = 'query' ,
633
+ schema = coreschema .Integer (title = 'Page size' ,
634
+ description = 'Number of results to return per page.' )),
635
+ coreapi .Field ('ordering' , required = False , location = 'query' ,
636
+ schema = coreschema .String (title = 'Ordering' ,
637
+ description = 'Which field to use when ordering the results.' ))
603
638
]
604
639
),
605
640
'custom_list_action' : coreapi .Link (
@@ -625,7 +660,9 @@ def test_schema_for_regular_views(self):
625
660
action = 'get' ,
626
661
fields = [
627
662
coreapi .Field ('id' , required = True , location = 'path' , schema = coreschema .String ()),
628
- coreapi .Field ('ordering' , required = False , location = 'query' , schema = coreschema .String (title = 'Ordering' , description = 'Which field to use when ordering the results.' ))
663
+ coreapi .Field ('ordering' , required = False , location = 'query' ,
664
+ schema = coreschema .String (title = 'Ordering' ,
665
+ description = 'Which field to use when ordering the results.' ))
629
666
]
630
667
)
631
668
}
@@ -706,8 +743,10 @@ def test_schema_for_regular_views(self):
706
743
action = 'post' ,
707
744
encoding = 'application/json' ,
708
745
fields = [
709
- coreapi .Field ('name' , required = True , location = 'form' , schema = coreschema .String (title = 'Name' )),
710
- coreapi .Field ('target' , required = True , location = 'form' , schema = coreschema .Integer (description = 'Target' , title = 'Target' )),
746
+ coreapi .Field ('name' , required = True , location = 'form' ,
747
+ schema = coreschema .String (title = 'Name' )),
748
+ coreapi .Field ('target' , required = True , location = 'form' ,
749
+ schema = coreschema .Integer (description = 'Target' , title = 'Target' )),
711
750
]
712
751
)
713
752
}
@@ -752,8 +791,10 @@ def test_schema_for_regular_views(self):
752
791
action = 'post' ,
753
792
encoding = 'application/json' ,
754
793
fields = [
755
- coreapi .Field ('name' , required = True , location = 'form' , schema = coreschema .String (title = 'Name' )),
756
- coreapi .Field ('targets' , required = True , location = 'form' , schema = coreschema .Array (title = 'Targets' , items = coreschema .Integer ())),
794
+ coreapi .Field ('name' , required = True , location = 'form' ,
795
+ schema = coreschema .String (title = 'Name' )),
796
+ coreapi .Field ('targets' , required = True , location = 'form' ,
797
+ schema = coreschema .Array (title = 'Targets' , items = coreschema .Integer ())),
757
798
]
758
799
)
759
800
}
@@ -769,6 +810,7 @@ def test_action_not_coerced_for_get_and_head(self):
769
810
"""
770
811
Ensure that action name is preserved when action map contains "head".
771
812
"""
813
+
772
814
class CustomViewSet (GenericViewSet ):
773
815
serializer_class = EmptySerializer
774
816
@@ -856,7 +898,8 @@ class CustomView(APIView):
856
898
assert isinstance (view .schema , CustomViewInspector )
857
899
858
900
def test_set_custom_inspector_class_via_settings (self ):
859
- with override_settings (REST_FRAMEWORK = {'DEFAULT_SCHEMA_CLASS' : 'tests.schemas.test_coreapi.CustomViewInspector' }):
901
+ with override_settings (
902
+ REST_FRAMEWORK = {'DEFAULT_SCHEMA_CLASS' : 'tests.schemas.test_coreapi.CustomViewInspector' }):
860
903
view = APIView ()
861
904
assert isinstance (view .schema , CustomViewInspector )
862
905
@@ -963,7 +1006,6 @@ def extra_action(self, pk, **kwargs):
963
1006
964
1007
@pytest .mark .skipif (not coreapi , reason = 'coreapi is not installed' )
965
1008
def test_view_with_manual_schema (self ):
966
-
967
1009
path = '/example'
968
1010
method = 'get'
969
1011
base_url = None
@@ -1198,6 +1240,7 @@ class TestURLNamingCollisions(TestCase):
1198
1240
"""
1199
1241
Ref: https://github.com/encode/django-rest-framework/issues/4704
1200
1242
"""
1243
+
1201
1244
def test_manually_routing_nested_routes (self ):
1202
1245
@api_view (["GET" ])
1203
1246
def simple_fbv (request ):
@@ -1444,6 +1487,11 @@ def test_schema_handles_exception():
1444
1487
1445
1488
1446
1489
class CoreapiDeprecationTestCase (TestCase ):
1490
+ def __init__ (self , * args , ** kwargs ):
1491
+ if not coreapi :
1492
+ pytest .skip ("coreapi is not installed" )
1493
+ super ().__init__ (* args , ** kwargs )
1494
+
1447
1495
def assert_deprecation_warning (self , obj ):
1448
1496
with pytest .warns (RemovedInDRF317Warning ) as warning_list :
1449
1497
obj .get_schema_fields ({})
0 commit comments