Skip to content

Commit 5dfad7f

Browse files
authored
Merge pull request #6 from getyoti/release-1.0.1
Release 1.0.1
2 parents 6b8466d + 95a346c commit 5dfad7f

File tree

4 files changed

+38
-5
lines changed

4 files changed

+38
-5
lines changed

yoti_python_sandbox/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ def setup_sharing_profile(self, request_token):
6262

6363
response_payload = signed_request.execute()
6464
if response_payload.status_code < 200 or response_payload.status_code >= 300:
65-
raise SandboxException("Error making request to sandbox service: " + response_payload.status_code, response_payload)
65+
raise SandboxException("Error making request to sandbox service: "
66+
+ str(response_payload.status_code), response_payload)
6667

6768
parsed = json.loads(response_payload.text)
6869
return YotiTokenResponse(parsed["token"])

yoti_python_sandbox/tests/mocks.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from yoti_python_sdk.http import YotiResponse
2+
3+
4+
class MockResponse(YotiResponse):
5+
def __init__(self, status_code, text):
6+
super(MockResponse, self).__init__(status_code, text)
7+
8+
9+
def mocked_request_failed_sandbox_token():
10+
return MockResponse(500, "Org not found")

yoti_python_sandbox/tests/test_sandbox_client.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
from yoti_python_sandbox.tests.conftest import PEM_FILE_PATH
33
from yoti_python_sandbox.token import YotiTokenRequest
44
from yoti_python_sandbox.token import YotiTokenResponse
5+
from .mocks import mocked_request_failed_sandbox_token
6+
from ..sandbox_exception import SandboxException
57

68
try:
7-
from unittest.mock import patch
9+
from unittest import mock
810
except ImportError:
9-
from mock import patch
11+
import mock
1012

1113
import pytest
1214

@@ -36,7 +38,7 @@ def test_builder_should_build_client():
3638
assert isinstance(client, SandboxClient)
3739

3840

39-
@patch("yoti_python_sandbox.client.SandboxClient")
41+
@mock.patch("yoti_python_sandbox.client.SandboxClient")
4042
def test_client_should_return_token_from_sandbox(sandbox_client_mock):
4143
sandbox_client_mock.setup_profile_share.return_value = YotiTokenResponse(
4244
"some-token"
@@ -48,3 +50,23 @@ def test_client_should_return_token_from_sandbox(sandbox_client_mock):
4850
response = sandbox_client_mock.setup_profile_share(token_request)
4951

5052
assert response.token == "some-token"
53+
54+
55+
@mock.patch("yoti_python_sdk.http.SignedRequest.execute", side_effect=mocked_request_failed_sandbox_token)
56+
def test_client_should_bubble_sandbox_exception(_):
57+
client = (
58+
SandboxClient.builder()
59+
.for_application("some_app")
60+
.with_pem_file(PEM_FILE_PATH)
61+
.with_sandbox_url("https://localhost")
62+
.build()
63+
)
64+
65+
token_request = (
66+
YotiTokenRequest.builder().with_remember_me_id("remember_me_pls").build()
67+
)
68+
69+
with pytest.raises(SandboxException) as ex:
70+
client.setup_sharing_profile(token_request)
71+
assert isinstance(ex.value, SandboxException)
72+
assert ex.value.text == "Org not found"

yoti_python_sandbox/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.0.0"
1+
__version__ = "1.0.1"

0 commit comments

Comments
 (0)