Passed
Push — main ( 1f94b4...a29a2e )
by Jochen
04:44
created

tests.integration.services.user_avatar.test_update_avatar_image   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 31
rs 10
c 0
b 0
f 0
wmc 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A test_path() 0 17 2
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