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