Skip to content

Commit

Permalink
Add test for absolute refs
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamJamieson committed Dec 30, 2024
1 parent e430bcf commit 43379fa
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from collections.abc import Mapping

import asdf
import asdf.treeutil
import pytest
import yaml
from crds.config import is_crds_name
Expand Down Expand Up @@ -312,3 +313,23 @@ def callback(node):
assert len(node) == 1

asdf.treeutil.walk(schema, callback)


@pytest.mark.parametrize("uri", SCHEMA_URIS)
def test_absolute_ref(uri):
"""
Test that all $ref are absolute URIs matching those registered with ASDF
"""
schema = asdf.schema.load_schema(uri)
resources = asdf.config.get_config().resource_manager

def callback(node):
if not isinstance(node, dict):
return
if "$ref" not in node:
return

# Check that the $ref is a full URI registered with ASDF
assert node["$ref"] in resources

asdf.treeutil.walk(schema, callback)

0 comments on commit 43379fa

Please sign in to comment.