Skip to content

Commit

Permalink
touched site upload URL
Browse files Browse the repository at this point in the history
  • Loading branch information
dogversioning committed Aug 14, 2023
1 parent 126b9b4 commit 2e259f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/handlers/site_upload/fetch_upload_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def upload_url_handler(event, context):
res = create_presigned_post(
os.environ.get("BUCKET_NAME"),
f"{BucketPath.UPLOAD.value}/{body['study']}/{body['data_package']}/"
f"{int(version):03d}/{metadata_db[user]['path']}/{body['filename']}",
f"{metadata_db[user]['path']}/{int(version):03d}/{body['filename']}",
)
return res
2 changes: 1 addition & 1 deletion src/handlers/site_upload/powerset_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def __init__(self, event):
self.data_package = s3_key_array[2].split("__")[1]
self.site = s3_key_array[3]
self.version = s3_key_array[4]

self.metadata = read_metadata(self.s3_client, self.s3_bucket_name)
print(s3_key_array)

# S3 Filesystem operations
def get_data_package_list(self, path) -> list:
Expand Down
11 changes: 10 additions & 1 deletion tests/site_upload/test_fetch_upload_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import boto3
import pytest

from src.handlers.shared.enums import BucketPath
from src.handlers.site_upload.fetch_upload_url import upload_url_handler
from tests.utils import (
EXISTING_DATA_P,
EXISTING_SITE,
EXISTING_STUDY,
EXISTING_VERSION,
TEST_BUCKET,
Expand Down Expand Up @@ -36,9 +38,16 @@ def test_fetch_upload_url(body, status, mock_bucket):
"principalId": "ppth",
}
}

response = upload_url_handler(
{"body": json.dumps(body), "requestContext": context}, None
)
print(response)
assert response["statusCode"] == status
if response["statusCode"] == 200:
res_body = json.loads(response["body"])
assert res_body["fields"]["key"] == (
f"{BucketPath.UPLOAD.value}/{body['study']}/{body['data_package']}/"
f"{EXISTING_SITE}/{body['data_package_version']}/encounter.parquet"
)

assert "Access-Control-Allow-Origin" not in response["headers"]

0 comments on commit 2e259f9

Please sign in to comment.