-
Couldn't load subscription status.
- Fork 79
Fix 1805 #2093
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
Merged
Merged
Fix 1805 #2093
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
a7925b8
Merge branch 'master' of https://github.com/biocore/qiita into fix-1805
antgonza 9d3fa5c
fix #1805
antgonza a70163b
adding button
antgonza 1626859
fix errors
antgonza ade8cbe
fixing failures tests
antgonza ba2745b
fixing conflicts
antgonza 8e3ec27
fixing errors
antgonza 890d465
fixing errors due to update
antgonza 55fe223
Making the download work
josenavas d96da86
Fixing tests
josenavas 1859c88
Addressing @antgonza's comments
josenavas e90ad50
Adding missing test
josenavas 587e5bf
Ignoring tgz - thanks @antgonza
josenavas 8ef50c1
adding docs
antgonza e6a65a3
addressing @wasade comment
antgonza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| # ----------------------------------------------------------------------------- | ||
| # Copyright (c) 2014--, The Qiita Development Team. | ||
| # | ||
| # Distributed under the terms of the BSD 3-clause License. | ||
| # | ||
| # The full license is in the file LICENSE, distributed with this software. | ||
| # ----------------------------------------------------------------------------- | ||
|
|
||
| from unittest import main | ||
| from mock import Mock | ||
| from os.path import exists, isdir, join | ||
| from os import remove, makedirs | ||
| from shutil import rmtree | ||
| from tempfile import mkdtemp | ||
|
|
||
| from biom.util import biom_open | ||
| from biom import example_table as et | ||
|
|
||
| from qiita_pet.test.tornado_test_base import TestHandlerBase | ||
| from qiita_pet.handlers.base_handlers import BaseHandler | ||
| from qiita_db.user import User | ||
| from qiita_db.artifact import Artifact | ||
| from qiita_db.software import Parameters, Command | ||
|
|
||
|
|
||
| class TestDownloadHandler(TestHandlerBase): | ||
|
|
||
| def setUp(self): | ||
| super(TestDownloadHandler, self).setUp() | ||
|
|
||
| def tearDown(self): | ||
| super(TestDownloadHandler, self).tearDown() | ||
|
|
||
| def test_download(self): | ||
| # check success | ||
| response = self.get('/download/1') | ||
| self.assertEqual(response.code, 200) | ||
| self.assertEqual(response.body, ( | ||
| "This installation of Qiita was not equipped with nginx, so it " | ||
| "is incapable of serving files. The file you attempted to " | ||
| "download is located at raw_data/1_s_G1_L001_sequences.fastq.gz")) | ||
|
|
||
| # failure | ||
| response = self.get('/download/1000') | ||
| self.assertEqual(response.code, 404) | ||
|
|
||
|
|
||
| class TestDownloadStudyBIOMSHandler(TestHandlerBase): | ||
|
|
||
| def setUp(self): | ||
| super(TestDownloadStudyBIOMSHandler, self).setUp() | ||
| self._clean_up_files = [] | ||
|
|
||
| def tearDown(self): | ||
| super(TestDownloadStudyBIOMSHandler, self).tearDown() | ||
| for fp in self._clean_up_files: | ||
| if exists(fp): | ||
| if isdir(fp): | ||
| rmtree(fp) | ||
| else: | ||
| remove(fp) | ||
|
|
||
| def test_download_study(self): | ||
| tmp_dir = mkdtemp() | ||
| self._clean_up_files.append(tmp_dir) | ||
|
|
||
| biom_fp = join(tmp_dir, 'otu_table.biom') | ||
| smr_dir = join(tmp_dir, 'sortmerna_picked_otus') | ||
| log_dir = join(smr_dir, 'seqs_otus.log') | ||
| tgz = join(tmp_dir, 'sortmerna_picked_otus.tgz') | ||
|
|
||
| with biom_open(biom_fp, 'w') as f: | ||
| et.to_hdf5(f, "test") | ||
| makedirs(smr_dir) | ||
| with open(log_dir, 'w') as f: | ||
| f.write('\n') | ||
| with open(tgz, 'w') as f: | ||
| f.write('\n') | ||
|
|
||
| self._clean_up_files.append(tmp_dir) | ||
|
|
||
| files_biom = [(biom_fp, 'biom'), (smr_dir, 'directory'), (tgz, 'tgz')] | ||
|
|
||
| params = Parameters.from_default_params( | ||
| Command(3).default_parameter_sets.next(), {'input_data': 1}) | ||
| a = Artifact.create(files_biom, "BIOM", parents=[Artifact(2)], | ||
| processing_parameters=params) | ||
| for _, fp, _ in a.filepaths: | ||
| self._clean_up_files.append(fp) | ||
|
|
||
| response = self.get('/download_study_bioms/1') | ||
| self.assertEqual(response.code, 200) | ||
| exp = ( | ||
| '- 1256812 /protected/processed_data/1_study_1001_closed_' | ||
| 'reference_otu_table.biom processed_data/1_study_1001_closed_' | ||
| 'reference_otu_table.biom\n' | ||
| '- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-' | ||
| '[0-9]*.txt mapping_files/4_mapping_file.txt\n' | ||
| '- 1256812 /protected/processed_data/' | ||
| '1_study_1001_closed_reference_otu_table.biom processed_data/' | ||
| '1_study_1001_closed_reference_otu_table.biom\n' | ||
| '- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-' | ||
| '[0-9]*.txt mapping_files/5_mapping_file.txt\n' | ||
| '- 1256812 /protected/processed_data/' | ||
| '1_study_1001_closed_reference_otu_table_Silva.biom processed_data' | ||
| '/1_study_1001_closed_reference_otu_table_Silva.biom\n' | ||
| '- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-' | ||
| '[0-9]*.txt mapping_files/6_mapping_file.txt\n' | ||
| '- 36615 /protected/templates/1_prep_2_qiime_[0-9]*-' | ||
| '[0-9]*.txt mapping_files/7_mapping_file.txt\n' | ||
| '- 39752 /protected/BIOM/{0}/otu_table.biom ' | ||
| 'BIOM/{0}/otu_table.biom\n' | ||
| '- 1 /protected/BIOM/{0}/sortmerna_picked_otus/seqs_otus.log ' | ||
| 'BIOM/{0}/sortmerna_picked_otus/seqs_otus.log\n' | ||
| '- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-[0-9]*.' | ||
| 'txt mapping_files/{0}_mapping_file.txt\n'.format(a.id)) | ||
| self.assertRegexpMatches(response.body, exp) | ||
|
|
||
| response = self.get('/download_study_bioms/200') | ||
| self.assertEqual(response.code, 405) | ||
|
|
||
| # changing user so we can test the failures | ||
| BaseHandler.get_current_user = Mock( | ||
| return_value=User("demo@microbio.me")) | ||
| response = self.get('/download_study_bioms/1') | ||
| self.assertEqual(response.code, 405) | ||
|
|
||
| a.visibility = 'public' | ||
| response = self.get('/download_study_bioms/1') | ||
| self.assertEqual(response.code, 200) | ||
| exp = ( | ||
| '- 39752 /protected/BIOM/{0}/otu_table.biom ' | ||
| 'BIOM/{0}/otu_table.biom\n' | ||
| '- 1 /protected/BIOM/{0}/sortmerna_picked_otus/seqs_otus.log ' | ||
| 'BIOM/{0}/sortmerna_picked_otus/seqs_otus.log\n' | ||
| '- 36615 /protected/templates/1_prep_1_qiime_[0-9]*-[0-9]*.' | ||
| 'txt mapping_files/{0}_mapping_file.txt\n'.format(a.id)) | ||
| self.assertRegexpMatches(response.body, exp) | ||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| main() |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a 403?