Skip to content

Commit

Permalink
Merge branch 'master' into simplify_is_none
Browse files Browse the repository at this point in the history
  • Loading branch information
caffalaughrey committed Sep 7, 2023
2 parents 71ad344 + 219e497 commit 704f4a5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 20 deletions.
11 changes: 0 additions & 11 deletions SalesforcePy/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,17 +254,6 @@ def request(self):
finally:
return response

def set_proxies(self, proxies):
""" Sets `proxies` for this class.
:param proxies: A dict containing proxies to use (see: # noqa
`Proxies <http://docs.python-requests.org/en/master/user/advanced/#proxies)>`_ # noqa
in the python-requests.org guide.
:type: dict
"""
self.proxies = proxies


class OAuthRequest(BaseRequest):
""" Base class for all OAuth request objects
Expand Down
9 changes: 3 additions & 6 deletions SalesforcePy/sfdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ def set_api_version(self, **kwargs):
headers = {'Content-Type': 'application/json'}
r = requests.get(service, headers=headers, proxies=self.proxies)
if r.status_code == 200:
versions = []
for i in r.json():
versions.append(i['version'])
self.client_kwargs.update({'version': max(versions)})
self.client_kwargs.update({'version': max(i['version'] for i in r.json())})
else:
# return a known recent api version
self.client_kwargs.update({'version': DEFAULT_API_VERSION})
Expand Down Expand Up @@ -536,8 +533,8 @@ def request(self, *args):
len_results = len(results)

if len_results == 0:
q = Query(self.session_id, self.instance_url, self.query_string)
q.set_proxies(self.proxies)
q = Query(self.session_id, self.instance_url, self.query_string,
proxies=self.proxies, version=self.api_version)
response = q.request()
results.append(response)
last = response
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pytest==5.4.3
python-coveralls==2.9.1
pytest-flake8==1.0.6
flake8==3.8.2
wheel==0.33.4
wheel==0.38.1
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
'python-coveralls==2.9.1',
'pytest-flake8==1.0.6',
'flake8==3.8.2',
'wheel==0.33.4',
'wheel==0.38.1',
]


Expand Down
22 changes: 21 additions & 1 deletion tests/test_query_more.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import testutil
import responses

import SalesforcePy as sfdc
import testutil


@responses.activate
def test_query_more_singlebatch():
Expand All @@ -13,6 +15,24 @@ def test_query_more_singlebatch():
assert query_result[0][0].get("done")


@responses.activate
def test_query_more_singlebatch_kwargs():
testutil.add_response("login_response_200")
testutil.add_response("query_response_200_version_40")
client = sfdc.client(
username=testutil.username,
password=testutil.password,
client_id=testutil.client_id,
client_secret=testutil.client_secret,
login_url=testutil.login_url,
version="40.0",
)
client.login()
query_result = client.query_more("SELECT Id, Name FROM Account LIMIT 10")
assert query_result[0][0] == testutil.mock_responses["query_response_200_version_40"]["body"]
assert query_result[0][0].get("done")


@responses.activate
def test_query_more_multibatch():
testutil.add_response("login_response_200")
Expand Down

0 comments on commit 704f4a5

Please sign in to comment.