Skip to content

Commit 172b07d

Browse files
Merge pull request #332 from getyoti/feature/handoff_flag
[SDK-1998] adding handoff flag
2 parents 1a7a0a0 + 3838647 commit 172b07d

File tree

4 files changed

+47
-4
lines changed

4 files changed

+47
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,4 @@ examples/yoti_example_django/*.pem
105105
examples/yoti_example_flask/*.pem
106106

107107
.scannerwork
108+
.venv/

yoti_python_sdk/doc_scan/session/create/sdk_config.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def __init__(
2121
preset_issuing_country,
2222
success_url,
2323
error_url,
24+
allow_handoff=None,
2425
privacy_policy_url=None,
2526
):
2627
"""
@@ -42,6 +43,8 @@ def __init__(
4243
:type error_url: str
4344
:param privacy_policy_url: the privacy policy url
4445
:type privacy_policy_url: str
46+
:param allow_handoff: boolean flag for allow_handoff
47+
:type allow_handoff: bool
4548
"""
4649
self.__allowed_capture_methods = allowed_capture_methods
4750
self.__primary_colour = primary_colour
@@ -52,6 +55,7 @@ def __init__(
5255
self.__success_url = success_url
5356
self.__error_url = error_url
5457
self.__privacy_policy_url = privacy_policy_url
58+
self.__allow_handoff = allow_handoff
5559

5660
@property
5761
def allowed_capture_methods(self):
@@ -134,6 +138,16 @@ def privacy_policy_url(self):
134138
"""
135139
return self.__privacy_policy_url
136140

141+
@property
142+
def allow_handoff(self):
143+
"""
144+
Flag to enable/disable relying business to handoff
145+
support when creating a session.
146+
147+
:return: the allow_handoff
148+
"""
149+
return self.__allow_handoff
150+
137151
def to_json(self):
138152
return remove_null_values(
139153
{
@@ -146,6 +160,7 @@ def to_json(self):
146160
"success_url": self.success_url,
147161
"error_url": self.error_url,
148162
"privacy_policy_url": self.privacy_policy_url,
163+
"allow_handoff": self.allow_handoff,
149164
}
150165
)
151166

@@ -165,6 +180,7 @@ def __init__(self):
165180
self.__success_url = None
166181
self.__error_url = None
167182
self.__privacy_policy_url = None
183+
self.__allow_handoff = None
168184

169185
def with_allowed_capture_methods(self, allowed_capture_methods):
170186
"""
@@ -292,6 +308,18 @@ def with_privacy_policy_url(self, url):
292308
self.__privacy_policy_url = url
293309
return self
294310

311+
def with_allow_handoff(self, flag):
312+
"""
313+
Sets the allow handoff flag
314+
315+
:param flag: boolean value for flag
316+
:type flag: bool
317+
:return: the builder
318+
:rtype: SdkConfigBuilder
319+
"""
320+
self.__allow_handoff = flag
321+
return self
322+
295323
def build(self):
296324
return SdkConfig(
297325
self.__allowed_capture_methods,
@@ -302,5 +330,6 @@ def build(self):
302330
self.__preset_issuing_country,
303331
self.__success_url,
304332
self.__error_url,
333+
self.__allow_handoff,
305334
self.__privacy_policy_url,
306335
)

yoti_python_sdk/tests/doc_scan/session/create/test_sdk_config.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class SdkConfigTest(unittest.TestCase):
1515
SOME_SUCCESS_URL = "https://mysite.com/yoti/success"
1616
SOME_ERROR_URL = "https://mysite.com/yoti/error"
1717
SOME_PRIVACY_POLICY_URL = "https://mysite.com/privacy"
18+
SOME_ALLOW_HANDOFF = True
1819

1920
def test_should_build_correctly(self):
2021
result = (
@@ -28,6 +29,7 @@ def test_should_build_correctly(self):
2829
.with_success_url(self.SOME_SUCCESS_URL)
2930
.with_error_url(self.SOME_ERROR_URL)
3031
.with_privacy_policy_url(self.SOME_PRIVACY_POLICY_URL)
32+
.with_allow_handoff(self.SOME_ALLOW_HANDOFF)
3133
.build()
3234
)
3335

@@ -41,12 +43,23 @@ def test_should_build_correctly(self):
4143
assert result.success_url is self.SOME_SUCCESS_URL
4244
assert result.error_url is self.SOME_ERROR_URL
4345
assert result.privacy_policy_url is self.SOME_PRIVACY_POLICY_URL
46+
assert result.allow_handoff is True
4447

4548
def test_should_allows_camera(self):
4649
result = SdkConfigBuilder().with_allows_camera().build()
4750

4851
assert result.allowed_capture_methods == "CAMERA"
4952

53+
def test_not_passing_allow_handoff(self):
54+
result = SdkConfigBuilder().with_allows_camera().build()
55+
56+
assert result.allow_handoff is None
57+
58+
def test_passing_allow_handoff_false_value(self):
59+
result = SdkConfigBuilder().with_allow_handoff(False).build()
60+
61+
assert result.allow_handoff is False
62+
5063
def test_should_serialize_to_json_without_error(self):
5164
result = (
5265
SdkConfigBuilder()

yoti_python_sdk/tests/test_anchor.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# -*- coding: utf-8 -*-
22
import logging
3+
import pytz
34
import time
45
from datetime import datetime
56

6-
from yoti_python_sdk.protobuf.attribute_public_api import Attribute_pb2
7-
87
import yoti_python_sdk
98
from yoti_python_sdk import config
109
from yoti_python_sdk.anchor import Anchor
10+
from yoti_python_sdk.protobuf.attribute_public_api import Attribute_pb2
1111
from yoti_python_sdk.tests import anchor_fixture_parser
1212

1313

@@ -118,8 +118,8 @@ def test_processing_unknown_anchor_data():
118118
(anchor.value, anchor.anchor_type, anchor.sub_type) for anchor in anchors
119119
]
120120

121-
expected_timestamp = datetime(2019, 3, 5, 10, 45, 11, 840037)
122-
actual_timestamp = anchors[0].signed_timestamp
121+
expected_timestamp = datetime(2019, 3, 5, 10, 45, 11, 840037).replace(tzinfo=None)
122+
actual_timestamp = anchors[0].signed_timestamp.astimezone(pytz.utc).replace(tzinfo=None)
123123

124124
assert expected_timestamp == actual_timestamp
125125

0 commit comments

Comments
 (0)