66from yoti_python_sdk .doc_scan .session .retrieve .id_document_resource_response import (
77 IdDocumentResourceResponse ,
88)
9+ from yoti_python_sdk .doc_scan .session .retrieve .task_response import (
10+ TextExtractionTaskResponse ,
11+ TaskResponse ,
12+ )
913
1014
1115class IdDocumentResourceResponseTest (unittest .TestCase ):
1216 SOME_ID = "someId"
1317 SOME_DOCUMENT_TYPE = "someDocumentType"
1418 SOME_ISSUING_COUNTRY = "someIssuingCountry"
15- SOME_TASKS = [{"first" : "task" }, {"second" : "task" }]
19+ SOME_TASKS = [
20+ {"first" : "task" , "type" : "ID_DOCUMENT_TEXT_DATA_EXTRACTION" },
21+ {"second" : "task" },
22+ ]
1623 SOME_PAGES = [{"first" : "page" }, {"second" : "page" }]
1724 SOME_DOCUMENT_FIELDS = {"media" : {}}
1825
@@ -28,9 +35,9 @@ def test_should_parse_correctly(self):
2835
2936 result = IdDocumentResourceResponse (data )
3037
31- assert result .id is self .SOME_ID
32- assert result .document_type is self .SOME_DOCUMENT_TYPE
33- assert result .issuing_country is self .SOME_ISSUING_COUNTRY
38+ assert result .id == self .SOME_ID
39+ assert result .document_type == self .SOME_DOCUMENT_TYPE
40+ assert result .issuing_country == self .SOME_ISSUING_COUNTRY
3441 assert len (result .tasks ) == 2
3542 assert len (result .pages ) == 2
3643 assert isinstance (result .document_fields , DocumentFieldsResponse )
@@ -45,6 +52,22 @@ def test_should_parse_when_none(self):
4552 assert len (result .pages ) == 0
4653 assert result .document_fields is None
4754
55+ def test_should_parse_tasks_with_type (self ):
56+ data = {
57+ "id" : self .SOME_ID ,
58+ "document_type" : self .SOME_DOCUMENT_TYPE ,
59+ "issuing_country" : self .SOME_ISSUING_COUNTRY ,
60+ "tasks" : self .SOME_TASKS ,
61+ "pages" : self .SOME_PAGES ,
62+ "document_fields" : self .SOME_DOCUMENT_FIELDS ,
63+ }
64+
65+ result = IdDocumentResourceResponse (data )
66+
67+ assert len (result .tasks ) == 2
68+ assert isinstance (result .tasks [0 ], TextExtractionTaskResponse )
69+ assert isinstance (result .tasks [1 ], TaskResponse )
70+
4871
4972if __name__ == "__main__" :
5073 unittest .main ()
0 commit comments