summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Undheim <ruben.undheim@gmail.com>2019-01-29 14:54:40 +0000
committerRuben Undheim <ruben.undheim@gmail.com>2019-01-29 14:54:40 +0000
commit8163cd837ed90bd66544bc349c1fec0c15347d9d (patch)
treecf8c44c5daba62d6a7bcda4fd17401f11e41aef5
parent33eee9e9275f59d32e2920117a14d7d326b55eb8 (diff)
parent6dfbccb15630472233639bf2ad093493e90f3629 (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.in1
-rwxr-xr-xscript/bootstrap10
-rwxr-xr-xscript/release8
-rwxr-xr-xscript/setup10
-rw-r--r--setup.py2
-rw-r--r--tests/test_lib.py35
-rw-r--r--voluptuous_serialize/__init__.py5
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 .
diff --git a/setup.py b/setup.py
index 9232f17..e0e7849 100644
--- a/setup.py
+++ b/setup.py
@@ -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