5
5
6
6
from yoti_python_sdk .protobuf import protobuf
7
7
8
- string_value = "123"
9
- byte_value = str .encode (string_value )
10
- int_value = int (string_value )
8
+ STRING_VALUE = "123"
9
+ BYTE_VALUE = str .encode (STRING_VALUE )
10
+ INT_VALUE = int (STRING_VALUE )
11
11
12
12
13
13
@pytest .fixture (scope = 'module' )
@@ -17,27 +17,27 @@ def proto():
17
17
18
18
@pytest .mark .parametrize (
19
19
"content_type, expected_value" ,
20
- [(proto ().CT_STRING , string_value ),
21
- (proto ().CT_DATE , string_value ),
22
- (proto ().CT_INT , int_value )])
20
+ [(proto ().CT_STRING , STRING_VALUE ),
21
+ (proto ().CT_DATE , STRING_VALUE ),
22
+ (proto ().CT_INT , INT_VALUE )])
23
23
def test_protobuf_values_based_on_content_type (content_type , expected_value ):
24
- result = proto ().value_based_on_content_type (byte_value , content_type )
24
+ result = proto ().value_based_on_content_type (BYTE_VALUE , content_type )
25
25
assert result == expected_value
26
26
27
27
28
- def test_warning_protobuf_values_based_on_content_type (proto ):
28
+ def test_protobuf_values_based_on_other_content_types (proto ):
29
29
# disable logging for the below types: warning shown as type is not recognized
30
30
logger = logging .getLogger ()
31
31
logger .propagate = False
32
32
33
- result = proto .value_based_on_content_type (byte_value , proto .CT_UNDEFINED )
34
- assert result == string_value
33
+ result = proto .value_based_on_content_type (BYTE_VALUE , proto .CT_UNDEFINED )
34
+ assert result == STRING_VALUE
35
35
36
- result = proto .value_based_on_content_type (byte_value )
37
- assert result == string_value
36
+ result = proto .value_based_on_content_type (BYTE_VALUE )
37
+ assert result == STRING_VALUE
38
38
39
- result = proto .value_based_on_content_type (byte_value , 100 )
40
- assert result == string_value
39
+ result = proto .value_based_on_content_type (BYTE_VALUE , 100 )
40
+ assert result == STRING_VALUE
41
41
42
42
logger .propagate = True
43
43
@@ -47,8 +47,8 @@ def test_warning_protobuf_values_based_on_content_type(proto):
47
47
(proto ().CT_JPEG ,
48
48
proto ().CT_PNG ))
49
49
def test_image_value_based_on_content_type (proto , content_type ):
50
- result = proto .value_based_on_content_type (byte_value , content_type )
51
- assert result .data == byte_value
50
+ result = proto .value_based_on_content_type (BYTE_VALUE , content_type )
51
+ assert result .data == BYTE_VALUE
52
52
assert result .content_type == content_type
53
53
54
54
0 commit comments