1
2import json
3
4import aiohttp
5
6
7async def test_ok(service_client, load_binary):
8 form_data = aiohttp.FormData()
9
10
11 image = load_binary('logo_in_circle.png')
12 form_data.add_field('profileImage', image, filename='logo_in_circle.png')
13
14
15 address = {'street': '3, Garden St', 'city': 'Hillsbery, UT'}
16 form_data.add_field(
17 'address', json.dumps(address), content_type='application/json',
18 )
19
20
21 response = await service_client.post('/v1/multipart', data=form_data)
22 assert response.status == 200
23 assert response.text == f'city={address["city"]} image_size={len(image)}'
24
25
26
27async def test_bad_content_type(service_client):
28 response = await service_client.post('/v1/multipart', data='{}')
29 assert response.status == 400
30 assert response.content == b'Expected \'multipart/form-data\' content type'