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
), 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)", dict( in_kwargs=dict(cim_obj=CIMProperty( 'P1', value='foo', qualifiers=[TEST_QUAL_UNITS1_BYTES])), exp_result=u'B', ), None, None, True), ("cim_obj is CIMProperty with Units #2 (Bytes)",
def test_leaks_CIMParameter_minimal(): """ Test function with a minimal CIMParameter object (i.e. no qualifiers). """ _ = CIMParameter('P1', type='string')
def test_all(self): # Single-valued parameters self._run_single(CIMParameter('Param', 'string')) self._run_single( CIMParameter('Param', 'string', qualifiers={'Key': CIMQualifier('Key', True)})) # Reference parameters self._run_single(CIMParameter('RefParam', 'reference')) self._run_single( CIMParameter('RefParam', 'reference', reference_class='CIM_Foo')) self._run_single( CIMParameter('RefParam', 'reference', reference_class='CIM_Foo', qualifiers={'Key': CIMQualifier('Key', True)})) # Array parameters self._run_single(CIMParameter('Array', 'string', is_array=True)) self._run_single( CIMParameter('Array', 'string', is_array=True, array_size=10)) self._run_single( CIMParameter('Array', 'string', is_array=True, array_size=10, qualifiers={'Key': CIMQualifier('Key', True)})) # Reference array parameters self._run_single(CIMParameter('RefArray', 'reference', is_array=True)) self._run_single( CIMParameter('RefArray', 'reference', is_array=True, reference_class='CIM_Foo')) self._run_single( CIMParameter('RefArray', 'reference', is_array=True, reference_class='CIM_Foo', array_size=10)) self._run_single( CIMParameter('RefArray', 'reference', is_array=True, reference_class='CIM_Foo', array_size=10, qualifiers={'Key': CIMQualifier('Key', True)}))