Skip to content

Commit cae4a50

Browse files
committed
Add test for parsing outputs
1 parent fb17e19 commit cae4a50

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

app/tests/components_tests/test_tasks.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
delete_container_image,
4646
encode_b64j,
4747
execute_job,
48+
parse_endpoint_invocation_outputs,
4849
preload_interactive_algorithms,
4950
remove_container_image_from_registry,
5051
remove_inactive_container_images,
@@ -1651,3 +1652,32 @@ def test_stop_expired_endpoints(
16511652
assert len(callbacks) == 1
16521653
mock_deprovision.assert_called_once()
16531654
assert endpoint_to_stop.status == EndpointStatusChoices.STOPPED
1655+
1656+
1657+
@pytest.mark.django_db
1658+
def test_parse_endpoint_invocation_outputs(settings):
1659+
socket = ComponentInterfaceFactory(kind=InterfaceKindChoices.STRING)
1660+
invocation = InvocationFactory(
1661+
status=InvocationStatusChoices.EXECUTED,
1662+
algorithm_interface__outputs=[socket],
1663+
)
1664+
orchestrator = invocation.orchestrator
1665+
content = json.dumps("test output content").encode("utf-8")
1666+
orchestrator._s3_client.upload_fileobj(
1667+
Fileobj=io.BytesIO(content),
1668+
Bucket=settings.ALGORITHM_ENDPOINTS_OUTPUT_BUCKET_NAME,
1669+
Key=f"{orchestrator._io_prefix}/{socket.relative_path}",
1670+
)
1671+
1672+
assert invocation.outputs.count() == 0
1673+
1674+
parse_endpoint_invocation_outputs(**invocation.task_kwargs)
1675+
invocation.refresh_from_db()
1676+
1677+
assert invocation.error_message == ""
1678+
assert invocation.status == InvocationStatusChoices.SUCCESS
1679+
assert invocation.outputs.count() == 1
1680+
1681+
civ = invocation.outputs.first()
1682+
1683+
assert civ.value == "test output content"

0 commit comments

Comments
 (0)