Skip to content

Commit

Permalink
Update datamodel_name and add datamodel_name tests
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamJamieson committed Jul 20, 2023
1 parent 769041d commit ba41bfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ id: asdf://stsci.edu/datamodels/roman/schemas/reference_files/inverselinearity-1

title: Inverse linearity correction reference schema

datamodel_name: InverseLinearityRefModel
datamodel_name: InverselinearityRefModel

type: object
properties:
Expand Down
17 changes: 17 additions & 0 deletions tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,23 @@ def callback(node):
asdf.treeutil.walk(schema, callback)


def _model_name_from_schema_uri(schema_uri):
schema_name = schema_uri.split("/")[-1].split("-")[0]
class_name = "".join([p.capitalize() for p in schema_name.split("_")])
if schema_uri.startswith("asdf://stsci.edu/datamodels/roman/schemas/reference_files/"):
class_name += "Ref"

if class_name.startswith("Wfi") and "Ref" not in class_name:
class_name = class_name.split("Wfi")[-1]

return f"{class_name}Model"


def test_datamodel_name(schema):
if "datamodel_name" in schema:
assert _model_name_from_schema_uri(schema["id"]) == schema["datamodel_name"]


# Confirm that the optical_element filter in wfi_img_photom.yml matches WFI_OPTICAL_ELEMENTS
def test_matched_optical_element_entries():
phot_table_keys = list(
Expand Down

0 comments on commit ba41bfa

Please sign in to comment.