Skip to content

Commit

Permalink
Merge pull request #186 from getyoti/hotfix-2.11.1
Browse files Browse the repository at this point in the history
Hotfix 2.11.1
  • Loading branch information
MrBurtyyy authored Apr 27, 2020
2 parents ec94e79 + 145edfd commit e52b149
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 30 deletions.
1 change: 1 addition & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[run]
omit =
yoti_python_sdk/version.py
yoti_python_sdk/tests/**
yoti_python_sdk/protobuf/**/*
examples/**
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sonar.host.url = https://sonarcloud.io
sonar.organization = getyoti
sonar.projectKey = getyoti:python
sonar.projectName = Python SDK
sonar.projectVersion = 2.11.0
sonar.projectVersion = 2.11.1
sonar.exclusions = yoti_python_sdk/tests/**,examples/**,yoti_python_sdk/protobuf/**/*

sonar.python.pylint.reportPath = coverage.out
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
DocumentFieldsResponse,
)
from yoti_python_sdk.doc_scan.session.retrieve.page_response import PageResponse
from yoti_python_sdk.doc_scan.session.retrieve.task_response import TaskResponse
from yoti_python_sdk.doc_scan.session.retrieve.resource_response import ResourceResponse


class IdDocumentResourceResponse(object):
class IdDocumentResourceResponse(ResourceResponse):
"""
Represents an Identity Document resource for a given session
"""
Expand All @@ -21,37 +21,17 @@ def __init__(self, data=None):
if data is None:
data = dict()

self.__id = data.get("id", None)
ResourceResponse.__init__(self, data)

self.__document_type = data.get("document_type", None)
self.__issuing_country = data.get("issuing_country", None)
self.__tasks = [TaskResponse(task) for task in data.get("tasks", [])]
self.__pages = [PageResponse(page) for page in data.get("pages", [])]
self.__document_fields = (
DocumentFieldsResponse(data["document_fields"])
if "document_fields" in data.keys()
else None
)

@property
def id(self):
"""
Returns the ID of the identity document
:return: the ID
:rtype: str or None
"""
return self.__id

@property
def tasks(self):
"""
Returns all associated tasks of the identity document
:return: the associated tasks
:rtype: list[TaskResponse]
"""
return self.__tasks

@property
def document_type(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@
from yoti_python_sdk.doc_scan.session.retrieve.id_document_resource_response import (
IdDocumentResourceResponse,
)
from yoti_python_sdk.doc_scan.session.retrieve.task_response import (
TextExtractionTaskResponse,
TaskResponse,
)


class IdDocumentResourceResponseTest(unittest.TestCase):
SOME_ID = "someId"
SOME_DOCUMENT_TYPE = "someDocumentType"
SOME_ISSUING_COUNTRY = "someIssuingCountry"
SOME_TASKS = [{"first": "task"}, {"second": "task"}]
SOME_TASKS = [
{"first": "task", "type": "ID_DOCUMENT_TEXT_DATA_EXTRACTION"},
{"second": "task"},
]
SOME_PAGES = [{"first": "page"}, {"second": "page"}]
SOME_DOCUMENT_FIELDS = {"media": {}}

Expand All @@ -28,9 +35,9 @@ def test_should_parse_correctly(self):

result = IdDocumentResourceResponse(data)

assert result.id is self.SOME_ID
assert result.document_type is self.SOME_DOCUMENT_TYPE
assert result.issuing_country is self.SOME_ISSUING_COUNTRY
assert result.id == self.SOME_ID
assert result.document_type == self.SOME_DOCUMENT_TYPE
assert result.issuing_country == self.SOME_ISSUING_COUNTRY
assert len(result.tasks) == 2
assert len(result.pages) == 2
assert isinstance(result.document_fields, DocumentFieldsResponse)
Expand All @@ -45,6 +52,22 @@ def test_should_parse_when_none(self):
assert len(result.pages) == 0
assert result.document_fields is None

def test_should_parse_tasks_with_type(self):
data = {
"id": self.SOME_ID,
"document_type": self.SOME_DOCUMENT_TYPE,
"issuing_country": self.SOME_ISSUING_COUNTRY,
"tasks": self.SOME_TASKS,
"pages": self.SOME_PAGES,
"document_fields": self.SOME_DOCUMENT_FIELDS,
}

result = IdDocumentResourceResponse(data)

assert len(result.tasks) == 2
assert isinstance(result.tasks[0], TextExtractionTaskResponse)
assert isinstance(result.tasks[1], TaskResponse)


if __name__ == "__main__":
unittest.main()
2 changes: 1 addition & 1 deletion yoti_python_sdk/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# -*- coding: utf-8 -*-
__version__ = "2.11.0"
__version__ = "2.11.1"

0 comments on commit e52b149

Please sign in to comment.