Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def __init__(self, data=None):
self.__image = (
ImageResponse(data["image"]) if "image" in data.keys() else None
)
self.__capture_type = data.get("capture_type", None)

@property
def image(self):
Expand All @@ -33,3 +34,13 @@ def image(self):
:rtype: ImageResponse or None
"""
return self.__image

@property
def capture_type(self):
"""
Returns the capture type for the static liveness resource

:return: the capture type
:rtype: str or None
"""
return self.__capture_type
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
from yoti_python_sdk.doc_scan.session.retrieve.resource_container import (
ResourceContainer,
)
from yoti_python_sdk.doc_scan.session.retrieve.static_liveness_resource_response import (
StaticLivenessResourceResponse,
)


class ResourceContainerTest(unittest.TestCase):
Expand Down Expand Up @@ -62,6 +65,25 @@ def test_should_filter_static_liveness_resources(self):
assert len(result.liveness_capture) == 2
assert len(result.static_liveness_resources) == 1

def test_should_expose_capture_type_on_static_liveness_resource(self):
data = {
"liveness_capture": [
{"liveness_type": "STATIC", "capture_type": "PHOTOGRAPH"},
{"liveness_type": "ZOOM"},
]
}

result = ResourceContainer(data)

static_resources = result.static_liveness_resources
assert len(static_resources) == 1
assert isinstance(static_resources[0], StaticLivenessResourceResponse)
assert static_resources[0].capture_type == "PHOTOGRAPH"

zoom_resources = result.zoom_liveness_resources
assert len(zoom_resources) == 1
assert not hasattr(zoom_resources[0], "capture_type")


if __name__ == "__main__":
unittest.main()
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def test_should_parse_static_liveness_resource(self):
"id": "bbbbbbb-5717-4562-b3fc-2c963f66afa6",
"source": {"type": "END_USER"},
"liveness_type": "STATIC",
"capture_type": "PHOTOGRAPH",
"image": {
"media": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
Expand All @@ -27,6 +28,7 @@ def test_should_parse_static_liveness_resource(self):

assert result.id == "bbbbbbb-5717-4562-b3fc-2c963f66afa6"
assert result.liveness_type == "STATIC"
assert result.capture_type == "PHOTOGRAPH"
assert isinstance(result.image, ImageResponse)
assert isinstance(result.image.media, MediaResponse)
assert result.image.media.id == "3fa85f64-5717-4562-b3fc-2c963f66afa6"
Expand All @@ -44,6 +46,33 @@ def test_should_handle_missing_image(self):
assert result.id == "test-id"
assert result.liveness_type == "STATIC"
assert result.image is None
assert result.capture_type is None

def test_should_handle_missing_capture_type(self):
data = {
"id": "test-id",
"liveness_type": "STATIC",
"image": {
"media": {
"id": "media-id-123",
"type": "IMAGE",
"created": "2021-06-11T11:39:24Z",
"last_updated": "2021-06-11T11:39:24Z",
}
},
"tasks": [],
}

result = StaticLivenessResourceResponse(data)

assert result.capture_type is None
assert result.image is not None

def test_should_handle_none_data(self):
result = StaticLivenessResourceResponse(None)

assert result.capture_type is None
assert result.image is None

def test_should_parse_media_id_for_retrieval(self):
data = {
Expand Down
Loading