Skip to content

Commit

Permalink
remove_sequence_item returns NcMethodResult
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-r-thorpe committed Nov 2, 2024
1 parent 9dcd93d commit 9424fc3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 21 deletions.
2 changes: 1 addition & 1 deletion nmostesting/IS12Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def add_sequence_item_override(self, test, property_id, value, oid, **kwargs):
NcObjectMethods.ADD_SEQUENCE_ITEM.value,
{'id': property_id, 'value': value})

def remove_sequence_item(self, test, property_id, index, oid, **kwargs):
def remove_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.REMOVE_SEQUENCE_ITEM.value,
Expand Down
2 changes: 1 addition & 1 deletion nmostesting/IS14Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def add_sequence_item_override(self, test, property_id, value, role_path, **kwar
return self._do_request(test, "PATCH", methods_endpoint,
json={"arguments": {"id": property_id, "value": value}})

def remove_sequence_item(self, test, property_id, index, role_path, **kwargs):
def remove_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.REMOVE_SEQUENCE_ITEM.value)
return self._do_request(test, "PATCH", methods_endpoint,
Expand Down
9 changes: 8 additions & 1 deletion nmostesting/MS05Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def add_sequence_item_override(self, test, property_id, value, **kwargs):
"""Add value to a sequence property. Raises NMOSTestException on error"""
pass

def remove_sequence_item(self, test, property_id, index, **kwargs):
def remove_sequence_item_override(self, test, property_id, index, **kwargs):
"""Get value from sequence property. Raises NMOSTestException on error"""
pass

Expand Down Expand Up @@ -145,6 +145,13 @@ def add_sequence_item(self, test, property_id, value, **kwargs):
role_path=kwargs.get("role_path"))
return NcMethodResult.factory(result)

def remove_sequence_item(self, test, property_id, index, **kwargs):
"""Get value from sequence property. Raises NMOSTestException on error"""
result = self.remove_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.
Expand Down
46 changes: 28 additions & 18 deletions nmostesting/suites/MS0502Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,17 @@ def _check_parameter_constraints_number(self, test, constrained_property):
new_value + step / 2)

if constrained_property.descriptor.isSequence:
self.ms05_utils.remove_sequence_item(test,
constrained_property.descriptor.id.__dict__,
index,
oid=constrained_property.oid,
role_path=constrained_property.role_path)
method_result = self.ms05_utils.remove_sequence_item(test,
constrained_property.descriptor.id.__dict__,
index,
oid=constrained_property.oid,
role_path=constrained_property.role_path)
if isinstance(method_result, NcMethodResultError):
self.constraint_validation_metadata.error = True
self.constraint_validation_metadata.error_msg += \
f"{self.ms05_utils.create_role_path_string(constrained_property.role_path)}: " \
f"Error removing sequence item: {str(constrained_property.descriptor.id.__dict__)}: " \
f"{str(method_result.errorMessage)} "

def _check_parameter_constraints_string(self, test, constrained_property):
constraints = constrained_property.constraints
Expand Down Expand Up @@ -417,11 +423,17 @@ def _check_parameter_constraints_string(self, test, constrained_property):

# Remove added sequence item
if constrained_property.descriptor.isSequence:
self.ms05_utils.remove_sequence_item(test,
constrained_property.descriptor.id.__dict__,
index,
oid=constrained_property.oid,
role_path=constrained_property.role_path)
method_result = self.ms05_utils.remove_sequence_item(test,
constrained_property.descriptor.id.__dict__,
index,
oid=constrained_property.oid,
role_path=constrained_property.role_path)
if isinstance(method_result, NcMethodResultError):
self.constraint_validation_metadata.error = True
self.constraint_validation_metadata.error_msg += \
f"{self.ms05_utils.create_role_path_string(constrained_property.role_path)}: " \
f"Error removing sequence item: {str(constrained_property.descriptor.id.__dict__)}: " \
f"{str(method_result.errorMessage)} "

def _check_sequence_datatype_type(self, test, property_under_test):
self.constraint_validation_metadata.checked = True
Expand Down Expand Up @@ -913,16 +925,14 @@ def check_set_sequence_item(self, test, property_id, property_name, sequence_len

def check_remove_sequence_item(self, test, property_id, property_name, sequence_length,
oid, role_path, context=""):
try:
# remove item
self.remove_sequence_item_metadata.checked = True
self.ms05_utils.remove_sequence_item(test, property_id.__dict__, index=sequence_length,
oid=oid, role_path=role_path)
return True
except NMOSTestException as e:
# remove item
self.remove_sequence_item_metadata.checked = True
method_result = self.ms05_utils.remove_sequence_item(test, property_id.__dict__, index=sequence_length,
oid=oid, role_path=role_path)
if isinstance(method_result, NcMethodResultError):
self.remove_sequence_item_metadata.error = True
self.remove_sequence_item_metadata.error_msg += \
f"{context}{property_name}: {str(e.args[0].detail)}, "
f"{context}{property_name}: Error removing sequence item: {str(method_result.errorMessage)}, "
return False

def check_sequence_methods(self, test, property_id, property_name, oid, role_path, context=""):
Expand Down

0 comments on commit 9424fc3

Please sign in to comment.