Skip to content

Commit 5923e93

Browse files
committed
add expiration date field
1 parent 554d1c4 commit 5923e93

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

mati/types/enums.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ def ocr_number(self) -> str:
184184
return self.fields['ocr_number']['value']
185185
return ''
186186

187+
@property
188+
def expiration_date(self) -> str:
189+
"""
190+
This property fills the expiration date direct from the ocr
191+
fields `expiration_date`
192+
"""
193+
if self.fields and 'expiration_date' in self.fields:
194+
return self.fields['expiration_date']['value']
195+
return ''
196+
187197
def add_expired_step(self) -> None:
188198
'''
189199
Appends an expired error step to the document if missing.

mati/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '2.0.8'
1+
__version__ = '2.0.9.dev1'

tests/test_types.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from pytest_lazyfixture import lazy_fixture
33

44
from mati.types import ValidationInputType
5-
from mati.types.enums import VerificationDocumentStep
5+
from mati.types.enums import VerificationDocument, VerificationDocumentStep
66

77

88
def test_type_to_str():
@@ -44,3 +44,30 @@ def test_excess_fields():
4444
data = {'some': 'data', 'aditional': 'data', 'id': 'foo', 'status': 10}
4545
VerificationDocumentStep._filter_excess_fields(data)
4646
assert 'some' not in data
47+
48+
49+
def test_expiration_date_property():
50+
doc = VerificationDocument(
51+
country='MX',
52+
region='',
53+
photos=[],
54+
steps=[],
55+
type='national-id',
56+
fields={
57+
'expiration_date': {
58+
'value': '2030-12-31',
59+
'label': 'Date of Expiration',
60+
'format': 'date',
61+
}
62+
},
63+
)
64+
assert doc.expiration_date == '2030-12-31'
65+
doc_no_fields = VerificationDocument(
66+
country='MX',
67+
region='',
68+
photos=[],
69+
steps=[],
70+
type='national-id',
71+
fields=None,
72+
)
73+
assert doc_no_fields.expiration_date == ''

0 commit comments

Comments
 (0)