-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'pr5' with improvements. closes #5
- Loading branch information
Showing
5 changed files
with
64 additions
and
13 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
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
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,32 @@ | ||
from django.db import models | ||
from rest_framework import serializers | ||
|
||
from drf_spectacular.plumbing import is_serializer, force_instance, is_field | ||
|
||
|
||
def test_is_serializer(): | ||
assert not is_serializer(serializers.SlugField) | ||
assert not is_serializer(serializers.SlugField()) | ||
|
||
assert not is_serializer(models.CharField) | ||
assert not is_serializer(models.CharField()) | ||
|
||
assert is_serializer(serializers.Serializer) | ||
assert is_serializer(serializers.Serializer()) | ||
|
||
|
||
def test_is_field(): | ||
assert is_field(serializers.SlugField) | ||
assert is_field(serializers.SlugField()) | ||
|
||
assert not is_field(models.CharField) | ||
assert not is_field(models.CharField()) | ||
|
||
assert not is_field(serializers.Serializer) | ||
assert not is_field(serializers.Serializer()) | ||
|
||
|
||
def test_force_instance(): | ||
assert isinstance(force_instance(serializers.CharField), serializers.CharField) | ||
assert force_instance(5) == 5 | ||
assert force_instance(dict) == dict |