-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✅ [#34] test drf-spectacular extensions
- Loading branch information
1 parent
0152c97
commit ae73ded
Showing
4 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class TestAppConfig(AppConfig): | ||
name = "testapp" | ||
|
||
def ready(self): | ||
from django_loose_fk import oas_extensions # noqa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from drf_spectacular.generators import SchemaGenerator | ||
|
||
|
||
def test_field_schema(): | ||
schema = SchemaGenerator().get_schema(request=None, public=True) | ||
|
||
zaaktype_schema = schema["components"]["schemas"]["Zaak"]["properties"]["zaaktype"] | ||
assert zaaktype_schema == { | ||
"type": "string", | ||
"format": "uri", | ||
"maxLength": 1000, | ||
"minLength": None, | ||
} | ||
|
||
|
||
def test_filter_schema(): | ||
schema = SchemaGenerator().get_schema(request=None, public=True) | ||
|
||
parameters_schema = schema["paths"]["/zaken/"]["get"]["parameters"] | ||
|
||
assert len(parameters_schema) == 2 | ||
|
||
zaaktype_param = parameters_schema[0] | ||
assert zaaktype_param["name"] == "zaaktype" | ||
assert zaaktype_param["schema"]["type"] == "string" | ||
assert zaaktype_param["schema"]["format"] == "uri" | ||
|
||
zaaktype_in_param = parameters_schema[1] | ||
assert zaaktype_in_param["name"] == "zaaktype__in" | ||
assert zaaktype_in_param["schema"]["type"] == "array" | ||
assert zaaktype_in_param["schema"]["items"]["type"] == "string" | ||
assert zaaktype_in_param["schema"]["items"]["format"] == "uri" | ||
|
||
|
||
def test_declared_filter_schema(): | ||
schema = SchemaGenerator().get_schema(request=None, public=True) | ||
|
||
parameters_schema = schema["paths"]["/zaakobjectfk/"]["get"]["parameters"] | ||
|
||
assert len(parameters_schema) == 1 | ||
param = parameters_schema[0] | ||
|
||
assert param["name"] == "zaak" | ||
assert param["schema"]["type"] == "string" | ||
assert param["schema"]["format"] == "uri" |