-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from uc-cdis/fix/get-params
Fix/get params
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
pytest==3.0.6 | ||
mock | ||
-e git+https://github.com/uc-cdis/[email protected]#egg=cdisutilstest | ||
-e git+https://github.com/uc-cdis/[email protected]#egg=cdispyutils | ||
-e git+https://github.com/uc-cdis/[email protected]#egg=indexd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,39 @@ | ||
# Python 2 and 3 compatible | ||
try: | ||
from unittest.mock import patch | ||
except ImportError: | ||
from mock import patch | ||
|
||
|
||
def test_import_index(): | ||
''' | ||
Try to import the index package. | ||
''' | ||
import indexclient | ||
|
||
|
||
@patch("indexclient.client.handle_error") | ||
@patch("requests.get") | ||
def test_hashes(get_request_mock, handle_error_mock): | ||
from indexclient.client import IndexClient | ||
input_params = { | ||
'hashes': { | ||
'md5': '00000000000000000000000000000001' | ||
}, | ||
'size': '1' | ||
} | ||
|
||
expected_format = { | ||
'hash': [ | ||
'md5:00000000000000000000000000000001' | ||
], | ||
'size': '1' | ||
} | ||
|
||
with patch("indexclient.client.IndexClient._get") as get_mock: | ||
client = IndexClient('base_url') | ||
client.get_with_params(input_params) | ||
|
||
assert get_mock.called | ||
args, kwargs = get_mock.call_args_list[0] | ||
assert kwargs['params'] == expected_format |