def setup_for_parameter(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 parameter with the specified data type and valuemap and values qualifiers. """ test_parm = CIMParameter(PARMNAME, type=integer_type, is_array=is_array) if valuemap is not None: test_parm.qualifiers['ValueMap'] = \ CIMQualifier('ValueMap', valuemap, 'string') if values is not None: test_parm.qualifiers['Values'] = \ CIMQualifier('Values', values, 'string') test_meth = CIMMethod(METHNAME, return_type='string') test_meth.parameters[PARMNAME] = test_parm test_class = CIMClass(CLASSNAME) test_class.methods[METHNAME] = test_meth self.conn.GetClass = Mock(return_value=test_class) vm = ValueMapping.for_parameter(server, NAMESPACE, CLASSNAME, METHNAME, PARMNAME) return vm
def test_leaks_CIMClass_method(): """ Test function with a CIMClass object that has one method. """ _ = CIMClass('CIM_Foo', methods=[ CIMMethod('M1', return_type='string'), ])
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
def build_classes(): """ Function that builds and returns a single class: CIM_Foo that will to be used as a test class for the mock class tests. """ # build the key properties qkey = {'Key': CIMQualifier('Key', True)} dkey = {'Description': CIMQualifier('Description', 'blah blah')} # build the CIMClass with properties and methods. c = CIMClass('CIM_FooDirLoad', qualifiers=dkey, properties={ 'InstanceID': CIMProperty('InstanceID', None, qualifiers=qkey, type='string', class_origin='CIM_Foo', propagated=False) }, methods={ 'Delete': CIMMethod('Delete', 'uint32', qualifiers=dkey, class_origin='CIM_Foo', propagated=False), 'Fuzzy': CIMMethod('Fuzzy', 'string', qualifiers=dkey, class_origin='CIM_Foo', propagated=False) }) # add the objects to the mock repository CONN.add_cimobjects(c) # noqa: F821
exp_result=None, ), TypeError, None, True), ("cim_obj has invalid type", dict( in_kwargs=dict(cim_obj=42, ), exp_result=None, ), TypeError, None, True), ("cim_obj is CIMProperty with PUnit #1 (byte)", dict( in_kwargs=dict(cim_obj=CIMProperty( 'P1', value='foo', qualifiers=[TEST_QUAL_PUNIT1_BYTE])), exp_result=u'B', ), None, None, True), ("cim_obj is CIMMethod with PUnit #1 (byte)", dict( in_kwargs=dict(cim_obj=CIMMethod( 'P1', return_type='uint32', qualifiers=[TEST_QUAL_PUNIT1_BYTE])), exp_result=u'B', ), None, None, True), ("cim_obj is CIMParameter with PUnit #1 (byte)", dict( in_kwargs=dict(cim_obj=CIMParameter( 'P1', type='uint32', qualifiers=[TEST_QUAL_PUNIT1_BYTE])), exp_result=u'B', ), None, None, True), ("cim_obj is CIMProperty with PUnit #2 (byte)", dict( in_kwargs=dict(cim_obj=CIMProperty( 'P1', value='foo', qualifiers=[TEST_QUAL_PUNIT2_BYTE])), exp_result=u'B', ), None, None, True), ("cim_obj is CIMProperty with Units #1 (Bytes)",
def test_leaks_CIMMethod_minimal(): """ Test function with a minimal CIMMethod object (i.e. no parameters, no qualifiers). """ _ = CIMMethod('M1', return_type='string')