-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from workfloworchestrator/py311
Python 3.11 + Bump version to 0.2.0
- Loading branch information
Showing
10 changed files
with
192 additions
and
37 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,118 @@ | ||
.git | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build | ||
develop-eggs | ||
dist | ||
downloads | ||
eggs | ||
.eggs | ||
lib | ||
lib64 | ||
parts | ||
sdist | ||
var | ||
wheels | ||
pip-wheel-metadata | ||
share/python-wheels | ||
*.egg-info | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build | ||
|
||
# PyBuilder | ||
target | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv* | ||
env | ||
venv | ||
ENV | ||
env.bak | ||
venv.bak | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mypy | ||
.mypy_cache | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre | ||
|
||
# Misc cache | ||
.cache | ||
.pytest_cache | ||
|
||
# Editors | ||
.idea | ||
.code | ||
.vscode | ||
.pycharm_helpers | ||
|
||
# Exclude files | ||
.*ignore | ||
|
||
# OSX stuff | ||
.DS_Store | ||
|
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 |
---|---|---|
|
@@ -13,4 +13,4 @@ | |
|
||
"""This is the pydantic-forms engine.""" | ||
|
||
__version__ = "0.1.0" | ||
__version__ = "0.2.0" |
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
Empty file.
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,48 @@ | ||
from http import HTTPStatus | ||
from unittest import mock | ||
|
||
import pytest | ||
from fastapi.requests import Request | ||
from pydantic import ValidationError | ||
|
||
from pydantic_forms.core import FormPage | ||
from pydantic_forms.exception_handlers.fastapi import form_error_handler | ||
from pydantic_forms.exceptions import FormNotCompleteError, FormOverflowError, FormValidationError | ||
|
||
|
||
async def test_form_not_complete(): | ||
exception = FormNotCompleteError({"message": "foobar"}) | ||
response = await form_error_handler(mock.Mock(spec=Request), exception) | ||
assert response.status_code == HTTPStatus.NOT_EXTENDED | ||
body = response.body.decode() | ||
assert "FormNotCompleteError" in body | ||
assert "foobar" in body | ||
|
||
|
||
@pytest.fixture | ||
def example_form_error_invalid_int(): | ||
class Form(FormPage): | ||
number: int | ||
|
||
with pytest.raises(ValidationError) as error_info: | ||
assert Form(number="foo") | ||
|
||
return error_info.value.errors() | ||
|
||
|
||
async def test_form_validation(example_form_error_invalid_int): | ||
exception = FormValidationError("myvalidator", example_form_error_invalid_int) | ||
response = await form_error_handler(mock.Mock(spec=Request), exception) | ||
assert response.status_code == HTTPStatus.BAD_REQUEST | ||
body = response.body.decode() | ||
assert "FormValidationError" in body | ||
assert "is not a valid integer" in body | ||
|
||
|
||
async def test_overflow_error(): | ||
exception = FormOverflowError("my error") | ||
response = await form_error_handler(mock.Mock(spec=Request), exception) | ||
assert response.status_code == HTTPStatus.INTERNAL_SERVER_ERROR | ||
body = response.body.decode() | ||
assert "FormOverflowError" in body | ||
assert "my error" in body |