@@ -915,15 +915,17 @@ def setUp(self):
915915 @patch ("vulnerabilities.api_v2.enqueue_ad_hoc_pipeline" )
916916 @patch ("vulnerabilities.models.PipelineRun.objects.get" )
917917 @patch ("vulnerabilities.models.LivePipelineRun.objects.create" )
918+ @patch ("django.urls.reverse" )
918919 def test_evaluate_success (
919- self , mock_live_create , mock_pipeline_get , mock_enqueue , mock_registry
920+ self , mock_reverse , mock_live_create , mock_pipeline_get , mock_enqueue , mock_registry
920921 ):
921922 class MockImporter :
922923 pipeline_id = "pypa_live_importer_v2"
923924 supported_types = ["pypi" ]
924925
925926 mock_registry .values .return_value = [MockImporter ]
926- mock_live_run = type ("MockLiveRun" , (), {"run_id" : "mock-live-id" })()
927+ valid_uuid = "00000000-0000-0000-0000-000000000001"
928+ mock_live_run = type ("MockLiveRun" , (), {"run_id" : valid_uuid })()
927929 mock_live_create .return_value = mock_live_run
928930 mock_enqueue .return_value = "mock-run-id"
929931 mock_pipeline_run = type (
@@ -932,6 +934,7 @@ class MockImporter:
932934 {"run_id" : "mock-run-id" , "live_pipeline" : None , "save" : lambda self : None },
933935 )()
934936 mock_pipeline_get .return_value = mock_pipeline_run
937+ mock_reverse .return_value = f"/api/v2/live-evaluation/status/{ valid_uuid } "
935938
936939 data = {"purl" : "pkg:pypi/django@3.2" }
937940 response = self .client .post (self .url , data , format = "json" )
@@ -940,6 +943,8 @@ class MockImporter:
940943 assert response .data ["live_run_id" ] is not None
941944 assert response .data ["runs" ][0 ]["importer" ] == "pypa_live_importer_v2"
942945 assert response .data ["runs" ][0 ]["run_id" ] is not None
946+ assert "status_url" in response .data
947+ assert response .data ["status_url" ].endswith (f"/api/v2/live-evaluation/status/{ valid_uuid } " )
943948
944949 @patch ("vulnerabilities.api_v2.LIVE_IMPORTERS_REGISTRY" )
945950 def test_evaluate_no_importer_found (self , mock_registry ):
0 commit comments