Exemple #1
0
    def setup_for_method(self, server, type_, valuemap, values):
        """
        Return a new ValueMapping object that is set up for a CIM method
        with the specified data type and valuemap and values qualifiers.
        """
        test_meth = CIMMethod(METHNAME, return_type=type_)
        if valuemap is not None:
            test_meth.qualifiers['ValueMap'] = \
                CIMQualifier('ValueMap', valuemap, 'string')
        if values is not None:
            test_meth.qualifiers['Values'] = \
                CIMQualifier('Values', values, 'string')
        test_class = CIMClass(CLASSNAME)
        test_class.methods[METHNAME] = test_meth
        self.conn.GetClass = Mock(return_value=test_class)

        vm = ValueMapping.for_method(server, NAMESPACE, CLASSNAME, METHNAME)
        return vm
Exemple #2
0
    def setup_for_method(self, server, integer_type, is_array, valuemap,
                         values):
        # pylint: disable=redefined-outer-name
        """
        Return a new ValueMapping object that is set up for a CIM method
        with the specified data type and valuemap and values qualifiers.
        """
        if is_array:
            pytest.skip("CIM methods cannot return arrays")
        test_meth = CIMMethod(METHNAME, return_type=integer_type)
        if valuemap is not None:
            test_meth.qualifiers['ValueMap'] = \
                CIMQualifier('ValueMap', valuemap, 'string')
        if values is not None:
            test_meth.qualifiers['Values'] = \
                CIMQualifier('Values', values, 'string')
        test_class = CIMClass(CLASSNAME)
        test_class.methods[METHNAME] = test_meth
        self.conn.GetClass = Mock(return_value=test_class)

        vm = ValueMapping.for_method(server, NAMESPACE, CLASSNAME, METHNAME)
        return vm