|
45 | 45 | delete_container_image, |
46 | 46 | encode_b64j, |
47 | 47 | execute_job, |
| 48 | + parse_endpoint_invocation_outputs, |
48 | 49 | preload_interactive_algorithms, |
49 | 50 | remove_container_image_from_registry, |
50 | 51 | remove_inactive_container_images, |
@@ -1651,3 +1652,32 @@ def test_stop_expired_endpoints( |
1651 | 1652 | assert len(callbacks) == 1 |
1652 | 1653 | mock_deprovision.assert_called_once() |
1653 | 1654 | 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