Skip to content

Commit 9c173eb

Browse files
fix: test_source_osv.py #4633
1 parent 82ccffd commit 9c173eb

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

test/test_source_osv.py

Lines changed: 20 additions & 12 deletions
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,26 @@ 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+
# Inline parent ecosystem extraction
180+
code_parent_ecosystems = {
181+
ecosystem.split(":")[0] for ecosystem in self.osv.ecosystems
182+
}
183+
184+
# Validate ecosystem consistency
185+
missing_parents = expected_top_level - code_parent_ecosystems
186+
extra_parents = code_parent_ecosystems - expected_top_level
187+
188+
error_msg = []
189+
if missing_parents:
190+
error_msg.append(f"Missing parent ecosystems: {missing_parents}")
191+
if extra_parents:
192+
error_msg.append(f"Unexpected parent ecosystems: {extra_parents}")
193+
if error_msg:
194+
pytest.fail("\n".join(error_msg))
187195

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

0 commit comments

Comments
 (0)