Add simple API test for tus endpoint

This commit is contained in:
mvdbeek
2021-10-12 13:34:55 +02:00
parent d08a08ac4c
commit 32065d123a
3 changed files with 34 additions and 0 deletions
@@ -2,6 +2,7 @@
adal==1.2.7
aiofiles==0.6.0
aiotus==0.1.10
alabaster==0.7.12; python_version >= "3.5"
amqp==5.0.6; python_version >= "3.6"
appdirs==1.4.4; python_version >= "3.6"
+32
View File
@@ -1,5 +1,8 @@
import asyncio
import json
import os
import aiotus
import pytest
from galaxy.tool_util.verify.test_data import TestDataResolver
@@ -906,3 +909,32 @@ class ToolsUploadTestCase(ApiTestCase):
new_dataset = self.dataset_populator.fetch(payload, assert_ok=assert_ok).json()["outputs"][0]
self.dataset_populator.wait_for_history(history_id, assert_ok=assert_ok)
return history_id, new_dataset
def test_upload_dataset_resumable(self):
async def upload_file(url, path, api_key, history_id, ):
filename = os.path.basename(path)
metadata = {
'filename': filename.encode(),
'history_id': history_id.encode(),
}
headers = {'x-api-key': api_key}
# Upload a file to a tus server.
with open(path, "rb") as f:
location = await aiotus.upload(url, f, metadata, headers=headers)
# 'location' is the URL where the file was uploaded to.
# Read back the metadata from the server.
return await aiotus.metadata(location, headers=headers)
loop = asyncio.get_event_loop()
with self.dataset_populator.test_history() as history_id:
future = upload_file(url=f"{self.url}/api/upload/resumable_upload", path=TestDataResolver().get_filename("1.fastqsanger.gz"), api_key=self.galaxy_interactor.api_key, history_id=history_id)
result = loop.run_until_complete(future)
assert result['filename']
assert result['history_id']
self.dataset_populator.wait_for_history(history_id, assert_ok=True)
dataset = self.dataset_populator.get_history_dataset_details(history_id)
assert dataset['name'] == '1.fastqsanger.gz'
assert dataset['file_ext'] == 'fastqsanger.gz'
+1
View File
@@ -87,6 +87,7 @@ Whoosh = "*"
zipstream-new = "*"
[tool.poetry.dev-dependencies]
aiotus = "*"
fluent-logger = "*"
httpx = "*"
gunicorn = "*"