diff --git a/nmostesting/IS12Utils.py b/nmostesting/IS12Utils.py index c3548f26..3a3d7f4f 100644 --- a/nmostesting/IS12Utils.py +++ b/nmostesting/IS12Utils.py @@ -24,7 +24,7 @@ from .GenericTest import NMOSInitException, NMOSTestException from .TestHelper import WebsocketWorker, load_resolved_schema from .MS05Utils import NcBlockMethods, NcClassManagerMethods, NcEventId, NcMethodStatus, NcObjectMethods, \ - NcPropertyChangedEventData + NcPropertyChangedEventData, NcObjectProperties CONTROL_API_KEY = "ncp" MS05_API_KEY = "controlframework" @@ -76,6 +76,8 @@ def reset(self): super().reset() self.command_handle = 0 self.expect_notifications = False + self.expect_notifications_oid = 0 + self.expect_notifications_property = None self.notifications = [] # Overridden functions @@ -159,7 +161,7 @@ def send_command(self, test, command_json): results = [] start_time = time.time() - while time.time() < start_time + WS_MESSAGE_TIMEOUT: + while time.time() < start_time + 2* WS_MESSAGE_TIMEOUT: # have enough time for command and notifications if not self.ncp_websocket.is_messages_received(): time.sleep(0.2) continue @@ -198,7 +200,14 @@ def send_command(self, test, command_json): if not self.expect_notifications and len(results) != 0: break if self.expect_notifications and len(results) != 0 and len(self.notifications) != 0: - break + found_oid = False + for notification in self.notifications: + if notification.oid == self.expect_notifications_oid and notification.eventData.propertyId == self.expect_notifications_property: + found_oid = True + break + + if found_oid: + break if len(results) == 0: raise NMOSTestException(test.FAIL( @@ -209,13 +218,18 @@ def send_command(self, test, command_json): if len(results) > 1: raise NMOSTestException(test.FAIL(f"Received multiple responses : {len(responses)}")) + if self.expect_notifications and len(self.notifications) == 0: + raise NMOSTestException(test.FAIL("expected notifications not received in time")) + return results[0] def get_notifications(self): return self.notifications - def start_logging_notifications(self): + def start_logging_notifications(self, oid, property): self.expect_notifications = True + self.expect_notifications_oid = oid + self.expect_notifications_property = property self.notifications = [] def stop_logging_notifications(self): diff --git a/nmostesting/suites/IS1201Test.py b/nmostesting/suites/IS1201Test.py index a20a0505..b34abf5b 100644 --- a/nmostesting/suites/IS1201Test.py +++ b/nmostesting/suites/IS1201Test.py @@ -295,14 +295,15 @@ def test_33(self, test): # Each label will be set twice; once to the new user label, and then again back to the old user label for label in [new_user_label, old_user_label]: # Set property and log notificaiton - self.is12_utils.start_logging_notifications() + self.is12_utils.start_logging_notifications(oid, NcObjectProperties.USER_LABEL.value) method_result = self.is12_utils.set_property(test, NcObjectProperties.USER_LABEL.value, label, oid=oid) + self.is12_utils.stop_logging_notifications() + if isinstance(method_result, NcMethodResultError): error = True error_message += f"Unable to set user label property from object (OID:{str(oid)}): " \ f"{str(method_result.errorMessage)} " continue - self.is12_utils.stop_logging_notifications() for notification in self.is12_utils.get_notifications(): if notification.oid == oid: @@ -314,7 +315,7 @@ def test_33(self, test): if notification.eventData.propertyId != NcObjectProperties.USER_LABEL.value: continue - if notification.eventData.changeType != NcPropertyChangeType.ValueChanged: + if notification.eventData.changeType != NcPropertyChangeType.ValueChanged.value: error = True error_message += f"{context}Unexpected change type: " \ f"{str(notification.eventData.changeType.name)}, "