From 0cddcd66b074a7cc7fa20a44e8957683a0ad849d Mon Sep 17 00:00:00 2001 From: Deepak Date: Tue, 6 May 2025 16:39:09 +0200 Subject: [PATCH] Use git trees to minimize the number of API calls when checking for existence of PURL configuration --- tests/test_integrity.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/tests/test_integrity.py b/tests/test_integrity.py index 8e5462e01..cf8a8ef80 100644 --- a/tests/test_integrity.py +++ b/tests/test_integrity.py @@ -216,17 +216,30 @@ def test_redundant_descriptions(self): def test_has_purl_config(self): """Tests that OBO PURL configuration is available.""" + existing_purl_configs = set() + missing = set() + res = requests.get('https://api.github.com/repos/OBOFoundry/purl.obolibrary.org/git/trees/master?recursive=1') + self.assertEqual( + 200, + res.status_code, + "Error while fetching Git tree for OBOFoundry/purl.obolibrary.org" + ) + data = res.json() + for entry in data['tree']: + if entry['path'].startswith('config/'): + existing_purl_configs.add(entry['path']) for prefix, record in self.ontologies.items(): if self.skip_inactive(record): continue with self.subTest(prefix=prefix): - url = f"https://raw.githubusercontent.com/OBOFoundry/purl.obolibrary.org/master/config/{prefix}.yml" - res = requests.get(url) - self.assertEqual( - 200, - res.status_code, - msg=f"PURL configuration is missing for {prefix}", - ) + filename = f"config/{prefix}.yml" + if filename not in existing_purl_configs: + missing.add(prefix) + self.assertEqual( + set(), + missing, + msg=f"PURL configuration missing for {', '.join(missing)}" + ) class TestStandardizedYaml(unittest.TestCase):