Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b131e21
Added unit tests to demonstrate the problems of https://github.com/za…
ddurham2 Apr 22, 2020
2af3c48
now splitting out multipart POSTs into files[] and form[], handling d…
ddurham2 Apr 22, 2020
6ba7927
rewrote how operations/openapi.py::_get_body_argument() works to bett…
ddurham2 Apr 22, 2020
c277980
Adding unit tests to improve code converage test
ddurham2 Apr 23, 2020
41e03cd
Merge remote-tracking branch 'upstream/master' into fix_975-renewed
ddurham2 May 20, 2020
5b69e90
post merge fixes - using 'async' keyword now in new unit test file
ddurham2 May 20, 2020
e214f45
unit test improvements -- now testing the contents of the files we up…
ddurham2 May 22, 2020
1628d36
making some code a bit clearer regarding duplicate names of file subm…
ddurham2 May 22, 2020
13488a5
Merge branch 'master' of https://github.com/zalando/connexion into fi…
ddurham2 Jul 22, 2020
d1345f5
Patched up 2.7.0 version with validation.py repair of request.body pa…
Mar 10, 2021
a7f8858
US ASCII is a safer encoding for the body parsing
Mar 11, 2021
92c28c1
Revert to utf-8 as the default
Mar 11, 2021
f41436f
Merge branch 'master' into fix-urlencoded-body-parameter-parsing
RichardBruskiewich Mar 11, 2021
0b8c861
parse_body_parameters is a static function
Mar 11, 2021
9524238
Merge branch 'fix-urlencoded-body-parameter-parsing' of https://githu…
Mar 11, 2021
91ea2f1
Applied https://github.com/zalando/connexion/issues/975 fix commit #9…
Mar 11, 2021
1d54bb1
Tag your version with a local STAR tag
Mar 11, 2021
b091fb1
Applying patch https://github.com/zalando/connexion/pull/954
Mar 11, 2021
114bdf4
trench warefare: just another small iteration that makes sense?
Mar 11, 2021
c7a01e6
set 'body' default to an empty byte string
Mar 11, 2021
b7aefc3
Merge branch 'jjdunham2/fix_975-renewed' into fix-urlencoded-body-par…
Mar 11, 2021
150921b
missing string type in TYPE_MAP?
Mar 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
unit test improvements -- now testing the contents of the files we up…
…load too
  • Loading branch information
ddurham2 committed May 22, 2020
commit e214f45337957e873ad8eabe3059e6a57a36d6e8
22 changes: 20 additions & 2 deletions tests/aiohttp/test_aiohttp_multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import aiohttp
import pytest
from pathlib import Path

from connexion import AioHttpApp

Expand Down Expand Up @@ -37,13 +38,17 @@ async def test_single_file_upload(aiohttp_app, aiohttp_client):
data = await resp.json()
assert resp.status == 200
assert data['fileName'] == f'{__name__}.py'
assert data['content'] == Path(__file__).read_bytes().decode('utf8')


async def test_many_files_upload(aiohttp_app, aiohttp_client):
app_client = await aiohttp_client(aiohttp_app.app)

dir_name = os.path.dirname(__file__)
files_field = [('files', open(f'{dir_name}/{file_name}', 'rb')) for file_name in os.listdir(dir_name) if file_name.endswith('.py')]
files_field = [
('files', open(f'{dir_name}/{file_name}', 'rb')) \
for file_name in sorted(os.listdir(dir_name)) if file_name.endswith('.py')
]

form_data = aiohttp.FormData(fields=files_field)

Expand All @@ -56,6 +61,10 @@ async def test_many_files_upload(aiohttp_app, aiohttp_client):

assert resp.status == 200
assert data['filesCount'] == len(files_field)
assert data['contents'] == [
Path(f'{dir_name}/{file_name}').read_bytes().decode('utf8') \
for file_name in sorted(os.listdir(dir_name)) if file_name.endswith('.py')
]


async def test_mixed_multipart_single_file(aiohttp_app, aiohttp_client):
Expand All @@ -75,13 +84,18 @@ async def test_mixed_multipart_single_file(aiohttp_app, aiohttp_client):
assert resp.status == 200
assert data['dirName'] == os.path.dirname(__file__)
assert data['fileName'] == f'{__name__}.py'
assert data['content'] == Path(__file__).read_bytes().decode('utf8')



async def test_mixed_multipart_many_files(aiohttp_app, aiohttp_client):
app_client = await aiohttp_client(aiohttp_app.app)

dir_name = os.path.dirname(__file__)
files_field = [('files', open(f'{dir_name}/{file_name}', 'rb')) for file_name in os.listdir(dir_name) if file_name.endswith('.py')]
files_field = [
('files', open(f'{dir_name}/{file_name}', 'rb')) \
for file_name in sorted(os.listdir(dir_name)) if file_name.endswith('.py')
]

form_data = aiohttp.FormData(fields=files_field)
form_data.add_field('dirName', os.path.dirname(__file__))
Expand All @@ -98,3 +112,7 @@ async def test_mixed_multipart_many_files(aiohttp_app, aiohttp_client):
assert data['dirName'] == os.path.dirname(__file__)
assert data['testCount'] == len(files_field)
assert data['filesCount'] == len(files_field)
assert data['contents'] == [
Path(f'{dir_name}/{file_name}').read_bytes().decode('utf8') \
for file_name in sorted(os.listdir(dir_name)) if file_name.endswith('.py')
]
12 changes: 10 additions & 2 deletions tests/fakeapi/aiohttp_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,19 @@ async def get_uuid():

async def aiohttp_multipart_single_file(funky_funky):
return aiohttp.web.json_response(
data={'fileName': funky_funky.filename},
data={
'fileName': funky_funky.filename,
'content': funky_funky.file.read().decode('utf8')
},
)


async def aiohttp_multipart_many_files(files):
return aiohttp.web.json_response(
data={'filesCount': len(files)},
data={
'filesCount': len(files),
'contents': [ f.file.read().decode('utf8') for f in files ]
},
)


Expand All @@ -103,6 +109,7 @@ async def aiohttp_multipart_mixed_single_file(dir_name, funky_funky):
data={
'dirName': dir_name,
'fileName': funky_funky.filename,
'content': funky_funky.file.read().decode('utf8'),
},
)

Expand All @@ -113,5 +120,6 @@ async def aiohttp_multipart_mixed_many_files(dir_name, test_count, files):
'filesCount': len(files),
'dirName': dir_name,
'testCount': test_count,
'contents': [ f.file.read().decode('utf8') for f in files ]
},
)