Skip to content

Commit

Permalink
Implement IS12CommandResponse class
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathan-r-thorpe committed Nov 4, 2024
1 parent 82ebd13 commit ec3c2a1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions nmostesting/IS12Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ class MessageTypes(IntEnum):
Error = 5


class IS12CommandResponse():
def __init__(self, response_json):
self.handle = response_json["handle"]
# Store raw result here - construction of NcMethodResult object happens in the MS-05 layer
self.result = response_json["result"]


class IS12Notification():
def __init__(self, notification_json):
self.oid = notification_json["oid"]
Expand Down Expand Up @@ -163,9 +170,9 @@ def send_command(self, test, command_json):
.format(self.apis[CONTROL_API_KEY]["spec_branch"])))

if parsed_message["messageType"] == MessageTypes.CommandResponse:
responses = parsed_message["responses"]
responses = [IS12CommandResponse(r) for r in parsed_message["responses"]]
for response in responses:
if response["handle"] == command_handle:
if response.handle == command_handle:
results.append(response)
if parsed_message["messageType"] == MessageTypes.SubscriptionResponse:
results.append(parsed_message["subscriptions"])
Expand Down Expand Up @@ -220,7 +227,7 @@ def create_command_JSON(self, oid, method_id, arguments):
def execute_command(self, test, oid, method_id, arguments):
command_JSON = self.create_command_JSON(oid, method_id, arguments)
response = self.send_command(test, command_JSON)
return response["result"]
return response.result

def get_property_override(self, test, property_id, oid, **kwargs):
"""Get property from object. Raises NMOSTestException on error"""
Expand Down
6 changes: 3 additions & 3 deletions nmostesting/suites/IS1201Test.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,10 @@ def do_ms05_error_test(self, test, command_json, expected_status=None):
# when expected_status = None checking of the status code is skipped
# check the syntax of the error message according to is12_error

result = self.is12_utils.send_command(test, command_json)
response = self.is12_utils.send_command(test, command_json)

self.ms05_utils.reference_datatype_schema_validate(test, result["result"], NcMethodResult.__name__)
method_result = NcMethodResult.factory(result["result"])
self.ms05_utils.reference_datatype_schema_validate(test, response.result, NcMethodResult.__name__)
method_result = NcMethodResult.factory(response.result)

if not isinstance(method_result, NcMethodResultError):
return test.FAIL("Error not handled.",
Expand Down

0 comments on commit ec3c2a1

Please sign in to comment.