From ede661ead66a836ed915d1060207f88a72d9374b Mon Sep 17 00:00:00 2001 From: mehmet-yoti Date: Mon, 11 May 2026 15:45:48 +0100 Subject: [PATCH] feat(SDK-2781): Python - Add support for new capture_type property on Static Liveness resources [python] --- .../static_liveness_resource_response.py | 11 +++++++ .../retrieve/test_resource_container.py | 22 ++++++++++++++ .../retrieve/test_static_liveness_resource.py | 29 +++++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/yoti_python_sdk/doc_scan/session/retrieve/static_liveness_resource_response.py b/yoti_python_sdk/doc_scan/session/retrieve/static_liveness_resource_response.py index 970258e1..4a4e9b00 100644 --- a/yoti_python_sdk/doc_scan/session/retrieve/static_liveness_resource_response.py +++ b/yoti_python_sdk/doc_scan/session/retrieve/static_liveness_resource_response.py @@ -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): @@ -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 diff --git a/yoti_python_sdk/tests/doc_scan/session/retrieve/test_resource_container.py b/yoti_python_sdk/tests/doc_scan/session/retrieve/test_resource_container.py index 6607d2d9..f32c5c4d 100644 --- a/yoti_python_sdk/tests/doc_scan/session/retrieve/test_resource_container.py +++ b/yoti_python_sdk/tests/doc_scan/session/retrieve/test_resource_container.py @@ -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): @@ -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() diff --git a/yoti_python_sdk/tests/doc_scan/session/retrieve/test_static_liveness_resource.py b/yoti_python_sdk/tests/doc_scan/session/retrieve/test_static_liveness_resource.py index 0037810c..8f57874b 100644 --- a/yoti_python_sdk/tests/doc_scan/session/retrieve/test_static_liveness_resource.py +++ b/yoti_python_sdk/tests/doc_scan/session/retrieve/test_static_liveness_resource.py @@ -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", @@ -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" @@ -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 = {