Skip to content

Commit 0cddcd6

Browse files
committed
Use git trees to minimize the number of API calls when checking for existence of PURL configuration
1 parent 653bfce commit 0cddcd6

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

tests/test_integrity.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,30 @@ def test_redundant_descriptions(self):
216216

217217
def test_has_purl_config(self):
218218
"""Tests that OBO PURL configuration is available."""
219+
existing_purl_configs = set()
220+
missing = set()
221+
res = requests.get('https://api.github.com/repos/OBOFoundry/purl.obolibrary.org/git/trees/master?recursive=1')
222+
self.assertEqual(
223+
200,
224+
res.status_code,
225+
"Error while fetching Git tree for OBOFoundry/purl.obolibrary.org"
226+
)
227+
data = res.json()
228+
for entry in data['tree']:
229+
if entry['path'].startswith('config/'):
230+
existing_purl_configs.add(entry['path'])
219231
for prefix, record in self.ontologies.items():
220232
if self.skip_inactive(record):
221233
continue
222234
with self.subTest(prefix=prefix):
223-
url = f"https://raw.githubusercontent.com/OBOFoundry/purl.obolibrary.org/master/config/{prefix}.yml"
224-
res = requests.get(url)
225-
self.assertEqual(
226-
200,
227-
res.status_code,
228-
msg=f"PURL configuration is missing for {prefix}",
229-
)
235+
filename = f"config/{prefix}.yml"
236+
if filename not in existing_purl_configs:
237+
missing.add(prefix)
238+
self.assertEqual(
239+
set(),
240+
missing,
241+
msg=f"PURL configuration missing for {', '.join(missing)}"
242+
)
230243

231244

232245
class TestStandardizedYaml(unittest.TestCase):

0 commit comments

Comments
 (0)