Skip to content

Commit 5d4312b

Browse files
committed
Fix Live Evaluation API tests #1953
Signed-off-by: Michael Ehab Mikhail <michael.ehab@hotmail.com>
1 parent 54a7d8b commit 5d4312b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

vulnerabilities/tests/test_api_v2.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
# See https://aboutcode.org for more information about nexB OSS projects.
88
#
99

10+
import os
1011
from unittest.mock import patch
1112

1213
from django.contrib.auth.models import User
@@ -919,6 +920,7 @@ class MockImporter:
919920
pipeline_id = "pypa_live_importer_v2"
920921
supported_types = ["pypi"]
921922

923+
os.environ["VULNERABLECODE_ENABLE_LIVE_EVALUATION_API"] = "true"
922924
mock_registry.values.return_value = [MockImporter]
923925
valid_uuid = "00000000-0000-0000-0000-000000000001"
924926
mock_enqueue.return_value = (valid_uuid, ["mock-run-id"])
@@ -940,20 +942,23 @@ class MockImporter:
940942
pipeline_id = "dummy"
941943
supported_types = ["npm"]
942944

945+
os.environ["VULNERABLECODE_ENABLE_LIVE_EVALUATION_API"] = "true"
943946
mock_registry.values.return_value = [MockImporter]
944947
data = {"purl": "pkg:pypi/django@3.2"}
945948
response = self.client.post(self.url, data, format="json")
946949
assert response.status_code == 400
947950
assert "No live importers found" in response.data["error"]
948951

949952
def test_evaluate_invalid_purl(self):
953+
os.environ["VULNERABLECODE_ENABLE_LIVE_EVALUATION_API"] = "true"
950954
data = {"purl": "not_a_valid_purl"}
951955
response = self.client.post(self.url, data, format="json")
952956
assert response.status_code == 400
953957
assert "Invalid PackageURL" in response.data["error"]
954958

955959
@patch("vulnerabilities.models.LivePipelineRun.objects.get")
956960
def test_status_not_found(self, mock_live_get):
961+
os.environ["VULNERABLECODE_ENABLE_LIVE_EVALUATION_API"] = "true"
957962
mock_live_get.side_effect = LivePipelineRun.DoesNotExist()
958963
url = "/api/v2/live-evaluation/status/00000000-0000-0000-0000-000000000000"
959964
response = self.client.get(url)

0 commit comments

Comments
 (0)