Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCAL-822 Improve Schema Info Test #344

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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]

- Pleaced the previous test for ``schema_info`` with something more robust. [#344]
PaulHuwe marked this conversation as resolved.
Show resolved Hide resolved

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pleaced? maybe Replaced?

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