From b32a401432bdd2b0880c7bd958a99f9f923587cf Mon Sep 17 00:00:00 2001 From: "Jonathan Thorpe (Sony)" Date: Fri, 13 Sep 2024 11:09:37 +0100 Subject: [PATCH] Improve error reporting --- nmostesting/MS05Utils.py | 2 +- nmostesting/suites/MS0501Test.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/nmostesting/MS05Utils.py b/nmostesting/MS05Utils.py index 78d6c5cf..e8780d57 100644 --- a/nmostesting/MS05Utils.py +++ b/nmostesting/MS05Utils.py @@ -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"]) diff --git a/nmostesting/suites/MS0501Test.py b/nmostesting/suites/MS0501Test.py index 68469780..7ea5f285 100644 --- a/nmostesting/suites/MS0501Test.py +++ b/nmostesting/suites/MS0501Test.py @@ -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 @@ -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): @@ -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 @@ -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']) @@ -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