Skip to content

Commit 82a6bc9

Browse files
authored
Merge pull request #28 from sypht-team/hotfix/reuse_sessions_dependency_bump
Hotfix/reuse sessions dependency bump
2 parents 2a6b395 + 7fef597 commit 82a6bc9

File tree

4 files changed

+19
-14
lines changed

4 files changed

+19
-14
lines changed

requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
requests==2.22.0
1+
requests==2.26.0
2+
urllib3==1.26.0

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from setuptools import find_packages, setup
22

3-
__version__ = "0.5.11"
3+
__version__ = "0.5.12"
44
__pkg_name__ = "sypht"
55

66
setup(
@@ -16,5 +16,5 @@
1616
"Programming Language :: Python :: 3.7",
1717
"Topic :: Scientific/Engineering :: Artificial Intelligence",
1818
],
19-
install_requires=["requests>=2.20.1,<3"],
19+
install_requires=["requests>=2.26.0", "urllib3>=1.26.0"],
2020
)

sypht/client.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,11 @@ def __init__(
7474
def _create_session(self):
7575
return requests.Session()
7676

77-
@staticmethod
78-
def _authenticate_v2(endpoint, client_id, client_secret, audience):
77+
def _authenticate_v2(self, endpoint, client_id, client_secret, audience):
7978
basic_auth_slug = b64encode((client_id + ":" + client_secret).encode("utf-8")).decode(
8079
"utf-8"
8180
)
82-
result = requests.post(
81+
result = self.requests.post(
8382
endpoint,
8483
headers={
8584
"Accept": "application/json",
@@ -95,10 +94,9 @@ def _authenticate_v2(endpoint, client_id, client_secret, audience):
9594

9695
return result["access_token"], result["expires_in"]
9796

98-
@staticmethod
99-
def _authenticate_v1(endpoint, client_id, client_secret, audience):
97+
def _authenticate_v1(self, endpoint, client_id, client_secret, audience):
10098
endpoint = endpoint or os.environ.get("SYPHT_AUTH_ENDPOINT", SYPHT_LEGACY_AUTH_ENDPOINT)
101-
result = requests.post(
99+
result = self.requests.post(
102100
endpoint,
103101
data={
104102
"client_id": client_id,

tests/tests_client.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import os
22
import unittest
33
import warnings
4+
from datetime import datetime, timedelta
5+
from uuid import UUID, uuid4
46

57
from sypht.client import SyphtClient
6-
from uuid import UUID, uuid4
7-
from datetime import datetime, timedelta
88

99

1010
def validate_uuid4(uuid_string):
@@ -25,9 +25,15 @@ def setUp(self):
2525
def test_with_wrong_fieldset(self):
2626
with self.assertRaises(Exception) as context:
2727
with open("tests/sample_invoice.pdf", "rb") as f:
28-
response = self.sypht_client.upload(f, ["sypht.incorrect",])
28+
response = self.sypht_client.upload(
29+
f,
30+
[
31+
"sypht.incorrect",
32+
],
33+
)
2934
self.assertIn(
30-
"does not have permission to use fieldSet sypht.incorrect", response["error"]
35+
"does not have permission to use fieldSet sypht.incorrect",
36+
response["error"],
3137
)
3238

3339
self.assertTrue("Request failed with status code" in str(context.exception))
@@ -61,7 +67,7 @@ def test_data_extraction_2(self):
6167
self.assertIn("bank.bsb", results)
6268

6369
def test_parent_doc_id(self):
64-
parent_doc_id=uuid4()
70+
parent_doc_id = uuid4()
6571
with open("tests/sample_invoice.pdf", "rb") as f:
6672
fid = self.sypht_client.upload(f, ["invoices"], parent_doc_id=parent_doc_id)
6773
self.assertTrue(validate_uuid4(fid))

0 commit comments

Comments
 (0)