Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions examples/yoti_example_django/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,3 @@ wrapt==1.12.1
# via deprecated
yoti==2.14.0
# via -r requirements.in

# The following packages are considered to be unsafe in a requirements file:
# setuptools
11 changes: 11 additions & 0 deletions yoti_python_sdk/doc_scan/session/retrieve/page_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, data=None):
)
self.__media = MediaResponse(data["media"]) if "media" in data.keys() else None
self.__frames = [FrameResponse(frame) for frame in data.get("frames", [])]
self.__extraction_image_ids = list(data.get("extraction_image_ids") or [])

@property
def capture_method(self):
Expand Down Expand Up @@ -53,3 +54,13 @@ def frames(self):
:rtype: list[FrameResponse]
"""
return self.__frames

@property
def extraction_image_ids(self):
"""
Returns the list of media IDs used for automated extraction

:return: the extraction image IDs
:rtype: list[str]
"""
return self.__extraction_image_ids
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@
class PageResponseTest(unittest.TestCase):
SOME_CAPTURE_METHOD = "someCaptureMethod"
SOME_FRAMES = [{"first": "frame"}, {"second": "frame"}]
SOME_EXTRACTION_IMAGE_ID = "066a9372-1ab9-49f0-b390-1b58e08f17f6"
SOME_OTHER_EXTRACTION_IMAGE_ID = "1a2b3c4d-5e6f-7890-abcd-ef1234567890"

def test_should_parse_correctly(self):
data = {
"capture_method": self.SOME_CAPTURE_METHOD,
"media": {},
"frames": self.SOME_FRAMES,
"extraction_image_ids": [
self.SOME_EXTRACTION_IMAGE_ID,
self.SOME_OTHER_EXTRACTION_IMAGE_ID,
],
}

result = PageResponse(data)
Expand All @@ -23,13 +29,46 @@ def test_should_parse_correctly(self):
assert len(result.frames) == 2
assert isinstance(result.frames[0], FrameResponse)
assert isinstance(result.frames[1], FrameResponse)
assert result.extraction_image_ids == [
self.SOME_EXTRACTION_IMAGE_ID,
self.SOME_OTHER_EXTRACTION_IMAGE_ID,
]

def test_should_parse_with_none(self):
result = PageResponse(None)

assert result.capture_method is None
assert result.media is None
assert len(result.frames) == 0
assert result.extraction_image_ids == []

def test_should_parse_extraction_image_ids_with_single_uuid(self):
data = {"extraction_image_ids": [self.SOME_EXTRACTION_IMAGE_ID]}

result = PageResponse(data)

assert result.extraction_image_ids == [self.SOME_EXTRACTION_IMAGE_ID]

def test_should_parse_extraction_image_ids_with_empty_array(self):
data = {"extraction_image_ids": []}

result = PageResponse(data)

assert result.extraction_image_ids == []

def test_should_parse_extraction_image_ids_with_null(self):
data = {"extraction_image_ids": None}

result = PageResponse(data)

assert result.extraction_image_ids == []

def test_should_parse_extraction_image_ids_when_field_absent(self):
data = {"capture_method": self.SOME_CAPTURE_METHOD}

result = PageResponse(data)

assert result.extraction_image_ids == []


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"type": "IMAGE",
"created": "2020-01-30T15:00:00Z",
"last_updated": "2020-01-30T15:00:00Z"
}
},
"extraction_image_ids": ["<uuid>"]
}],
"document_fields": {
"media": {
Expand Down
Loading