|
1 | 1 | # Copyright (C) 2022 Intel Corporation
|
2 | 2 | # SPDX-License-Identifier: GPL-3.0-or-later
|
3 | 3 |
|
4 |
| - |
| 4 | +import asyncio |
5 | 5 | import io
|
6 | 6 | import shutil
|
7 | 7 | import tempfile
|
@@ -169,21 +169,26 @@ def teardown_class(cls):
|
169 | 169 | @pytest.mark.skipif(not EXTERNAL_SYSTEM(), reason="Needs network connection.")
|
170 | 170 | async def test_update_ecosystems(self):
|
171 | 171 | await self.osv.update_ecosystems()
|
172 |
| - |
173 |
| - ecosystems_txt = make_http_requests( |
174 |
| - "text", url=self.ecosystems_url, timeout=300 |
175 |
| - ).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) |
| 172 | + loop = asyncio.get_running_loop() |
| 173 | + ecosystems_txt = await loop.run_in_executor( |
| 174 | + None, |
| 175 | + lambda: make_http_requests("text", url=self.ecosystems_url, timeout=300), |
| 176 | + ) |
| 177 | + expected_top_level = set(ecosystems_txt.strip().split("\n")) |
| 178 | + |
| 179 | + # Validate parent ecosystems |
| 180 | + code_parent_ecosystems = {e.split(":")[0] for e in self.osv.ecosystems} |
| 181 | + expected_top_level.discard("[EMPTY]") |
| 182 | + missing_parents = expected_top_level - code_parent_ecosystems |
| 183 | + extra_parents = code_parent_ecosystems - expected_top_level |
| 184 | + |
| 185 | + if missing_parents or extra_parents: |
| 186 | + error_msg = [] |
| 187 | + if missing_parents: |
| 188 | + error_msg.append(f"Missing parent ecosystems: {missing_parents}") |
| 189 | + if extra_parents: |
| 190 | + error_msg.append(f"Unexpected parent ecosystems: {extra_parents}") |
| 191 | + pytest.fail("\n".join(error_msg)) |
187 | 192 |
|
188 | 193 | @pytest.mark.asyncio
|
189 | 194 | @pytest.mark.skipif(not EXTERNAL_SYSTEM(), reason="Needs network connection.")
|
|
0 commit comments