def check_delayed_activation(self, activationTime, activationType): active = Active() active.unrouteAll() preActivationState = active.buildJSONObject() outputList = getOutputList() testRouteAction = outputList[0].findAcceptableTestRoute() activation = Activation() activation.addAction(testRouteAction) activation.type = activationType activation.activationTimestamp = activationTime try: activation.fireActivation() except NMOSTestException as e: time.sleep(2) raise e pendingState = active.buildJSONObject() if not compare_json(preActivationState, pendingState): msg = globalConfig.test.FAIL("Scheduled Activation completed immediately") raise NMOSTestException(msg) time.sleep(2) active.assertActionCompleted(testRouteAction, retries=5) time.sleep(1)
def test_06(self, test): """Index of /single/receivers/{receiverId}/ matches the spec""" if len(self.receivers) > 0: for receiver in self.receivers: dest = "single/receivers/" + receiver + "/" valid, response = self.is05_utils.checkCleanRequestJSON("GET", dest) expected = [ "constraints/", "staged/", "active/" ] api = self.apis[CONN_API_KEY] if self.is05_utils.compare_api_version(api["version"], "v1.1") >= 0: expected.append("transporttype/") msg = "Receiver root at {} response incorrect, expected :{}, got {}".format(dest, expected, response) if valid: if compare_json(expected, response): pass else: return test.FAIL(msg) else: return test.FAIL(response) return test.PASS() else: return test.UNCLEAR("Not tested. No resources found.")
def test_33(self, test): """/bulk/ endpoint returns correct JSON""" url = "bulk/" valid, response = self.is05_utils.checkCleanRequestJSON("GET", url) if valid: expected = ['senders/', 'receivers/'] msg = "Got wrong response from {}, expected an array containing {}, got {}".format(url, expected, response) if compare_json(expected, response): return test.PASS() else: return test.FAIL(msg) else: return test.FAIL(response)
def test_02(self, test): """Single endpoint root matches the spec""" expected = ["receivers/", "senders/"] dest = "single/" valid, result = self.is05_utils.checkCleanRequestJSON("GET", dest) if valid: msg = "Got the wrong json from {} - got {}. Please check json matches the spec, including trailing " \ "slashes".format(dest, result) if compare_json(expected, result): return test.PASS() else: return test.FAIL(msg) else: return test.FAIL(result)
def test_01(self, test): """API root matches the spec""" expected = ["single/", "bulk/"] dest = "" valid, result = self.is05_utils.checkCleanRequestJSON("GET", dest) if valid: msg = "Got the wrong json from {} - got {}. Please check json matches the spec, including trailing slashes" \ .format(dest, result) if compare_json(expected, result): return test.PASS() else: return test.FAIL(msg) else: return test.FAIL(result)
def test_01_io_content_match(self, test): """Content of the /io view matches resources elsewhere in the API""" globalConfig.test = test inputList = getInputList() outputList = getOutputList() ioInstance = IO() ioJSON = ioInstance.getIOAsJSON() mockIoResource = {"inputs": {}, "outputs": {}} for input in inputList: mockIoResource["inputs"][input.id] = input.assembleInputObject() for output in outputList: mockIoResource["outputs"][output.id] = output.assembleOutputObject() if compare_json(mockIoResource, ioJSON): return test.PASS() else: return test.FAIL("IO Resource does not correctly reflect the API resources")