Total Complexity | 2 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | """ |
||
2 | :Copyright: 2006-2021 Jochen Kupperschmidt |
||
3 | :License: Revised BSD (see `LICENSE` file for details) |
||
4 | """ |
||
5 | |||
6 | from pathlib import Path |
||
7 | |||
8 | import pytest |
||
9 | |||
10 | from byceps.services.user_avatar import service as user_avatar_service |
||
11 | from byceps.util.image.models import ImageType |
||
12 | |||
13 | |||
14 | @pytest.mark.parametrize( |
||
15 | 'image_extension, image_type', |
||
16 | [ |
||
17 | ('jpeg', ImageType.jpeg), |
||
18 | ('png', ImageType.png), |
||
19 | ], |
||
20 | ) |
||
21 | def test_path(data_path, site_app, user, image_extension, image_type): |
||
22 | with Path(f'tests/fixtures/images/image.{image_extension}').open('rb') as f: |
||
23 | avatar_id = user_avatar_service.update_avatar_image( |
||
24 | user.id, f, {image_type} |
||
25 | ) |
||
26 | |||
27 | avatar = user_avatar_service.get_db_avatar(avatar_id) |
||
28 | expected_filename = f'{avatar.id}.{image_extension}' |
||
29 | |||
30 | assert avatar.path == data_path / 'global/users/avatars' / expected_filename |
||
31 |