6
6
from yoti_python_sdk .doc_scan .session .retrieve .id_document_resource_response import (
7
7
IdDocumentResourceResponse ,
8
8
)
9
+ from yoti_python_sdk .doc_scan .session .retrieve .task_response import (
10
+ TextExtractionTaskResponse ,
11
+ TaskResponse ,
12
+ )
9
13
10
14
11
15
class IdDocumentResourceResponseTest (unittest .TestCase ):
12
16
SOME_ID = "someId"
13
17
SOME_DOCUMENT_TYPE = "someDocumentType"
14
18
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
+ ]
16
23
SOME_PAGES = [{"first" : "page" }, {"second" : "page" }]
17
24
SOME_DOCUMENT_FIELDS = {"media" : {}}
18
25
@@ -28,9 +35,9 @@ def test_should_parse_correctly(self):
28
35
29
36
result = IdDocumentResourceResponse (data )
30
37
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
34
41
assert len (result .tasks ) == 2
35
42
assert len (result .pages ) == 2
36
43
assert isinstance (result .document_fields , DocumentFieldsResponse )
@@ -45,6 +52,22 @@ def test_should_parse_when_none(self):
45
52
assert len (result .pages ) == 0
46
53
assert result .document_fields is None
47
54
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
+
48
71
49
72
if __name__ == "__main__" :
50
73
unittest .main ()
0 commit comments