3
3
4
4
import pytest
5
5
6
+ from yoti_python_sdk import attribute_parser
6
7
from yoti_python_sdk .protobuf import protobuf
7
8
8
9
STRING_VALUE = "123"
@@ -20,23 +21,23 @@ def proto():
20
21
[(proto ().CT_STRING , STRING_VALUE ),
21
22
(proto ().CT_DATE , STRING_VALUE ),
22
23
(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 )
24
+ def test_attribute_parser_values_based_on_content_type (content_type , expected_value ):
25
+ result = attribute_parser .value_based_on_content_type (BYTE_VALUE , content_type )
25
26
assert result == expected_value
26
27
27
28
28
- def test_protobuf_values_based_on_other_content_types (proto ):
29
+ def test_attribute_parser_values_based_on_other_content_types (proto ):
29
30
# disable logging for the below types: warning shown as type is not recognized
30
31
logger = logging .getLogger ()
31
32
logger .propagate = False
32
33
33
- result = proto .value_based_on_content_type (BYTE_VALUE , proto .CT_UNDEFINED )
34
+ result = attribute_parser .value_based_on_content_type (BYTE_VALUE , proto .CT_UNDEFINED )
34
35
assert result == STRING_VALUE
35
36
36
- result = proto .value_based_on_content_type (BYTE_VALUE )
37
+ result = attribute_parser .value_based_on_content_type (BYTE_VALUE )
37
38
assert result == STRING_VALUE
38
39
39
- result = proto .value_based_on_content_type (BYTE_VALUE , 100 )
40
+ result = attribute_parser .value_based_on_content_type (BYTE_VALUE , 100 )
40
41
assert result == STRING_VALUE
41
42
42
43
logger .propagate = True
@@ -47,16 +48,16 @@ def test_protobuf_values_based_on_other_content_types(proto):
47
48
(proto ().CT_JPEG ,
48
49
proto ().CT_PNG ))
49
50
def test_image_value_based_on_content_type (proto , content_type ):
50
- result = proto .value_based_on_content_type (BYTE_VALUE , content_type )
51
+ result = attribute_parser .value_based_on_content_type (BYTE_VALUE , content_type )
51
52
assert result .data == BYTE_VALUE
52
53
assert result .content_type == content_type
53
54
54
55
55
- def test_protobuf_image_uri_based_on_content_type (proto ):
56
+ def test_attribute_parser_image_uri_based_on_content_type (proto ):
56
57
value = b'test string'
57
58
58
- result = proto .image_uri_based_on_content_type (value , proto .CT_JPEG )
59
+ result = attribute_parser .image_uri_based_on_content_type (value , proto .CT_JPEG )
59
60
assert result == 'data:image/jpeg;base64,dGVzdCBzdHJpbmc='
60
61
61
- result = proto .image_uri_based_on_content_type (value , proto .CT_PNG )
62
+ result = attribute_parser .image_uri_based_on_content_type (value , proto .CT_PNG )
62
63
assert result == 'data:image/png;base64,dGVzdCBzdHJpbmc='
0 commit comments