22
22
)
23
23
EXPOSURE_TYPE_ELEMENTS = list (asdf .schema .load_schema ("asdf://stsci.edu/datamodels/roman/schemas/exposure_type-1.0.0" )["enum" ])
24
24
EXPECTED_COMMON_REFERENCE = {"$ref" : "asdf://stsci.edu/datamodels/roman/schemas/reference_files/ref_common-1.0.0" }
25
+ METADATA_FORCING_REQUIRED = ["archive_catalog" , "sdf" ]
25
26
26
27
27
28
@pytest .fixture (scope = "session" , params = SCHEMA_URIS )
@@ -105,6 +106,10 @@ def callback(node):
105
106
106
107
107
108
def test_required (schema ):
109
+ """
110
+ Checks that all properties are required if there is a required list.
111
+ """
112
+
108
113
def callback (node ):
109
114
if isinstance (node , Mapping ) and "required" in node :
110
115
assert node .get ("type" ) == "object"
@@ -118,6 +123,22 @@ def callback(node):
118
123
asdf .treeutil .walk (schema , callback )
119
124
120
125
126
+ def test_metadata_force_required (schema ):
127
+ """
128
+ Test that if certain properties have certain metadata entries, that they are in a required list.
129
+ """
130
+
131
+ def callback (node ):
132
+ if isinstance (node , Mapping ) and "properties" in node :
133
+ for prop_name , prop in node ["properties" ].items ():
134
+ for metadata in METADATA_FORCING_REQUIRED :
135
+ if isinstance (prop , Mapping ) and metadata in prop :
136
+ assert "required" in node
137
+ assert prop_name in node ["required" ]
138
+
139
+ asdf .treeutil .walk (schema , callback )
140
+
141
+
121
142
def test_flowstyle (schema , manifest ):
122
143
is_tag_schema = schema ["id" ] in {t ["schema_uri" ] for t in manifest ["tags" ]}
123
144
0 commit comments