Total Complexity | 5 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """ |
||
2 | :Copyright: 2006-2020 Jochen Kupperschmidt |
||
3 | :License: Modified BSD, see LICENSE for details. |
||
4 | """ |
||
5 | |||
6 | from pathlib import Path |
||
7 | from tempfile import TemporaryDirectory |
||
8 | |||
9 | import pytest |
||
10 | |||
11 | |||
12 | def test_create( |
||
13 | data_path, app, api_client, api_client_authz_header, party, user |
||
14 | ): |
||
15 | app.config['PATH_DATA'] = data_path |
||
16 | |||
17 | response = send_request( |
||
18 | api_client, api_client_authz_header, party.id, user.id |
||
19 | ) |
||
20 | |||
21 | assert response.status_code == 201 |
||
22 | |||
23 | |||
24 | @pytest.fixture |
||
25 | def data_path(): |
||
26 | with TemporaryDirectory() as d: |
||
27 | yield Path(d) |
||
28 | |||
29 | |||
30 | def send_request(api_client, api_client_authz_header, party_id, creator_id): |
||
31 | url = f'/api/tourney/avatars' |
||
32 | |||
33 | headers = [api_client_authz_header] |
||
34 | with Path('testfixtures/images/image.png').open('rb') as image_file: |
||
35 | form_data = { |
||
36 | 'image': image_file, |
||
37 | 'party_id': party_id, |
||
38 | 'creator_id': creator_id, |
||
39 | } |
||
40 | |||
41 | return api_client.post(url, headers=headers, data=form_data) |
||
42 |