Skip to content

Commit

Permalink
find_members_by_path returns NcMethodResult
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-r-thorpe committed Nov 3, 2024
1 parent e66fa76 commit f297309
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 23 deletions.
4 changes: 2 additions & 2 deletions nmostesting/IS12Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ def get_member_descriptors_override(self, test, recurse, oid, **kwargs):
NcBlockMethods.GET_MEMBERS_DESCRIPTOR.value,
{'recurse': recurse})

def find_members_by_path(self, test, path, oid, **kwargs):
def find_members_by_path_override(self, test, path, oid, **kwargs):
"""Query members based on role path. Raises NMOSTestException on error"""
return self.execute_command(test, oid,
NcBlockMethods.FIND_MEMBERS_BY_PATH.value,
{'path': path})["value"]
{'path': path})

def find_members_by_role(self, test, role, case_sensitive, match_whole_string, recurse, oid, **kwargs):
"""Query members based on role. Raises NMOSTestException on error"""
Expand Down
4 changes: 2 additions & 2 deletions nmostesting/IS14Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ def get_member_descriptors_override(self, test, recurse, role_path, **kwargs):
methods_endpoint = self._create_methods_endpoint(role_path, NcBlockMethods.GET_MEMBERS_DESCRIPTOR.value)
return self._do_request(test, "PATCH", methods_endpoint, json={"arguments": {"recurse": recurse}})

def find_members_by_path(self, test, path, role_path, **kwargs):
def find_members_by_path_override(self, test, path, role_path, **kwargs):
"""Query members based on role path. Raises NMOSTestException on error"""
methods_endpoint = self._create_methods_endpoint(role_path, NcBlockMethods.FIND_MEMBERS_BY_PATH.value)
return self._do_request(test, "PATCH", methods_endpoint, json={"arguments": {"path": path}})['value']
return self._do_request(test, "PATCH", methods_endpoint, json={"arguments": {"path": path}})

def find_members_by_role(self, test, role, case_sensitive, match_whole_string, recurse, role_path, **kwargs):
"""Query members based on role. Raises NMOSTestException on error"""
Expand Down
20 changes: 14 additions & 6 deletions nmostesting/MS05Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def remove_sequence_item_override(self, test, property_id, index, **kwargs):
def get_member_descriptors_override(self, test, recurse, **kwargs):
pass

def find_members_by_path(self, test, path, **kwargs):
def find_members_by_path_override(self, test, path, **kwargs):
"""Query members based on role path. Raises NMOSTestException on error"""
pass

Expand Down Expand Up @@ -152,11 +152,10 @@ def remove_sequence_item(self, test, property_id, index, **kwargs):
role_path=kwargs.get("role_path"))
return NcMethodResult.factory(result)

def get_member_descriptors(self, test, recurse, **kwargs):
result = self.get_member_descriptors_override(test, recurse, **kwargs)
self.reference_datatype_schema_validate(test, result, NcMethodResult.__name__,
role_path=kwargs.get("role_path"))
def create_NcMethodResultBlockMemberDescriptors(self, test, result, role_path):
self.reference_datatype_schema_validate(test, result, NcMethodResult.__name__, role_path=role_path)
method_result = NcMethodResult.factory(result)

if not isinstance(method_result, NcMethodResultError) and isinstance(method_result.value, list):
# Validate block members and create NcBlockMemberDescriptor objects
block_member_descriptors = []
Expand All @@ -165,11 +164,20 @@ def get_member_descriptors(self, test, recurse, **kwargs):
test,
member,
NcBlockMemberDescriptor.__name__,
self.create_role_path(kwargs.get("role_path"), member.get("role")))
self.create_role_path(role_path, member.get("role")))
block_member_descriptors.append(NcBlockMemberDescriptor(member))
method_result.value = block_member_descriptors
return method_result

def get_member_descriptors(self, test, recurse, **kwargs):
result = self.get_member_descriptors_override(test, recurse, **kwargs)
return self.create_NcMethodResultBlockMemberDescriptors(test, result, kwargs.get("role_path"))

def find_members_by_path(self, test, path, **kwargs):
"""Query members based on role path. Raises NMOSTestException on error"""
result = self.find_members_by_path_override(test, path, **kwargs)
return self.create_NcMethodResultBlockMemberDescriptors(test, result, kwargs.get("role_path"))

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
23 changes: 10 additions & 13 deletions nmostesting/suites/MS0501Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -863,26 +863,23 @@ def do_find_member_by_path_test(self, test, block):
# Get ground truth data from local device model object tree
expected_member = block.find_members_by_path(path)

queried_members = self.ms05_utils.find_members_by_path(test, path,
oid=block.oid,
role_path=block.role_path)
method_result = self.ms05_utils.find_members_by_path(test, path,
oid=block.oid,
role_path=block.role_path)

if not isinstance(queried_members, list):
if isinstance(method_result, NcMethodResultError):
raise NMOSTestException(test.FAIL(f"{block_role_path_string}: Error in findMembersByPath: "
f"{str(method_result.errorMessage)}"))

if not isinstance(method_result.value, list):
raise NMOSTestException(test.FAIL(f"{block_role_path_string}"
f": Did not return an array of results for query: {str(path)}"))

for queried_member in queried_members:
self.ms05_utils.reference_datatype_schema_validate(
test,
queried_member,
NcBlockMemberDescriptor.__name__,
self.ms05_utils.create_role_path(block.role_path, queried_member.get("role")))

if len(queried_members) != 1:
if len(method_result.value) != 1:
raise NMOSTestException(test.FAIL(f"{block_role_path_string}"
f": Incorrect member found by role path: {str(path)}"))

queried_member_oids = [m['oid'] for m in queried_members]
queried_member_oids = [m.oid for m in method_result.value]

if expected_member.oid not in queried_member_oids:
raise NMOSTestException(test.FAIL(f"{block_role_path_string}"
Expand Down

0 comments on commit f297309

Please sign in to comment.