Skip to content

Commit 0bc7e15

Browse files
committed
add expiration date field
1 parent 554d1c4 commit 0bc7e15

3 files changed

Lines changed: 76 additions & 2 deletions

File tree

mati/types/enums.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,26 @@ 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+
197+
@property
198+
def emission_date(self) -> str:
199+
"""
200+
This property fills the emission date direct from the ocr
201+
fields `emission_date`
202+
"""
203+
if self.fields and 'emission_date' in self.fields:
204+
return self.fields['emission_date']['value']
205+
return ''
206+
187207
def add_expired_step(self) -> None:
188208
'''
189209
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.dev2'

tests/test_types.py

Lines changed: 55 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,57 @@ 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 == ''
74+
75+
76+
def test_emission_date_property():
77+
doc = VerificationDocument(
78+
country='MX',
79+
region='',
80+
photos=[],
81+
steps=[],
82+
type='proof-of-residency',
83+
fields={
84+
'emission_date': {
85+
'value': '2023-01-15',
86+
'label': 'Emission Date',
87+
'format': 'date',
88+
}
89+
},
90+
)
91+
assert doc.emission_date == '2023-01-15'
92+
doc_no_fields = VerificationDocument(
93+
country='MX',
94+
region='',
95+
photos=[],
96+
steps=[],
97+
type='proof-of-residency',
98+
fields=None,
99+
)
100+
assert doc_no_fields.emission_date == ''

0 commit comments

Comments
 (0)