Skip to content

Commit ae86d42

Browse files
committed
SDK-1229: Implement extra_data tests
1 parent db4cc8f commit ae86d42

File tree

3 files changed

+43
-1
lines changed

3 files changed

+43
-1
lines changed

yoti_python_sdk/issuance_details.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ def __init__(self, data_entry):
1010
else:
1111
value = data_entry.value
1212
self.__token = value.issuance_token.decode()
13-
self.__expiry_date = value.issuing_attributes.expiry_date
13+
if (
14+
value.issuing_attributes.expiry_date != ""
15+
and value.issuing_attributes.expiry_date is not None
16+
):
17+
self.__expiry_date = value.issuing_attributes.expiry_date
18+
else:
19+
self.__expiry_date = None
1420
self.__attributes = value.issuing_attributes.definitions
1521

1622
@property
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CmMIBhJfChFzb21lSXNzdWFuY2VUb2tlbhJKChgyMDE5LTEwLTE1VDIyOjA0OjA1LjEyM1oSEwoRY29tLnRoaXJkcGFydHkuaWQSGQoXY29tLnRoaXJkcGFydHkub3RoZXJfaWQ=

yoti_python_sdk/tests/share/test_extra_data.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime
44
from types import SimpleNamespace
55
import os.path
6+
import pytest
67

78
from yoti_python_sdk.share.extra_data import ExtraData
89
from yoti_python_sdk.tests import file_helper
@@ -64,3 +65,37 @@ def test_should_parse_multiple_issuing_attributes():
6465
assert result.expiry_date == "2019-10-15T22:04:05.123Z"
6566
assert result.attributes[0].name == "com.thirdparty.id"
6667
assert result.attributes[1].name == "com.thirdparty.other_id"
68+
69+
70+
@pytest.mark.parametrize("no_expiry", ["", None])
71+
def test_should_handle_no_expiry_date(no_expiry):
72+
tokenValue = "tokenValue"
73+
thirdparty_attribute = create_third_party_test_data(
74+
tokenValue, no_expiry, "attribute.name"
75+
)
76+
extra_data = ExtraData([thirdparty_attribute])
77+
78+
result = extra_data.attribute_issuance_details
79+
80+
assert result.expiry_date is None
81+
82+
83+
def test_should_handle_no_issuing_attributes():
84+
tokenValue = "tokenValue"
85+
thirdparty_attribute = create_third_party_test_data(tokenValue, None)
86+
extra_data = ExtraData([thirdparty_attribute])
87+
result = extra_data.attribute_issuance_details
88+
assert result.token == "tokenValue"
89+
assert len(result.attributes) == 0
90+
91+
92+
def test_should_handle_no_issuing_attribute_definitions():
93+
tokenValue = "tokenValue"
94+
expiry_date = datetime.now().isoformat()
95+
thirdparty_attribute = create_third_party_test_data(tokenValue, expiry_date)
96+
97+
extra_data = ExtraData([thirdparty_attribute])
98+
result = extra_data.attribute_issuance_details
99+
assert result.token == tokenValue
100+
assert result.expiry_date == expiry_date
101+
assert len(result.attributes) == 0

0 commit comments

Comments
 (0)