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 )
11
+
8
12
9
13
@pytest .fixture (scope = 'module' )
10
14
def proto ():
11
15
return protobuf .Protobuf ()
12
16
13
17
14
- def test_protobuf_value_based_on_content_type (proto ):
15
- string_value = "123"
16
- byte_value = str .encode (string_value )
17
- int_value = int (string_value )
18
-
19
- result = proto .value_based_on_content_type (byte_value , proto .CT_STRING )
20
- assert result == string_value
21
-
22
- result = proto .value_based_on_content_type (byte_value , proto .CT_DATE )
23
- assert result == string_value
18
+ @pytest .mark .parametrize (
19
+ "content_type, expected_value" ,
20
+ [(proto ().CT_STRING , string_value ),
21
+ (proto ().CT_DATE , string_value ),
22
+ (proto ().CT_INT , int_value )])
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 )
25
+ assert result == expected_value
24
26
25
- result = proto .value_based_on_content_type (byte_value , proto .CT_JPEG )
26
- assert result == byte_value
27
-
28
- result = proto .value_based_on_content_type (byte_value , proto .CT_PNG )
29
- assert result == byte_value
30
-
31
- result = proto .value_based_on_content_type (byte_value , proto .CT_INT )
32
- assert result == int_value
33
27
28
+ def test_warning_protobuf_values_based_on_content_type (proto ):
34
29
# disable logging for the below types: warning shown as type is not recognized
35
30
logger = logging .getLogger ()
36
31
logger .propagate = False
@@ -47,6 +42,16 @@ def test_protobuf_value_based_on_content_type(proto):
47
42
logger .propagate = True
48
43
49
44
45
+ @pytest .mark .parametrize (
46
+ "content_type" ,
47
+ (proto ().CT_JPEG ,
48
+ proto ().CT_PNG ))
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
52
+ assert result .content_type == content_type
53
+
54
+
50
55
def test_protobuf_image_uri_based_on_content_type (proto ):
51
56
value = b'test string'
52
57
0 commit comments