Skip to content

Commit

Permalink
Merge pull request #552 from uncle-lv/pin-flask-marshmallow
Browse files Browse the repository at this point in the history
Update dependencies and add tests for empty file field
  • Loading branch information
greyli committed Mar 28, 2024
2 parents a9bb058 + 9bcd5b8 commit 664ad64
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ repos:
# hooks:
# - id: black
- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 7.0.0
hooks:
- id: flake8
additional_dependencies:
Expand Down
16 changes: 8 additions & 8 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
-r examples.txt
-r tests.txt
-r typing.txt
build==1.0.3
build==1.1.1
# via pip-tools
cachetools==5.3.2
cachetools==5.3.3
# via tox
cfgv==3.4.0
# via pre-commit
chardet==5.2.0
# via tox
distlib==0.3.8
# via virtualenv
filelock==3.13.1
filelock==3.13.3
# via
# tox
# virtualenv
Expand All @@ -29,9 +29,9 @@ nodeenv==1.8.0
# via pre-commit
pip-compile-multi==2.6.3
# via -r requirements/dev.in
pip-tools==7.4.0
pip-tools==7.4.1
# via pip-compile-multi
pre-commit==3.6.2
pre-commit==3.7.0
# via -r requirements/dev.in
pyproject-api==1.6.1
# via tox
Expand All @@ -41,13 +41,13 @@ pyproject-hooks==1.0.0
# pip-tools
toposort==1.10
# via pip-compile-multi
tox==4.13.0
tox==4.14.2
# via -r requirements/dev.in
virtualenv==20.25.0
virtualenv==20.25.1
# via
# pre-commit
# tox
wheel==0.42.0
wheel==0.43.0
# via pip-tools

