Skip to content

Commit

Permalink
Improve error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-r-thorpe committed Sep 13, 2024
1 parent 013849d commit b32a401
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nmostesting/MS05Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def validate_reference_datatype_schema(self, test, payload, datatype_name, conte
def validate_schema(self, test, payload, schema, context=""):
"""Delegates to validate_schema. Raises NMOSTestExceptions on error"""
if not schema:
raise NMOSTestException(test.FAIL(context + "Missing schema. "))
raise NMOSTestException(test.FAIL("Missing schema. Possible unknown type: " + context))
try:
# Validate the JSON schema is correct
checker = FormatChecker(["ipv4", "ipv6", "uri"])
Expand Down
17 changes: 11 additions & 6 deletions nmostesting/suites/MS0501Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def _validate_property_type(self, test, value, data_type, is_nullable, context="
if not isinstance(value, self.ms05_utils.primitive_to_python_type(data_type)):
raise NMOSTestException(test.FAIL(context + str(value) + " is not of type " + str(data_type)))
else:
self.ms05_utils.validate_schema(test, value, self.get_datatype_schema(test, data_type), context)
self.ms05_utils.validate_schema(test, value, self.get_datatype_schema(test, data_type), context + data_type)

return

Expand Down Expand Up @@ -308,8 +308,7 @@ def check_object_properties(self, test, reference_class_descriptor, oid, role_pa
object_property,
class_property['typeName'],
class_property['isNullable'],
context=context + class_property["typeName"]
+ class_property["name"] + ": ")
context=context + class_property["name"] + ": ")
return

def check_unique_roles(self, role, role_cache):
Expand Down Expand Up @@ -361,7 +360,7 @@ def check_touchpoints(self, test, oid, role_path, context):
test,
touchpoint,
schema,
context=context + schema["title"] + ": ")
context=context + schema["title"])

except NMOSTestException as e:
self.touchpoints_metadata["error"] = True
Expand All @@ -383,7 +382,7 @@ def check_block(self, test, block, class_descriptors, context=""):
test,
descriptor,
self.get_datatype_schema(test, "NcBlockMemberDescriptor"),
context=context + "NcBlockMemberDescriptor: ")
context=context + "NcBlockMemberDescriptor: " + str(descriptor['role']))

self.check_unique_roles(descriptor['role'], role_cache)
self.check_unique_oid(descriptor['oid'])
Expand Down Expand Up @@ -1260,7 +1259,13 @@ def _check_constraints_hierarchy(self, test, class_property, datatype_descriptor
runtime_constraints = None
# Level 0: Datatype constraints
if class_property.get('typeName'):
datatype_constraints = datatype_descriptors.get(class_property['typeName']).get('constraints')
if(datatype_descriptors.get(class_property['typeName'])):
datatype_constraints = datatype_descriptors.get(class_property['typeName']).get('constraints')
else:
raise NMOSTestException(test.FAIL(context + "Unknown data type: " + class_property['typeName']))
else:
raise NMOSTestException(test.FAIL(context + "Missing data type from class descriptor"))

# Level 1: Property constraints
property_constraints = class_property.get('constraints')
# Level 3: Runtime constraints
Expand Down

0 comments on commit b32a401

Please sign in to comment.