Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gdc.py: Show error code of failed download request #20

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions tests/test_gdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def test_download():
os.unlink(file_path)


def test_download_error():
uuid = "something-invalid-0101"
gdc.download(uuid)
Copy link
Collaborator

@ayan-b ayan-b Apr 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start! However, you are not asserting the output to some expected output, so the test is not running. You may take a look at the other tests in the same file for some inspiration. 😃

uuid = "something-invalid-0101"
actual = gdc.download(uuid)
expected = <insert the string here>
assert actual == expected

Also, take a look at the CONTRIBUTING file in #17 .



def test_get_project_info():
project_name = "TCGA-THCA"
assert 'TCGA-BRCA' in gdc.get_project_info().index
Expand All @@ -88,3 +93,6 @@ def test_get_samples_clinical():
project_id = "TCGA-OV"
actual = gdc.get_samples_clinical(project_id)
assert actual['case_id'][0] == "71faa2c1-0d5b-4dcc-bdf9-f2405f29907c"


test_download_error()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need not to execute the function. pytest will discover the test and will run by itself.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I forgot to remove that part after testing locally, will remove it.

4 changes: 3 additions & 1 deletion xena_gdc_etl/gdc.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ def download(uuids, download_dir='.', chunk_size=4096):
sys.stdout.flush()
download_list.append(path)
else:
print('\rFail to download file {}.'.format(uuid))
print('\rFailed to download file {filename}.'
'Error code: {errcode}'.format(filename=uuid,
errcode=response.status_code))
print('')
return download_list

Expand Down