# The following packages are considered to be unsafe in a requirements file:
Expand Down
18 changes: 10 additions & 8 deletions requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ colorama==0.4.6
# mkdocs-material
ghp-import==2.1.0
# via mkdocs
griffe==0.40.1
griffe==0.42.1
# via mkdocstrings-python
idna==3.6
# via requests
Expand All @@ -36,11 +36,13 @@ markdown==3.5.2
# mkdocs-autorefs
# mkdocs-material
# mkdocstrings
# mkdocstrings-python
# pymdown-extensions
markupsafe==2.1.5
# via
# jinja2
# mkdocs
# mkdocs-autorefs
# mkdocstrings
mergedeep==1.3.4
# via mkdocs
Expand All @@ -49,19 +51,19 @@ mkdocs==1.5.3
# mkdocs-autorefs
# mkdocs-material
# mkdocstrings
mkdocs-autorefs==0.5.0
mkdocs-autorefs==1.0.1
# via mkdocstrings
mkdocs-material==9.5.10
mkdocs-material==9.5.15
# via -r requirements/docs.in
mkdocs-material-extensions==1.3.1
# via mkdocs-material
mkdocstrings==0.24.0
mkdocstrings==0.24.1
# via
# -r requirements/docs.in
# mkdocstrings-python
mkdocstrings-python==1.8.0
mkdocstrings-python==1.9.0
# via -r requirements/docs.in
packaging==23.2
packaging==24.0
# via mkdocs
paginate==0.5.6
# via mkdocs-material
Expand All @@ -73,11 +75,11 @@ platformdirs==4.2.0
# mkdocstrings
pygments==2.17.2
# via mkdocs-material
pymdown-extensions==10.7
pymdown-extensions==10.7.1
# via
# mkdocs-material
# mkdocstrings
python-dateutil==2.8.2
python-dateutil==2.9.0.post0
# via ghp-import
pyyaml==6.0.1
# via
Expand Down
13 changes: 6 additions & 7 deletions requirements/examples.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cffi==1.16.0
# via cryptography
click==8.1.7
# via flask
cryptography==42.0.3
cryptography==42.0.5
# via authlib
flask==3.0.2
# via flask-sqlalchemy
Expand All @@ -29,21 +29,20 @@ markupsafe==2.1.5
# via
# jinja2
# werkzeug
marshmallow==3.20.2
marshmallow==3.21.1
# via marshmallow-dataclass
marshmallow-dataclass==8.6.0
marshmallow-dataclass==8.6.1
# via -r requirements/examples.in
mypy-extensions==1.0.0
# via typing-inspect
packaging==23.2
packaging==24.0
# via marshmallow
pycparser==2.21
# via cffi
sqlalchemy==2.0.27
sqlalchemy==2.0.29
# via flask-sqlalchemy
typing-extensions==4.9.0
typing-extensions==4.10.0
# via
# marshmallow-dataclass
# sqlalchemy
# typing-inspect
typing-inspect==0.9.0
Expand Down
8 changes: 4 additions & 4 deletions requirements/min-versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ cffi==1.16.0
# via cryptography
click==8.1.7
# via flask
cryptography==42.0.3
cryptography==42.0.5
# via authlib
flask==2.0.0
# via
Expand All @@ -35,7 +35,7 @@ jinja2==3.1.3
# via flask
markupsafe==2.1.5
# via jinja2
marshmallow==3.20.2
marshmallow==3.21.1
# via
# flask-marshmallow
# marshmallow-dataclass
Expand All @@ -44,7 +44,7 @@ marshmallow-dataclass==8.5.0
# via -r requirements/min-versions.in
mypy-extensions==1.0.0
# via typing-inspect
packaging==23.2
packaging==24.0
# via
# apispec
# flask-marshmallow
Expand All @@ -56,7 +56,7 @@ sqlalchemy==1.4.49
# via
# -r requirements/min-versions.in
# flask-sqlalchemy
typing-extensions==4.9.0
typing-extensions==4.10.0
# via typing-inspect
typing-inspect==0.9.0
# via marshmallow-dataclass
Expand Down
12 changes: 4 additions & 8 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#
# pip-compile-multi
#
asgiref==3.7.2
asgiref==3.8.1
# via -r requirements/tests.in
attrs==23.2.0
# via
Expand All @@ -16,7 +16,7 @@ certifi==2024.2.2
# via requests
charset-normalizer==3.3.2
# via requests
coverage[toml]==7.4.1
coverage[toml]==7.4.4
# via pytest-cov
idna==3.6
# via requests
Expand All @@ -38,7 +38,7 @@ openapi-schema-validator==0.6.2
# via openapi-spec-validator
openapi-spec-validator==0.7.1
# via -r requirements/tests.in
packaging==23.2
packaging==24.0
# via pytest
pathable==0.4.3
# via jsonschema-path
Expand All @@ -50,7 +50,7 @@ pytest==6.2.5
# via
# -r requirements/tests.in
# pytest-cov
pytest-cov==4.1.0
pytest-cov==5.0.0
# via -r requirements/tests.in
pyyaml==6.0.1
# via jsonschema-path
Expand All @@ -71,9 +71,5 @@ six==1.16.0
# via rfc3339-validator
toml==0.10.2
# via pytest
tomli==2.0.1
# via coverage
typing-extensions==4.9.0
# via asgiref
urllib3==2.2.1
# via requests
6 changes: 2 additions & 4 deletions requirements/typing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@
#
# pip-compile-multi
#
mypy==1.8.0
mypy==1.9.0
# via -r requirements/typing.in
mypy-extensions==1.0.0
# via mypy
tomli==2.0.1
# via mypy
typing-extensions==4.9.0
typing-extensions==4.10.0
# via mypy
24 changes: 24 additions & 0 deletions tests/test_fields.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import io
from importlib.metadata import version

import pytest
from packaging.version import parse
from werkzeug.datastructures import FileStorage

from .schemas import Files
Expand Down Expand Up @@ -45,6 +47,28 @@ def index(files_data):
assert rv.json['detail']['files']['image'] == ['Not a valid file.']


@pytest.mark.skipif(parse(version('flask-marshmallow')) < parse('1.2.1'),
reason='Need flask_marshmallow 1.2.1 for processing empty file field')
def test_empty_file_field(app, client):
@app.post('/')
@app.input(Files, location='files')
def index(files_data):
data = {}
if 'image' in files_data and isinstance(files_data['image'], FileStorage):
data['image'] = True
return data

rv = client.post(
'/',
data={
'image': '',
},
content_type='multipart/form-data'
)
assert rv.status_code == 200
assert rv.json == {}


def test_multiple_file_field(app, client):
@app.post('/')
@app.input(FilesList, location='files')
Expand Down

0 comments on commit 664ad64

Please sign in to comment.