Skip to content

Commit

Permalink
More upload API tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Oct 4, 2017
1 parent 78d1dda commit 8eac80a
Showing 1 changed file with 77 additions and 7 deletions.
84 changes: 77 additions & 7 deletions test/api/test_tools_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@

from galaxy.tools.verify.test_data import TestDataResolver

ONE_TO_SIX_WITH_SPACES = "1 2 3\n4 5 6\n"
ONE_TO_SIX_WITH_TABS = "1\t2\t3\n4\t5\t6\n"
ONE_TO_SIX_ON_WINDOWS = "1\t2\t3\r4\t5\t6\r"


class ToolsUploadTestCase(api.ApiTestCase):

Expand All @@ -21,26 +25,26 @@ def test_upload1_paste(self):
self._assert_has_keys(create_response.json(), 'outputs')

def test_upload_posix_newline_fixes(self):
windows_content = "1\t2\t3\r4\t5\t6\r"
posix_content = windows_content.replace("\r", "\n")
windows_content = ONE_TO_SIX_ON_WINDOWS
result_content = self._upload_and_get_content(windows_content)
self.assertEquals(result_content, posix_content)
self.assertEquals(result_content, ONE_TO_SIX_WITH_TABS)

def test_upload_disable_posix_fix(self):
windows_content = "1\t2\t3\r4\t5\t6\r"
windows_content = ONE_TO_SIX_ON_WINDOWS
result_content = self._upload_and_get_content(windows_content, to_posix_lines=None)
self.assertEquals(result_content, windows_content)

def test_upload_tab_to_space(self):
table = "1 2 3\n4 5 6\n"
table = ONE_TO_SIX_WITH_SPACES
result_content = self._upload_and_get_content(table, space_to_tab="Yes")
self.assertEquals(result_content, "1\t2\t3\n4\t5\t6\n")
self.assertEquals(result_content, ONE_TO_SIX_WITH_TABS)

def test_upload_tab_to_space_off_by_default(self):
table = "1 2 3\n4 5 6\n"
table = ONE_TO_SIX_WITH_SPACES
result_content = self._upload_and_get_content(table)
self.assertEquals(result_content, table)

@skip_without_datatype("rdata")
def test_rdata_not_decompressed(self):
# Prevent regression of https://github.com/galaxyproject/galaxy/issues/753
rdata_path = TestDataResolver().get_filename("1.RData")
Expand Down Expand Up @@ -185,6 +189,72 @@ def test_upload_multiple_files_3(self):
assert datasets[1]["file_ext"] == "txt"
assert datasets[1]["genome_build"] == "hg18", datasets

def test_upload_multiple_files_space_to_tab(self):
with self.dataset_populator.test_history() as history_id:
payload = self.dataset_populator.upload_payload(history_id,
content=ONE_TO_SIX_WITH_SPACES,
file_type="tabular",
dbkey="hg19",
extra_inputs={
"files_0|file_type": "txt",
"files_0|space_to_tab": "Yes",
"files_1|url_paste": ONE_TO_SIX_WITH_SPACES,
"files_1|NAME": "SecondOutputName",
"files_1|file_type": "txt",
"files_2|url_paste": ONE_TO_SIX_WITH_SPACES,
"files_2|NAME": "ThirdOutputName",
"files_2|file_type": "txt",
"files_2|space_to_tab": "Yes",
"file_count": "3",
}
)
run_response = self.dataset_populator.tools_post(payload)
self.dataset_populator.wait_for_tool_run(history_id, run_response)
datasets = run_response.json()["outputs"]

assert len(datasets) == 3, datasets
content = self.dataset_populator.get_history_dataset_content(history_id, dataset=datasets[0])
assert content == ONE_TO_SIX_WITH_TABS

content = self.dataset_populator.get_history_dataset_content(history_id, dataset=datasets[1])
assert content == ONE_TO_SIX_WITH_SPACES

content = self.dataset_populator.get_history_dataset_content(history_id, dataset=datasets[2])
assert content == ONE_TO_SIX_WITH_TABS

def test_multiple_files_posix_lines(self):
with self.dataset_populator.test_history() as history_id:
payload = self.dataset_populator.upload_payload(history_id,
content=ONE_TO_SIX_ON_WINDOWS,
file_type="tabular",
dbkey="hg19",
extra_inputs={
"files_0|file_type": "txt",
"files_0|to_posix_lines": "Yes",
"files_1|url_paste": ONE_TO_SIX_ON_WINDOWS,
"files_1|NAME": "SecondOutputName",
"files_1|file_type": "txt",
"files_1|to_posix_lines": None,
"files_2|url_paste": ONE_TO_SIX_ON_WINDOWS,
"files_2|NAME": "ThirdOutputName",
"files_2|file_type": "txt",
"file_count": "3",
}
)
run_response = self.dataset_populator.tools_post(payload)
self.dataset_populator.wait_for_tool_run(history_id, run_response)
datasets = run_response.json()["outputs"]

assert len(datasets) == 3, datasets
content = self.dataset_populator.get_history_dataset_content(history_id, dataset=datasets[0])
assert content == ONE_TO_SIX_WITH_TABS

content = self.dataset_populator.get_history_dataset_content(history_id, dataset=datasets[1])
assert content == ONE_TO_SIX_ON_WINDOWS

content = self.dataset_populator.get_history_dataset_content(history_id, dataset=datasets[2])
assert content == ONE_TO_SIX_WITH_TABS

def _velvet_upload(self, history_id, extra_inputs):
payload = self.dataset_populator.upload_payload(
history_id,
Expand Down

0 comments on commit 8eac80a

Please sign in to comment.