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
11 changes: 11 additions & 0 deletions yoti_python_sdk/doc_scan/session/retrieve/breakdown_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self, data):
"""
self.__sub_check = data.get("sub_check", None)
self.__result = data.get("result", None)
self.__process = data.get("process", None)
self.__details = [DetailsResponse(detail) for detail in data.get("details", [])]

@property
Expand All @@ -36,6 +37,16 @@ def result(self):
"""
return self.__result

@property
def process(self):
"""
The process of the sub check

:return: the process
:rtype: str or None
"""
return self.__process

@property
def details(self):
"""
Expand Down
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 = data.get("extraction_image_ids", [])

@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 extraction image IDs

: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,6 +8,7 @@
class BreakdownResponseTest(unittest.TestCase):
SOME_SUB_CHECK = "someSubCheck"
SOME_RESULT = "someResult"
SOME_PROCESS = "AUTOMATED"
SOME_DETAILS = [
{"name": "firstDetailName", "value": "firstDetailValue"},
{"name": "secondDetailName", "value": "secondDetailValue"},
Expand All @@ -17,20 +18,23 @@ def test_should_build_correctly(self):
data = {
"sub_check": self.SOME_SUB_CHECK,
"result": self.SOME_RESULT,
"process": self.SOME_PROCESS,
"details": self.SOME_DETAILS,
}

result = BreakdownResponse(data)

assert result.sub_check is self.SOME_SUB_CHECK
assert result.result is self.SOME_RESULT
assert result.process is self.SOME_PROCESS
Comment on lines 27 to +29
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These assertions use is to compare string values. is checks object identity and can be unreliable for strings (interning is an implementation detail), leading to flaky tests. Use == for value equality here (and ideally for the other string assertions in this test as well).

Suggested change
assert result.sub_check is self.SOME_SUB_CHECK
assert result.result is self.SOME_RESULT
assert result.process is self.SOME_PROCESS
assert result.sub_check == self.SOME_SUB_CHECK
assert result.result == self.SOME_RESULT
assert result.process == self.SOME_PROCESS

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary, this will change previous pattern in code.

assert len(result.details) == 2
assert result.details[0].name == "firstDetailName"
assert result.details[0].value == "firstDetailValue"

def test_should_default_details_to_empty_list(self):
result = BreakdownResponse({})
assert len(result.details) == 0
assert result.process is None


if __name__ == "__main__":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
class PageResponseTest(unittest.TestCase):
SOME_CAPTURE_METHOD = "someCaptureMethod"
SOME_FRAMES = [{"first": "frame"}, {"second": "frame"}]
SOME_EXTRACTION_IMAGE_IDS = [
"066a9372-0a52-4fe4-a026-866f8aee6fcb",
"9b0c9c0a-ff30-41ed-815b-d95d63271d45",
]

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_IDS,
}

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

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 len(result.extraction_image_ids) == 0


if __name__ == "__main__":
Expand Down
Loading