Skip to content
This repository was archived by the owner on Aug 28, 2025. It is now read-only.

Commit c7d2dc2

Browse files
authored
Merge pull request #57 from upwork/v2.1.0
v2.1.0
2 parents 05e0207 + e3b46b2 commit c7d2dc2

File tree

6 files changed

+15
-9
lines changed

6 files changed

+15
-9
lines changed

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ cache:
44
pip: true
55
matrix:
66
include:
7-
- python: "3.8"
8-
env: NOXSESSION="tests-3.8"
9-
- python: "3.8"
7+
- python: "3.9"
8+
env: NOXSESSION="tests-3.9"
9+
- python: "3.9"
1010
env: NOXSESSION="lint"
1111
dist: xenial
1212
install:

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
nox.options.sessions = ["tests", "lint", "build"]
55

6-
python = ["3.8"]
6+
python = ["3.9"]
77

88

99
lint_dependencies = [

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@
3131
packages=find_packages(),
3232
setup_requires=[],
3333
url="https://github.com/upwork/python-upwork",
34-
version="2.0.1",
34+
version="2.1.0",
3535
zip_safe=False,
3636
)

tests/test_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def test_send_request(self, mocked_get, mocked_post, mocked_put, mocked_delete):
103103
}
104104
)
105105
cl = client.Client(cfg)
106+
cl.requests = requests
106107
assert cl.get("/test/uri", {}) == {"a": "b"}
107108
assert cl.post("/test/uri", {}) == {"a": "b"}
108109
assert cl.put("/test/uri", {}) == {"a": "b"}

upwork/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66

77
__author__ = """Maksym Novozhylov"""
88
__email__ = "mnovozhilov@upwork.com"
9-
__version__ = "2.0.1"
9+
__version__ = "2.1.0"
1010

1111
__all__ = ("Config", "Client", "routers")

upwork/client.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
import requests
1515
from . import upwork
16+
from requests.adapters import HTTPAdapter
17+
from requests.packages.urllib3.util.retry import Retry
1618
from requests_oauthlib import OAuth1 # type: ignore
1719
from urllib.parse import parse_qsl, urlencode
1820

@@ -36,6 +38,9 @@ class Client(object):
3638
def __init__(self, config):
3739
self.config = config
3840

41+
self.requests = requests.Session()
42+
self.requests.mount('https://', HTTPAdapter(max_retries=Retry(total=0)))
43+
3944
def get_request_token(self):
4045
"""Get request token"""
4146
oauth = OAuth1(self.config.consumer_key, self.config.consumer_secret)
@@ -165,13 +170,13 @@ def send_request(self, uri, method="get", params={}):
165170
url = full_url(get_uri_with_format(uri, self.epoint), self.epoint)
166171

167172
if method == "get":
168-
r = requests.get(url, params=params, auth=oauth, verify=self.config.verify_ssl)
173+
r = self.requests.get(url, params=params, auth=oauth, verify=self.config.verify_ssl)
169174
elif method == "put":
170175
headers = {"Content-type": "application/json"}
171-
r = requests.put(url, json=params, headers=headers, auth=oauth, verify=self.config.verify_ssl)
176+
r = self.requests.put(url, json=params, headers=headers, auth=oauth, verify=self.config.verify_ssl)
172177
elif method in {"post", "delete"}:
173178
headers = {"Content-type": "application/json"}
174-
r = requests.post(url, json=params, headers=headers, auth=oauth, verify=self.config.verify_ssl)
179+
r = self.requests.post(url, json=params, headers=headers, auth=oauth, verify=self.config.verify_ssl)
175180
else:
176181
raise ValueError(
177182
'Do not know how to handle http method "{0}"'.format(method)

0 commit comments

Comments
 (0)