Skip to content

Commit

Permalink
RCAL-822 Improve Schema Info Test (#344)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
PaulHuwe and pre-commit-ci[bot] authored May 3, 2024
1 parent bb788f4 commit 1fd9ef5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

- Adds test to ensure that the base ``common`` keyword groups exist within the ``schema.info`` tree. [#338]

- Replaced the previous test for ``schema_info`` with something more robust. [#344]

0.19.1 (2024-04-04)
===================

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies = [
"numpy >=1.22",
"astropy >=5.3.0",
# "rad @ git+https://github.com/spacetelescope/rad.git",
"rad >= 0.19.2",
"rad >= 0.19.3",
"asdf-standard >=1.0.3",
]
dynamic = [
Expand Down
22 changes: 19 additions & 3 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@

EXPECTED_COMMON_REFERENCE = {"$ref": "ref_common-1.0.0"}

# Nodes for metadata schema that do not contain any archive_catalog keywords
NODES_LACKING_ARCHIVE_CATALOG = [stnode.OutlierDetection, stnode.MosaicAssociations, stnode.IndividualImageMeta, stnode.Resample]


def datamodel_names():
names = []
Expand Down Expand Up @@ -797,7 +800,7 @@ def test_datamodel_info_search(capsys):
assert result.node == "F158"


def test_datamodel_schema_info():
def test_datamodel_schema_info_values():
wfi_science_raw = utils.mk_level1_science_raw(shape=(2, 8, 8))
af = asdf.AsdfFile()
af.tree = {"roman": wfi_science_raw}
Expand Down Expand Up @@ -829,8 +832,21 @@ def test_datamodel_schema_info():
)
},
}
for keyword in dm.meta.keys():
assert keyword in info["roman"]["meta"]


@pytest.mark.parametrize("name", datamodel_names())
def test_datamodel_schema_info_existence(name):
# Loop over datamodels that have archive_catalog entries
if not name.endswith("RefModel") and name != "AssociationsModel":
method = getattr(datamodels, name)
model = utils.mk_datamodel(method)
info = model.schema_info("archive_catalog")
for keyword in model.meta.keys():
# Only DNodes or LNodes need to be canvassed
if isinstance(model.meta[keyword], (stnode.DNode, stnode.LNode)):
# Ignore metadata schemas that lack archive_catalog entries
if type(model.meta[keyword]) not in NODES_LACKING_ARCHIVE_CATALOG:
assert keyword in info["roman"]["meta"]


def test_crds_parameters(tmp_path):
Expand Down

0 comments on commit 1fd9ef5

Please sign in to comment.