diff --git a/nmostesting/IS12Utils.py b/nmostesting/IS12Utils.py index 9a4b2751..c70ea31b 100644 --- a/nmostesting/IS12Utils.py +++ b/nmostesting/IS12Utils.py @@ -233,16 +233,12 @@ def invoke_method_override(self, test, method_id, argument, oid, **kwargs): method_id, {"argument": argument}) - def get_sequence_item(self, test, property_id, index, oid, **kwargs): + def get_sequence_item_override(self, test, property_id, index, oid, **kwargs): """Get value from sequence property. Raises NMOSTestException on error""" return self.execute_command(test, oid, NcObjectMethods.GET_SEQUENCE_ITEM.value, {'id': property_id, 'index': index}) - def get_sequence_item_value(self, test, property_id, index, oid, **kwargs): - """Get value from sequence property. Raises NMOSTestException on error""" - return self.get_sequence_item(test, property_id, index, oid=oid)['value'] - def set_sequence_item(self, test, property_id, index, value, oid, **kwargs): """Add value to a sequence property. Raises NMOSTestException on error""" return self.execute_command(test, oid, diff --git a/nmostesting/IS14Utils.py b/nmostesting/IS14Utils.py index 302a99d1..b224235d 100644 --- a/nmostesting/IS14Utils.py +++ b/nmostesting/IS14Utils.py @@ -84,15 +84,12 @@ def invoke_method_override(self, test, method_id, argument, role_path, **kwargs) methods_endpoint = self._create_methods_endpoint(role_path, method_id) return self._do_request(test, "PATCH", methods_endpoint, json={"arguments": argument}) - def get_sequence_item(self, test, property_id, index, role_path, **kwargs): + def get_sequence_item_override(self, test, property_id, index, role_path, **kwargs): """Get value from sequence property. Raises NMOSTestException on error""" methods_endpoint = self._create_methods_endpoint(role_path, NcObjectMethods.GET_SEQUENCE_ITEM.value) return self._do_request(test, "PATCH", methods_endpoint, json={"arguments": {"id": property_id, "index": index}}) - def get_sequence_item_value(self, test, property_id, index, role_path, **kwargs): - return self.get_sequence_item(test, property_id, index, role_path, **kwargs)["value"] - def get_sequence_length(self, test, property_id, role_path, **kwargs): """Get sequence length. Raises NMOSTestException on error""" methods_endpoint = self._create_methods_endpoint(role_path, NcObjectMethods.GET_SEQUENCE_LENGTH.value) diff --git a/nmostesting/MS05Utils.py b/nmostesting/MS05Utils.py index 4abcf9c0..10538ca7 100644 --- a/nmostesting/MS05Utils.py +++ b/nmostesting/MS05Utils.py @@ -53,11 +53,7 @@ def set_property_override(self, test, property_id, argument, **kwargs): def invoke_method_override(self, test, method_id, argument, **kwargs): pass - def get_sequence_item(self, test, property_id, index, **kwargs): - pass - - def get_sequence_item_value(self, test, property_id, index, **kwargs): - """Get value from sequence property. Raises NMOSTestException on error""" + def get_sequence_item_override(self, test, property_id, index, **kwargs): pass def get_sequence_length(self, test, property_id, **kwargs): @@ -122,6 +118,12 @@ def invoke_method(self, test, method_id, argument, **kwargs): role_path=kwargs.get("role_path")) return NcMethodResult.factory(result) + def get_sequence_item(self, test, property_id, index, **kwargs): + result = self.get_sequence_item_override(test, property_id, index, **kwargs) + self.reference_datatype_schema_validate(test, result, NcMethodResult.__name__, + role_path=kwargs.get("role_path")) + return NcMethodResult.factory(result) + def query_device_model(self, test): """ Query Device Model from the Node under test. self.device_model_metadata set on Device Model validation error. diff --git a/nmostesting/suites/MS0501Test.py b/nmostesting/suites/MS0501Test.py index 2fc3c634..9fdfc248 100644 --- a/nmostesting/suites/MS0501Test.py +++ b/nmostesting/suites/MS0501Test.py @@ -17,7 +17,7 @@ from ..GenericTest import GenericTest, NMOSTestException from ..MS05Utils import MS05Utils, NcBlock, NcBlockMemberDescriptor, NcBlockProperties, NcClassDescriptor, \ NcDatatypeDescriptor, NcDatatypeDescriptorStruct, NcDeviceManagerProperties, NcMethodResultError, NcMethodStatus, \ - NcMethodResult, NcObjectProperties, NcParameterConstraintsNumber, NcParameterConstraintsString, \ + NcObjectProperties, NcParameterConstraintsNumber, NcParameterConstraintsString, \ NcPropertyConstraintsNumber, NcPropertyConstraintsString, NcTouchpoint, NcTouchpointNmos, \ NcTouchpointNmosChannelMapping, StandardClassIds from ..TestResult import Test @@ -199,22 +199,23 @@ def _validate_property_type(self, test, value, property_descriptor, role_path): def check_get_sequence_item(self, test, oid, role_path, sequence_values, property_descriptor): context = f"{self.ms05_utils.create_role_path_string(role_path)}: " - try: - self.get_sequence_item_metadata.checked = True - sequence_index = 0 - for property_value in sequence_values: - value = self.ms05_utils.get_sequence_item_value(test, property_descriptor.id.__dict__, sequence_index, - oid=oid, role_path=role_path) - if property_value != value: - self.get_sequence_item_metadata.error = True - self.get_sequence_item_metadata.error_msg += \ - f"{context}{property_descriptor.name}: Expected: {str(property_value)}, Actual: {str(value)}" \ - f" at index {sequence_index}, " - sequence_index += 1 - except NMOSTestException as e: - self.get_sequence_item_metadata.error = True - self.get_sequence_item_metadata.error_msg += \ - f"{context}{property_descriptor.name}: {str(e.args[0].detail)}, " + self.get_sequence_item_metadata.checked = True + sequence_index = 0 + for property_value in sequence_values: + method_result = self.ms05_utils.get_sequence_item(test, property_descriptor.id.__dict__, + sequence_index, oid=oid, role_path=role_path) + if isinstance(method_result, NcMethodResultError): + self.get_sequence_item_metadata.error = True + self.get_sequence_item_metadata.error_msg += \ + f"{context}{property_descriptor.name}: Error getting sequence item: " \ + f"{method_result.error}, " + if property_value != method_result.value: + self.get_sequence_item_metadata.error = True + self.get_sequence_item_metadata.error_msg += \ + f"{context}{property_descriptor.name}: Expected: {str(property_value)}, " \ + f"Actual: {str(method_result.value)} " \ + f"at index {sequence_index}, " + sequence_index += 1 def check_get_sequence_length(self, test, oid, role_path, sequence_values, property_descriptor): context = f"{self.ms05_utils.create_role_path_string(role_path)}: " @@ -1366,14 +1367,11 @@ def test_ms05_26(self, test): role_path=["root"]) out_of_bounds_index = length + 10 - result = self.ms05_utils.get_sequence_item(test, - NcBlockProperties.MEMBERS.value, - out_of_bounds_index, - oid=self.ms05_utils.ROOT_BLOCK_OID, - role_path=["root"]) - - self.ms05_utils.reference_datatype_schema_validate(test, result, NcMethodResult.__name__) - method_result = NcMethodResult.factory(result) + method_result = self.ms05_utils.get_sequence_item(test, + NcBlockProperties.MEMBERS.value, + out_of_bounds_index, + oid=self.ms05_utils.ROOT_BLOCK_OID, + role_path=["root"]) if not isinstance(method_result, NcMethodResultError): return test.FAIL("Sequence out of bounds error expected.", diff --git a/nmostesting/suites/MS0502Test.py b/nmostesting/suites/MS0502Test.py index 29a06e1e..a2d480a2 100644 --- a/nmostesting/suites/MS0502Test.py +++ b/nmostesting/suites/MS0502Test.py @@ -811,51 +811,69 @@ def test_ms05_07(self, test): return self._do_check_methods_test(test, question) def check_add_sequence_item(self, test, property_id, property_name, sequence_length, oid, role_path, context=""): - try: - self.add_sequence_item_metadata.checked = True - # Add a value to the end of the sequence - new_item = self.ms05_utils.get_sequence_item_value(test, property_id.__dict__, index=0, - oid=oid, role_path=role_path) - - self.ms05_utils.add_sequence_item(test, property_id.__dict__, new_item, oid=oid, role_path=role_path) - - # check the value - value = self.ms05_utils.get_sequence_item_value(test, property_id.__dict__, index=sequence_length, - oid=oid, role_path=role_path) - if value != new_item: - self.add_sequence_item_metadata.error = True - self.add_sequence_item_metadata.error_msg += \ - f"{context}{property_name}: Expected: {str(new_item)}, Actual: {str(value)}, " - return True - except NMOSTestException as e: + # Add a value to the end of the sequence + method_result = self.ms05_utils.get_sequence_item(test, property_id.__dict__, index=0, + oid=oid, role_path=role_path) + + if isinstance(method_result, NcMethodResultError): self.add_sequence_item_metadata.error = True self.add_sequence_item_metadata.error_msg += \ - f"{context}{property_name}: {str(e.args[0].detail)}, " - return False + f"{context}{property_name}: Error getting sequence item: {str(method_result.errorMessage)} " + return False + new_item = method_result.value + self.ms05_utils.add_sequence_item(test, property_id.__dict__, new_item, oid=oid, role_path=role_path) + + # check the value + method_result = self.ms05_utils.get_sequence_item(test, property_id.__dict__, index=sequence_length, + oid=oid, role_path=role_path) + + if isinstance(method_result, NcMethodResultError): + self.add_sequence_item_metadata.error = True + self.add_sequence_item_metadata.error_msg += \ + f"{context}{property_name}: Error getting sequence item: {str(method_result.errorMessage)} " + return False + + value = method_result.value + if value != new_item: + self.add_sequence_item_metadata.error = True + self.add_sequence_item_metadata.error_msg += \ + f"{context}{property_name}: Expected: {str(new_item)}, Actual: {str(value)}, " + self.add_sequence_item_metadata.checked = True + + return True def check_set_sequence_item(self, test, property_id, property_name, sequence_length, oid, role_path, context=""): - try: - self.set_sequence_item_metadata.checked = True - new_value = self.ms05_utils.get_sequence_item_value(test, property_id.__dict__, index=sequence_length - 1, - oid=oid, role_path=role_path) - - # set to another value - self.ms05_utils.set_sequence_item(test, property_id.__dict__, index=sequence_length, value=new_value, - oid=oid, role_path=role_path) - - # check the value - value = self.ms05_utils.get_sequence_item_value(test, property_id.__dict__, index=sequence_length, - oid=oid, role_path=role_path) - if value != new_value: - self.set_sequence_item_metadata.error = True - self.set_sequence_item_metadata.error_msg += \ - f"{context}{property_name}: Expected: {str(new_value)}, Actual: {str(value)}, " - return True - except NMOSTestException as e: + method_result = self.ms05_utils.get_sequence_item(test, property_id.__dict__, index=sequence_length - 1, + oid=oid, role_path=role_path) + + if isinstance(method_result, NcMethodResultError): + self.add_sequence_item_metadata.error = True + self.add_sequence_item_metadata.error_msg += \ + f"{context}{property_name}: Error getting sequence item: {str(method_result.errorMessage)} " + return False + new_value = method_result.value + # set to another value + self.ms05_utils.set_sequence_item(test, property_id.__dict__, index=sequence_length, value=new_value, + oid=oid, role_path=role_path) + + # check the value + method_result = self.ms05_utils.get_sequence_item(test, property_id.__dict__, index=sequence_length, + oid=oid, role_path=role_path) + + if isinstance(method_result, NcMethodResultError): + self.add_sequence_item_metadata.error = True + self.add_sequence_item_metadata.error_msg += \ + f"{context}{property_name}: Error getting sequence item: {str(method_result.errorMessage)} " + return False + + if method_result.value != new_value: self.set_sequence_item_metadata.error = True self.set_sequence_item_metadata.error_msg += \ - f"{context}{property_name}: {str(e.args[0].detail)}, " - return False + f"{context}{property_name}: Expected: {str(new_value)}, Actual: {str(method_result.value)}, " + + self.set_sequence_item_metadata.checked = True + + return True def check_remove_sequence_item(self, test, property_id, property_name, sequence_length, oid, role_path, context=""):