2017-10-19 06:43:50 +00:00
|
|
|
import asyncio
|
|
|
|
import aiohttp
|
|
|
|
|
|
|
|
|
2017-10-19 23:22:21 +00:00
|
|
|
def req1():
|
2017-10-19 06:43:50 +00:00
|
|
|
with aiohttp.MultipartWriter() as writer:
|
|
|
|
writer.append('test')
|
|
|
|
writer.append_json({'passed': True})
|
|
|
|
|
|
|
|
resp = yield from aiohttp.request(
|
|
|
|
"post", 'http://localhost:8080/multipart',
|
|
|
|
data=writer, headers=writer.headers)
|
|
|
|
print(resp)
|
|
|
|
assert 200 == resp.status
|
|
|
|
|
|
|
|
|
2017-10-19 23:22:21 +00:00
|
|
|
def req2():
|
|
|
|
with aiohttp.MultipartWriter() as writer:
|
|
|
|
writer.append('test')
|
|
|
|
writer.append_json({'passed': True})
|
|
|
|
writer.append(open('src/main.rs'))
|
|
|
|
|
|
|
|
resp = yield from aiohttp.request(
|
|
|
|
"post", 'http://localhost:8080/multipart',
|
|
|
|
data=writer, headers=writer.headers)
|
|
|
|
print(resp)
|
|
|
|
assert 200 == resp.status
|
|
|
|
|
|
|
|
|
2017-10-19 06:43:50 +00:00
|
|
|
loop = asyncio.get_event_loop()
|
2017-10-19 23:22:21 +00:00
|
|
|
loop.run_until_complete(req1())
|
|
|
|
loop.run_until_complete(req2())
|