def test_evaluatescript(self):
        """
        Test EvaluateScript ColumnOperations.

        This test calls the EvaluateScript function with the
        script 'num1 + num2' and two numbers as parameters,
        effectively summarizing the two input numbers.
        """
        params = to_numeric_parameters('num1', 'num2')

        header = SSE.ScriptRequestHeader(script='args[0] + args[1]',
                                         functionType=SSE.TENSOR,
                                         returnType=SSE.NUMERIC,
                                         params=params)

        duals = numbers_to_duals(42, 42)
        rows = duals_to_rows(duals)

        # Trailing commas to make iterable sequences of tuples.
        bundled_rows = (SSE.BundledRows(rows=rows)),
        metadata = (('qlik-scriptrequestheader-bin', header.SerializeToString()), )

        result = self.stub.EvaluateScript(request_iterator=iter(bundled_rows), metadata=metadata)

        for bundled_row in result:
            for row in bundled_row.rows:
                for dual in row.duals:
                    assert dual.numData == 84
    def test_executefunction(self):
        """
        Test ExecuteFunction HelloWorld.

        This tests calls the ExecuteFunction function, with an
        id corresponding to the HelloWorld plugin function.
        """

        header = SSE.FunctionRequestHeader(functionId=HELLO_WORLD_ID,
                                           version="1")

        duals = strings_to_duals('Hello World!')
        rows = duals_to_rows(duals)

        # Trailing commas to make iterable sequences of tuples.
        bundled_rows = (SSE.BundledRows(rows=rows)),
        metadata = (('qlik-functionrequestheader-bin',
                     header.SerializeToString()), )

        result = self.stub.ExecuteFunction(request_iterator=iter(bundled_rows),
                                           metadata=metadata)

        for bundled_row in result:
            for row in bundled_row.rows:
                for dual in row.duals:
                    assert dual.strData == 'Hello World!'
Example #3
0
    def test_evaluatescript(self):
        """
        Test EvaluateScript HelloWorld.

        This test calls the EvaluateScript function with the
        script 'str1 + str2' and two strings as parameters,
        effectively concatenating the two input strings.
        """
        params = to_string_parameters('str1', 'str2')

        header = SSE.ScriptRequestHeader(script='args[0] + args[1]',
                                         functionType=SSE.TENSOR,
                                         returnType=SSE.STRING,
                                         params=params)

        duals = strings_to_duals('Hello', 'World')
        rows = duals_to_rows(duals)

        # Trailing commas to make iterable sequences of tuples.
        bundled_rows = (SSE.BundledRows(rows=rows)),
        metadata = (('qlik-scriptrequestheader-bin', header.SerializeToString()), )

        result = self.stub.EvaluateScript(request_iterator=iter(bundled_rows), metadata=metadata)

        for bundled_row in result:
            for row in bundled_row.rows:
                for dual in row.duals:
                    assert dual.strData == 'HelloWorld'
Example #4
0
    def test_executefunction(self):
        """
        Test ExecuteFunction ColumnOperations.

        This tests calls the ExecuteFunction function, with an
        id corresponding to the ColumnOperations plugin function.
        """

        header = SSE.FunctionRequestHeader(functionId=SUM_OF_ROWS_ID,
                                           version="1")

        duals = numbers_to_duals(1, 2, 3, 4, 5)
        rows = duals_to_rows(duals)

        # Trailing commas to make iterable sequences of tuples.
        bundled_rows = (SSE.BundledRows(rows=rows)),
        metadata = (('qlik-functionrequestheader-bin',
                     header.SerializeToString()), )

        result = self.stub.ExecuteFunction(request_iterator=iter(bundled_rows),
                                           metadata=metadata)

        for bundled_row in result:
            for row in bundled_row.rows:
                for dual in row.duals:
                    assert dual.numData == 15