Skip to content

Commit 3b10f4a

Browse files
committed
fix failing test
Signed-off-by: tdruez <tdruez@aboutcode.org>
1 parent d91b5c5 commit 3b10f4a

2 files changed

Lines changed: 21 additions & 11 deletions

File tree

product_portfolio/tests/test_importers.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,9 +1507,26 @@ def test_product_portfolio_import_packages_from_scio_importer_is_reachable_not_o
15071507
self.assertFalse(analysis.is_reachable)
15081508

15091509
# A second import with a conflicting value must not overwrite the existing one.
1510-
mock_fetch_packages.return_value[0]["affected_by_vulnerabilities"][0]["is_reachable"] = (
1511-
"yes"
1512-
)
1510+
# Reassign return_value because import_package pops "affected_by_vulnerabilities".
1511+
mock_fetch_packages.return_value = [
1512+
{
1513+
"purl": "pkg:maven/abc/abc@1.0",
1514+
"type": "maven",
1515+
"namespace": "abc",
1516+
"name": "abc",
1517+
"version": "1.0",
1518+
"affected_by_vulnerabilities": [
1519+
{
1520+
"advisory_uid": "github_osv/GHSA-existing",
1521+
"summary": "A vulnerability",
1522+
"is_reachable": "yes",
1523+
"cdx_vulnerability_data": {
1524+
"analysis": {"state": "in_triage", "detail": "Under review"},
1525+
},
1526+
}
1527+
],
1528+
}
1529+
]
15131530
importer2 = ImportPackageFromScanCodeIO(
15141531
user=self.super_user,
15151532
project_uuid=uuid.uuid4(),
@@ -1556,4 +1573,4 @@ def test_product_portfolio_import_packages_from_scio_importer_is_reachable_witho
15561573
vulnerability__advisory_uid="github_osv/GHSA-no-cdx"
15571574
)
15581575
self.assertTrue(analysis.is_reachable)
1559-
self.assertIsNone(analysis.state)
1576+
self.assertFalse(analysis.state)

vulnerabilities/triage/tests/test_engine.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,6 @@ def test_updates_an_existing_preset_owned_analysis(self):
145145
self.assertEqual(second_preset, analysis.applied_by_preset)
146146
self.assertEqual(1, VulnerabilityAnalysis.objects.count())
147147

148-
def test_skips_creation_when_the_preset_has_no_content_field_set(self):
149-
# An AnalysisPreset always requires at least one content field to be saved (see
150-
# VulnerabilityAnalysisContentMixin.save), so this can only happen with an in-memory
151-
# preset. This exercises the defensive guard against saving a content-less analysis.
152-
content_less_preset = AnalysisPreset(dataspace=self.dataspace, is_reachable=True)
153-
apply_preset_for_vulnerabilities(content_less_preset, self.product, [self.vulnerability.pk])
154-
self.assertFalse(VulnerabilityAnalysis.objects.exists())
155148

156149
def test_does_nothing_when_no_product_package_carries_the_vulnerability(self):
157150
other_package = make_package(self.dataspace)

0 commit comments

Comments
 (0)