|  | 
| 2 | 2 | from rest_framework import status | 
| 3 | 3 | from rest_framework.fields import Field | 
| 4 | 4 | from rest_framework.generics import GenericAPIView | 
|  | 5 | +from rest_framework.request import Request | 
| 5 | 6 | from rest_framework.response import Response | 
| 6 | 7 | from rest_framework.views import APIView | 
| 7 | 8 | 
 | 
|  | 
| 13 | 14 |     format_link_segment, | 
| 14 | 15 |     format_resource_type, | 
| 15 | 16 |     format_value, | 
|  | 17 | +    get_included_resources, | 
| 16 | 18 |     get_related_resource_type, | 
| 17 | 19 |     get_resource_id, | 
| 18 | 20 |     get_resource_name, | 
| @@ -456,3 +458,22 @@ def test_get_resource_id(resource_instance, resource, expected): | 
| 456 | 458 | ) | 
| 457 | 459 | def test_format_error_object(message, pointer, response, result): | 
| 458 | 460 |     assert result == format_error_object(message, pointer, response) | 
|  | 461 | + | 
|  | 462 | + | 
|  | 463 | +@pytest.mark.parametrize( | 
|  | 464 | +    "format_type,include_param,expected_includes", | 
|  | 465 | +    [ | 
|  | 466 | +        ("dasherize", "author-bio", ["author_bio"]), | 
|  | 467 | +        ("dasherize", "author-bio,author-type", ["author_bio", "author_type"]), | 
|  | 468 | +        ("dasherize", "author-bio.author-type", ["author_bio.author_type"]), | 
|  | 469 | +        ("camelize", "authorBio", ["author_bio"]), | 
|  | 470 | +    ], | 
|  | 471 | +) | 
|  | 472 | +def test_get_included_resources( | 
|  | 473 | +    rf, include_param, expected_includes, format_type, settings | 
|  | 474 | +): | 
|  | 475 | +    settings.JSON_API_FORMAT_FIELD_NAMES = format_type | 
|  | 476 | + | 
|  | 477 | +    request = Request(rf.get("/test/", {"include": include_param})) | 
|  | 478 | +    includes = get_included_resources(request) | 
|  | 479 | +    assert includes == expected_includes | 
0 commit comments