Skip to content

Commit 16ed5d7

Browse files
committed
fix: test_source_osv.py #4633
1 parent 82ccffd commit 16ed5d7

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

test/test_source_osv.py

+21-12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright (C) 2022 Intel Corporation
22
# SPDX-License-Identifier: GPL-3.0-or-later
33

4-
54
import io
65
import shutil
76
import tempfile
@@ -173,17 +172,27 @@ async def test_update_ecosystems(self):
173172
ecosystems_txt = make_http_requests(
174173
"text", url=self.ecosystems_url, timeout=300
175174
).strip("\n")
176-
expected_ecosystems = set(ecosystems_txt.split("\n"))
177-
178-
# Because ecosystems.txt does not contain the complete list, this must be
179-
# manually fixed up.
180-
expected_ecosystems.add("DWF")
181-
expected_ecosystems.add("JavaScript")
182-
183-
# Assert that there are no missing ecosystems
184-
assert all(x in self.osv.ecosystems for x in expected_ecosystems)
185-
# Assert that there are no extra ecosystems
186-
assert all(x in expected_ecosystems for x in self.osv.ecosystems)
175+
expected_top_level = set(ecosystems_txt.split("\n"))
176+
expected_top_level.discard("[EMPTY]") # Remove invalid entry
177+
expected_top_level.update({"DWF", "JavaScript"}) # Manual additions
178+
179+
# Extract parent ecosystems from the result
180+
code_parent_ecosystems = set()
181+
for ecosystem in self.osv.ecosystems:
182+
parent = ecosystem.split(":")[0]
183+
code_parent_ecosystems.add(parent)
184+
185+
# Validate ecosystem consistency
186+
missing_parents = expected_top_level - code_parent_ecosystems
187+
extra_parents = code_parent_ecosystems - expected_top_level
188+
189+
error_msg = []
190+
if missing_parents:
191+
error_msg.append(f"Missing parent ecosystems: {missing_parents}")
192+
if extra_parents:
193+
error_msg.append(f"Unexpected parent ecosystems: {extra_parents}")
194+
if error_msg:
195+
pytest.fail("\n".join(error_msg))
187196

188197
@pytest.mark.asyncio
189198
@pytest.mark.skipif(not EXTERNAL_SYSTEM(), reason="Needs network connection.")

0 commit comments

Comments
 (0)