Skip to content

Commit

Permalink
Merge pull request #34 from HumanCellAtlas/jmackey-api-url-fix
Browse files Browse the repository at this point in the history
[EASY] Allow Python bindings to redirect to separate url - hotfix
  • Loading branch information
ttung committed Aug 15, 2017
2 parents 83c9a2e + cf12f99 commit 732bb6c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
3 changes: 2 additions & 1 deletion hca/added_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ def run(cls, args):
query_route = [split_endpoint]
query_route.extend(cls._get_ordered_path_args(args))

base_url = args.get('api_url', cls._get_base_url())
kwargs = args.get('kwargs', {})
base_url = kwargs.get('api_url', cls._get_base_url())
url = base_url + "/" + "/".join(query_route)

query_payload, body_payload, header_payload = cls._build_non_body_payloads(args)
Expand Down
9 changes: 9 additions & 0 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import pprint
from six.moves import reload_module

import requests
import six

pkg_root = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
Expand Down Expand Up @@ -361,6 +362,14 @@ def test_python_bindings(self):
resp = api.put_bundles(bundle_uuid, files=files, creator_uid=1, replica="aws")
self.assertTrue(resp.ok)

def test_python_api_url(self):
kwargs = {'uuid': "fake_uuid",
'replica': "aws",
'api_url': "https://thisisafakeurljslfjlshsfs.com"}
self.assertRaises(requests.exceptions.ConnectionError,
api.get_files,
**kwargs)

def test_python_subscriptions(self):
query = {'bool': {}}
resp = api.put_subscriptions(query=query, callback_url="www.example.com", replica="aws")
Expand Down

0 comments on commit 732bb6c

Please sign in to comment.