Exemplo n.º 1
0
    def test_15_block_constraint(self, test):
        """It is not possible to make an out-of-block route when block_size
        is anything other than 1"""
        globalConfig.test = test

        inputList = getInputList()
        constraintSet = False
        constrainedInputs = []
        for inputInstance in inputList:
            if inputInstance.getBlockSize() > 1:
                constraintSet = True
                constrainedInputs.append(inputInstance)

        if not constraintSet:
            return test.NA("No inputs constrain by block.")

        chosenInput = constrainedInputs[0]
        output = chosenInput.getRoutableOutputs()
        action = Action(
            chosenInput.id,
            output.id
        )
        activation = Activation()
        activation.addAction(action)
        try:
            activation.fireActivation()
        except NMOSTestException:
            return test.PASS()

        return test.FAIL("Was able to break block size routing constraint")
Exemplo n.º 2
0
 def unrouteAll(self):
     outputList = getOutputList()
     activation = Activation()
     for outputInstance in outputList:
         for channelID in range(0, len(outputInstance.getChannelList())):
             action = Action(None, outputInstance.id, None, channelID)
             activation.addAction(action)
     activation.fireActivation()
Exemplo n.º 3
0
    def test_13_violate_routing_constraints_rejected(self, test):
        """Attempting to violate routing constraints results in an HTTP 400 response"""
        globalConfig.test = test

        outputList = getOutputList()
        constrainedOutputList = []
        for outputInstance in outputList:
            constraints = outputInstance.getCaps()
            try:
                routableInputs = constraints['routable_inputs']
            except KeyError:
                pass
            else:
                constrainedOutputList.append({
                    "output": outputInstance,
                    "routableInputs": routableInputs
                })

        if len(constrainedOutputList) == 0:
            return test.NA(
                "Could not test - no outputs have routing constraints set.")

        inputList = getInputList()
        inputIDList = []
        for inputInstance in inputList:
            inputIDList.append(inputInstance.id)

        for constrainedOutput in constrainedOutputList:
            forbiddenRoutes = copy.deepcopy(inputIDList)

            for routableInputID in constrainedOutput['routableInputs']:
                forbiddenRoutes.remove(routableInputID)

            if len(forbiddenRoutes) > 0:

                action = Action(forbiddenRoutes[0],
                                constrainedOutput['output'].id)
                activation = Activation()
                activation.addAction(action)

                try:
                    activation.checkReject()
                    return test.PASS()
                except NMOSTestException:
                    msg = (
                        "Was able to create a forbidden route between input {}"
                        " and output {} despite routing constraint."
                        "".format(forbiddenRoutes[0], outputInstance.id))
                    return test.FAIL(msg)
        return test.NA("Could not test - no route is forbidden.")
Exemplo n.º 4
0
 def findAcceptableTestRoute(self):
     routableInputs = self.getRoutableInputList()
     return Action(routableInputs[0], self.id)
Exemplo n.º 5
0
    def test_14_reordering_constraint(self, test):
        """It is not possible to re-order channels when re-ordering is
        set to `false`"""
        globalConfig.test = test

        inputList = getInputList()

        constrainedInputs = []
        constraintSet = False
        for inputInstance in inputList:
            if not inputInstance.getReordering():
                constrainedInputs.append(inputInstance)
                constraintSet = True

        if not constraintSet:
            return test.NA("No inputs prevent re-ordering.")

        # Filter out inputs where the constraint can't be tested because the
        # block size prevents re-ordering anyway
        filteredInputs = []
        for inputInstance in constrainedInputs:
            blockSize = inputInstance.getBlockSize()
            if len(inputInstance.getChannelList) >= blockSize * 2:
                # Constraint makes no sense, can't re-order to to block size
                filteredInputs.append(inputInstance)

        # Filter out inputs where there is no output that channels could be
        # re-ordered into
        targetOutputList = {}
        testableInputs = []
        for inputInstance in filteredInputs:
            routableOutputList = inputInstance.getRoutableOutputs()
            for outputInstance in routableOutputList:
                if len(outputInstance.getChannelList) >= inputInstance.getBlockSize() * 2:
                    targetOutputList[inputInstance.id] = outputInstance
            if inputInstance.id in targetOutputList.keys:
                testableInputs.append(inputInstance)

        # Cross over blocks one and two on an input and output
        # e.g for a block size of 2:
        # IN            OUT
        # 0 ____   ____ 0
        # 1 ___ \ / ___ 1
        #      \ X /
        #       X X
        # 2 ___/ X \___ 2
        # 3 ____/ \____ 3
        activation = Activation()
        for inputInstance in testableInputs:
            for inputChannelIndex in range(0, inputInstance.getBlockSize()):
                outputChannelIndex = inputChannelIndex + blockSize
                blockOneAction = Action(
                    inputInstance.id,
                    targetOutputList[inputInstance.id],
                    inputChannelIndex,
                    outputChannelIndex
                )
                blockTwoAction = Action(
                    inputInstance.id,
                    targetOutputList[inputInstance.id],
                    outputChannelIndex,
                    inputChannelIndex
                )
                activation.addAction(blockOneAction)
                activation.addAction(blockTwoAction)

        try:
            activation.fireActivation()
        except NMOSTestException:
            return test.PASS()

        return test.FAIL("Channels could be re-ordered despite re-ordering constraint.")