Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
102 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
{ | ||
"add_imports": [ | ||
"from __future__ import absolute_import, print_function, unicode_literals" | ||
], | ||
"length": 120, | ||
"groups": [ | ||
{"type": "stdlib"}, | ||
{"type": "remainder"}, | ||
{"type": "packages", "packages": ["django"]}, | ||
{"type": "packages", "packages": ["rest_framework"]}, | ||
{"type": "local"} | ||
] | ||
"length": 120, | ||
"groups": [ | ||
{ "type": "stdlib" }, | ||
{ "type": "remainder" }, | ||
{ "type": "packages", "packages": ["django"] }, | ||
{ "type": "packages", "packages": ["rest_framework"] }, | ||
{ "type": "packages", "packages": ["rest_dataclasses"] }, | ||
{ "type": "local" } | ||
] | ||
} |
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,20 @@ | ||
--- | ||
language: python | ||
dist: xenial | ||
cache: | ||
directories: | ||
- $HOME/.cache/pip | ||
- $HOME/.cache/pre-commit | ||
|
||
python: | ||
- "3.7" | ||
|
||
install: | ||
- pip install -U -r requirements.txt | ||
|
||
script: | ||
- make lint | ||
- make coverage | ||
|
||
after_success: | ||
coveralls |
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,16 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
import unittest | ||
|
||
from django.core.exceptions import ValidationError | ||
|
||
from rest_dataclasses.utils import _django_to_drf | ||
|
||
|
||
class TestUtils(unittest.TestCase): | ||
def test_django_to_drf(self): | ||
self.assertEqual(_django_to_drf("hello"), "hello") | ||
self.assertEqual(_django_to_drf(["hello"]), ["hello"]) | ||
self.assertEqual(_django_to_drf({"hello": "world"}), {"hello": "world"}) | ||
self.assertEqual(_django_to_drf(ValidationError("hello")), ["hello"]) | ||
self.assertEqual(_django_to_drf(ValidationError({"hello": "world"})), {"hello": ["world"]}) |