|
3 | 3 | from datetime import datetime
|
4 | 4 | from types import SimpleNamespace
|
5 | 5 | import os.path
|
| 6 | +import pytest |
6 | 7 |
|
7 | 8 | from yoti_python_sdk.share.extra_data import ExtraData
|
8 | 9 | from yoti_python_sdk.tests import file_helper
|
@@ -64,3 +65,37 @@ def test_should_parse_multiple_issuing_attributes():
|
64 | 65 | assert result.expiry_date == "2019-10-15T22:04:05.123Z"
|
65 | 66 | assert result.attributes[0].name == "com.thirdparty.id"
|
66 | 67 | 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