Skip to content

Commit

Permalink
feat: add ID to intermediate response body, add future-proofing check…
Browse files Browse the repository at this point in the history
…s for async hub operations in integration tests
  • Loading branch information
mjugl committed Oct 17, 2024
1 parent 410e008 commit b073aef
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions project/routers/intermediate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

class IntermediateUploadResponse(BaseModel):
url: HttpUrl
object_id: uuid.UUID


@router.put(
Expand Down Expand Up @@ -64,6 +65,7 @@ async def submit_intermediate_result_to_hub(
)

return IntermediateUploadResponse(
object_id=bucket_file.id,
url=str(
request.url_for(
"retrieve_intermediate_result_from_hub",
Expand Down
7 changes: 6 additions & 1 deletion tests/test_final.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,18 @@
from starlette import status

from tests.common.auth import issue_client_access_token, BearerAuth
from tests.common.helpers import next_random_bytes
from tests.common.helpers import next_random_bytes, eventually
from tests.common.rest import wrap_bytes_for_request

pytestmark = pytest.mark.live


def test_200_submit_to_upload(test_client, rng, core_client, analysis_id):
def _check_result_bucket_exists():
return core_client.get_analysis_bucket(analysis_id, "RESULT") is not None

assert eventually(_check_result_bucket_exists)

analysis_file_count_old = len(core_client.get_analysis_bucket_file_list().data)

blob = next_random_bytes(rng)
Expand Down
10 changes: 8 additions & 2 deletions tests/test_intermediate.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@

from project.routers.intermediate import IntermediateUploadResponse
from tests.common.auth import BearerAuth, issue_client_access_token
from tests.common.helpers import next_random_bytes
from tests.common.helpers import next_random_bytes, eventually
from tests.common.rest import wrap_bytes_for_request, detail_of

pytestmark = pytest.mark.live


def test_200_submit_receive_intermediate(test_client, rng, analysis_id):
def test_200_submit_receive_intermediate(test_client, rng, analysis_id, core_client):
def _check_temp_bucket_exists():
return core_client.get_analysis_bucket(analysis_id, "TEMP") is not None

assert eventually(_check_temp_bucket_exists)

blob = next_random_bytes(rng)
r = test_client.put(
"/intermediate",
Expand All @@ -23,6 +28,7 @@ def test_200_submit_receive_intermediate(test_client, rng, analysis_id):

# check that the response contains a path to a valid resource
model = IntermediateUploadResponse(**r.json())
assert str(model.object_id) in str(model.url.path)

r = test_client.get(
model.url.path,
Expand Down

0 comments on commit b073aef

Please sign in to comment.