diff options
author | Ruben Undheim <ruben.undheim@gmail.com> | 2019-01-29 14:54:40 +0000 |
---|---|---|
committer | Ruben Undheim <ruben.undheim@gmail.com> | 2019-01-29 14:54:40 +0000 |
commit | 8163cd837ed90bd66544bc349c1fec0c15347d9d (patch) | |
tree | cf8c44c5daba62d6a7bcda4fd17401f11e41aef5 | |
parent | 33eee9e9275f59d32e2920117a14d7d326b55eb8 (diff) | |
parent | 6dfbccb15630472233639bf2ad093493e90f3629 (diff) |
Update upstream source from tag 'upstream/2.1.0'
Update to upstream version '2.1.0'
with Debian dir e12d92e1c10a7537b138937bddbc7f9761f83c84
-rw-r--r-- | MANIFEST.in | 1 | ||||
-rwxr-xr-x | script/bootstrap | 10 | ||||
-rwxr-xr-x | script/release | 8 | ||||
-rwxr-xr-x | script/setup | 10 | ||||
-rw-r--r-- | setup.py | 2 | ||||
-rw-r--r-- | tests/test_lib.py | 35 | ||||
-rw-r--r-- | voluptuous_serialize/__init__.py | 5 |
7 files changed, 70 insertions, 1 deletions
diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..16b52e4 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1 @@ +include tests/*.py diff --git a/script/bootstrap b/script/bootstrap new file mode 100755 index 0000000..e5cf7f3 --- /dev/null +++ b/script/bootstrap @@ -0,0 +1,10 @@ +#!/bin/sh +# Resolve all dependencies that the application requires to run. + +# Stop on errors +set -e + +cd "$(dirname "$0")/.." + +echo "Installing test and release dependencies..." +python3 -m pip install pytest pylint flake8 pydocstyle twine diff --git a/script/release b/script/release new file mode 100755 index 0000000..4b6bbcb --- /dev/null +++ b/script/release @@ -0,0 +1,8 @@ +#!/bin/sh +# Pushes a new version to PyPi. + +cd "$(dirname "$0")/.." + +rm -rf dist +python3 setup.py sdist +python3 -m twine upload dist/* --skip-existing diff --git a/script/setup b/script/setup new file mode 100755 index 0000000..554389e --- /dev/null +++ b/script/setup @@ -0,0 +1,10 @@ +#!/bin/sh +# Setups the repository. + +# Stop on errors +set -e + +cd "$(dirname "$0")/.." +script/bootstrap + +pip3 install -e . @@ -1,7 +1,7 @@ from setuptools import setup setup(name='voluptuous-serialize', - version='2.0.0', + version='2.1.0', description='Convert voluptuous schemas to dictionaries', url='http://github.com/balloob/voluptuous-serialize', author='Paulus Schoutsen', diff --git a/tests/test_lib.py b/tests/test_lib.py index 657d668..9e0e2d0 100644 --- a/tests/test_lib.py +++ b/tests/test_lib.py @@ -107,3 +107,38 @@ def test_marker_description(): }] == convert(vol.Schema({ vol.Required('name', description='Description of name'): str, })) + + +def test_lower(): + assert { + 'type': 'string', + 'lower': True, + } == convert(vol.Schema(vol.All(vol.Lower, str))) + + +def test_upper(): + assert { + 'type': 'string', + 'upper': True, + } == convert(vol.Schema(vol.All(vol.Upper, str))) + + +def test_capitalize(): + assert { + 'type': 'string', + 'capitalize': True, + } == convert(vol.Schema(vol.All(vol.Capitalize, str))) + + +def test_title(): + assert { + 'type': 'string', + 'title': True, + } == convert(vol.Schema(vol.All(vol.Title, str))) + + +def test_strip(): + assert { + 'type': 'string', + 'strip': True, + } == convert(vol.Schema(vol.All(vol.Strip, str))) diff --git a/voluptuous_serialize/__init__.py b/voluptuous_serialize/__init__.py index 17377c4..8bc2676 100644 --- a/voluptuous_serialize/__init__.py +++ b/voluptuous_serialize/__init__.py @@ -83,6 +83,11 @@ def convert(schema): 'options': [(item, item) for item in schema.container] } + if schema in (vol.Lower, vol.Upper, vol.Capitalize, vol.Title, vol.Strip): + return { + schema.__name__.lower(): True, + } + if isinstance(schema, vol.Coerce): schema = schema.type |