|
1 | 1 | # Copyright (C) 2022 Intel Corporation
|
2 | 2 | # SPDX-License-Identifier: GPL-3.0-or-later
|
3 | 3 |
|
4 |
| - |
5 | 4 | import io
|
6 | 5 | import shutil
|
7 | 6 | import tempfile
|
@@ -173,17 +172,27 @@ async def test_update_ecosystems(self):
|
173 | 172 | ecosystems_txt = make_http_requests(
|
174 | 173 | "text", url=self.ecosystems_url, timeout=300
|
175 | 174 | ).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)) |
187 | 196 |
|
188 | 197 | @pytest.mark.asyncio
|
189 | 198 | @pytest.mark.skipif(not EXTERNAL_SYSTEM(), reason="Needs network connection.")
|
|
0 commit comments