Skip to content

Commit

Permalink
Check deprecated properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-r-thorpe committed Nov 17, 2023
1 parent 5f2cb63 commit 7c93b49
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 20 deletions.
8 changes: 7 additions & 1 deletion nmostesting/IS12Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,18 @@ def _execute_command(self, test, oid, method_id, arguments):
response = self.send_command(test, command_JSON)
return response["result"]

def get_property(self, test, oid, property_id):
def get_property_value(self, test, oid, property_id):
"""Get property from object. Raises NMOSTestException on error"""
return self._execute_command(test, oid,
NcObjectMethods.GENERIC_GET.value,
{'id': property_id})["value"]

def get_property(self, test, oid, property_id):
"""Get property from object. Raises NMOSTestException on error"""
return self._execute_command(test, oid,
NcObjectMethods.GENERIC_GET.value,
{'id': property_id})

def set_property(self, test, oid, property_id, argument):
"""Get property from object. Raises NMOSTestException on error"""
return self._execute_command(test, oid,
Expand Down
81 changes: 62 additions & 19 deletions nmostesting/suites/IS1201Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ def set_up_tests(self):
self.device_model_metadata = {"checked": False, "error": False, "error_msg": ""}
self.organization_metadata = {"checked": False, "error": False, "error_msg": ""}
self.touchpoints_metadata = {"checked": False, "error": False, "error_msg": ""}
self.deprecated_property_metadata = {"checked": False, "error": False, "error_msg": ""}
self.get_sequence_item_metadata = {"checked": False, "error": False, "error_msg": ""}
self.get_sequence_length_metadata = {"checked": False, "error": False, "error_msg": ""}
self.validate_runtime_constraints_metadata = {"checked": False, "error": False, "error_msg": ""}
Expand Down Expand Up @@ -206,7 +207,7 @@ def _validate_schema(self, test, payload, schema, context=""):
return

def get_class_manager_descriptors(self, test, class_manager_oid, property_id, role):
response = self.get_property(test, class_manager_oid, property_id, role)
response = self.get_property_value(test, class_manager_oid, property_id, role)

if not response:
return None
Expand Down Expand Up @@ -340,9 +341,9 @@ def test_04(self, test):

self.create_ncp_socket(test)

role = self.is12_utils.get_property(test,
self.is12_utils.ROOT_BLOCK_OID,
NcObjectProperties.ROLE.value)
role = self.is12_utils.get_property_value(test,
self.is12_utils.ROOT_BLOCK_OID,
NcObjectProperties.ROLE.value)

if role != "root":
return test.FAIL("Unexpected role in Root Block: " + str(role),
Expand Down Expand Up @@ -427,6 +428,18 @@ def check_sequence_methods(self, test, oid, sequence_values, property_metadata,
self.check_get_sequence_item(test, oid, sequence_values, property_metadata, context)
self.check_get_sequence_length(test, oid, sequence_values, property_metadata, context)

def get_property_value(self, test, oid, property_id, context):
try:
return self.is12_utils.get_property_value(test, oid, property_id)
except NMOSTestException as e:
self.device_model_metadata["error"] = True
self.device_model_metadata["error_msg"] += context \
+ "Error getting property: " \
+ str(property_id) + ": " \
+ str(e.args[0].detail) \
+ "; "
return None

def get_property(self, test, oid, property_id, context):
try:
return self.is12_utils.get_property(test, oid, property_id)
Expand All @@ -441,7 +454,16 @@ def get_property(self, test, oid, property_id, context):

def check_object_properties(self, test, reference_class_descriptor, oid, context):
for class_property in reference_class_descriptor['properties']:
object_property = self.get_property(test, oid, class_property.get('id'), context)
response = self.get_property(test, oid, class_property.get('id'), context)

object_property = response["value"]

if class_property["isDeprecated"]:
self.deprecated_property_metadata["checked"] = True
if response["status"] != NcMethodStatus.PropertyDeprecated.value:
self.deprecated_property_metadata["error"] = True
self.deprecated_property_metadata["error_msg"] = context + \
" PropertyDeprecated status code expected when getting " + class_property["name"]

if not object_property:
continue
Expand Down Expand Up @@ -500,10 +522,10 @@ def check_manager(self, class_id, owner, class_descriptors, manager_cache):

def check_touchpoints(self, test, oid, context):
"""Touchpoint checks"""
touchpoints = self.get_property(test,
oid,
NcObjectProperties.TOUCHPOINTS.value,
context)
touchpoints = self.get_property_value(test,
oid,
NcObjectProperties.TOUCHPOINTS.value,
context)
if touchpoints is not None:
self.touchpoints_metadata["checked"] = True
try:
Expand Down Expand Up @@ -595,14 +617,14 @@ def check_device_model(self, test):

def nc_object_factory(self, test, class_id, oid, role):
"""Create NcObject or NcBlock based on class_id"""
runtime_constraints = self.get_property(test,
oid,
NcObjectProperties.RUNTIME_PROPERTY_CONSTRAINTS.value,
role + ": ")
runtime_constraints = self.get_property_value(test,
oid,
NcObjectProperties.RUNTIME_PROPERTY_CONSTRAINTS.value,
role + ": ")

# Check class id to determine if this is a block
if len(class_id) > 1 and class_id[0] == 1 and class_id[1] == 1:
member_descriptors = self.get_property(test, oid, NcBlockProperties.MEMBERS.value, role + ": ")
member_descriptors = self.get_property_value(test, oid, NcBlockProperties.MEMBERS.value, role + ": ")
if not member_descriptors:
# An error has likely occured
return None
Expand Down Expand Up @@ -727,6 +749,27 @@ def test_09(self, test):
return test.UNCLEAR("No Touchpoints found.")
return test.PASS()

def test_09_01(self, test):
"""Device Model: deprecated properties are indicated"""
# Getting deprecated properties MUST return a PropertyDeprecated status
# https://specs.amwa.tv/ms-05-02/branches/v1.0.x/docs/Framework.html#ncmethodstatus

try:
self.check_device_model(test)
except NMOSTestException as e:
# Couldn't validate model so can't perform test
return test.UNCLEAR(e.args[0].detail, e.args[0].link)

if self.deprecated_property_metadata["error"]:
return test.FAIL(self.deprecated_property_metadata["error_msg"],
"https://specs.amwa.tv/ms-05-02/branches/{}"
"/docs/Framework.html#ncmethodstatus"
.format(self.apis[MS05_API_KEY]["spec_branch"]))

if not self.deprecated_property_metadata["checked"]:
return test.UNCLEAR("No deprecated properties found.")
return test.PASS()

def test_10(self, test):
"""Managers: managers are members of the Root Block"""
# All managers MUST always exist as members in the Root Block and have a fixed role.
Expand Down Expand Up @@ -802,7 +845,7 @@ def test_13(self, test):
# Check MS-05-02 Version
property_id = NcDeviceManagerProperties.NCVERSION.value

version = self.is12_utils.get_property(test, device_manager.oid, property_id)
version = self.is12_utils.get_property_value(test, device_manager.oid, property_id)

if self.is12_utils.compare_api_version(version, self.apis[MS05_API_KEY]["version"]):
return test.FAIL("Unexpected version. Expected: "
Expand Down Expand Up @@ -871,15 +914,15 @@ def test_16(self, test):

property_id = NcObjectProperties.USER_LABEL.value

old_user_label = self.is12_utils.get_property(test, self.is12_utils.ROOT_BLOCK_OID, property_id)
old_user_label = self.is12_utils.get_property_value(test, self.is12_utils.ROOT_BLOCK_OID, property_id)

# Set user label
new_user_label = "NMOS Testing Tool"

self.is12_utils.set_property(test, self.is12_utils.ROOT_BLOCK_OID, property_id, new_user_label)

# Check user label
label = self.is12_utils.get_property(test, self.is12_utils.ROOT_BLOCK_OID, property_id)
label = self.is12_utils.get_property_value(test, self.is12_utils.ROOT_BLOCK_OID, property_id)
if label != new_user_label:
if label == old_user_label:
return test.FAIL("Unable to set user label", link)
Expand All @@ -890,7 +933,7 @@ def test_16(self, test):
self.is12_utils.set_property(test, self.is12_utils.ROOT_BLOCK_OID, property_id, old_user_label)

# Check user label
label = self.is12_utils.get_property(test, self.is12_utils.ROOT_BLOCK_OID, property_id)
label = self.is12_utils.get_property_value(test, self.is12_utils.ROOT_BLOCK_OID, property_id)
if label != old_user_label:
if label == new_user_label:
return test.FAIL("Unable to set user label", link)
Expand Down Expand Up @@ -1384,7 +1427,7 @@ def test_32(self, test):

for oid in oids.keys():
new_user_label = "NMOS Testing Tool " + str(oid)
old_user_label = self.is12_utils.get_property(test, oid, NcObjectProperties.USER_LABEL.value)
old_user_label = self.is12_utils.get_property_value(test, oid, NcObjectProperties.USER_LABEL.value)

context = "oid: " + str(oid) + ", "

Expand Down

0 comments on commit 7c93b49

Please sign in to comment.