~homeworkprod/byceps

ref: 1181a35dd06d48c779208a6d2a4b3672dd38d812 byceps/tests/services/user_avatar/test_models.py -rw-r--r-- 1.1 KiB
1181a35d — Jochen Kupperschmidt Ported tests from nose2 to pytest 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""
:Copyright: 2006-2017 Jochen Kupperschmidt
:License: Modified BSD, see LICENSE for details.
"""

from datetime import datetime

import pytest

from byceps.util.image.models import ImageType

from testfixtures.user import create_user
from testfixtures.user_avatar import create_avatar


CREATED_AT = datetime(2014, 7, 29, 14, 43, 30, 196165)


@pytest.mark.parametrize('database_value, expected', [
    (None  , None          ),
    ('gif' , ImageType.gif ),
    ('jpeg', ImageType.jpeg),
    ('png' , ImageType.png ),
])
def test_hybrid_image_type_getter(database_value, expected):
    user = create_user()
    avatar = create_avatar(user.id)

    avatar._image_type = database_value

    assert avatar.image_type == expected


@pytest.mark.parametrize('image_type, expected', [
    (None          , None  ),
    (ImageType.gif , 'gif' ),
    (ImageType.jpeg, 'jpeg'),
    (ImageType.png , 'png' ),
])
def test_hybrid_image_type_setter(image_type, expected):
    user = create_user()
    avatar = create_avatar(user.id)

    avatar.image_type = image_type

    assert avatar._image_type == expected