def setup(self): self.xml.append(cim_xml.VALUE_ARRAY([])) self.xml.append( cim_xml.VALUE_ARRAY([cim_xml.VALUE('cat'), cim_xml.VALUE('dog')]))
def setUp(self): super(MethodResponse, self).setUp() # ERROR self.xml.append( cim_xml.METHODRESPONSE('FooMethod', cim_xml.ERROR('123'))) # Empty self.xml.append(cim_xml.METHODRESPONSE('FooMethod')) # RETURNVALUE self.xml.append( cim_xml.METHODRESPONSE( 'FooMethod', cim_xml.PARAMVALUE('Dog', cim_xml.VALUE('Spottyfoot')))) # PARAMVALUE self.xml.append( cim_xml.METHODRESPONSE( 'FooMethod', cim_xml.PARAMVALUE('Dog', cim_xml.VALUE('Spottyfoot')))) # RETURNVALUE + PARAMVALUE self.xml.append( cim_xml.METHODRESPONSE( 'FooMethod', (cim_xml.RETURNVALUE(cim_xml.VALUE('Dog')), cim_xml.PARAMVALUE('Dog', cim_xml.VALUE('Spottyfoot')))))
def setUp(self): super(Property, self).setUp() # Empty self.xml.append(cim_xml.PROPERTY('PropertyName', 'string', None)) # PROPERTY self.xml.append( cim_xml.PROPERTY('PropertyName', 'string', cim_xml.VALUE('dog'))) # PROPERTY + attributes self.xml.append( cim_xml.PROPERTY('PropertyName', 'string', cim_xml.VALUE('dog'), propagated='true', class_origin='CIM_Pets')) # PROPERTY + QUALIFIER self.xml.append( cim_xml.PROPERTY('PropertyName', 'string', cim_xml.VALUE('dog'), qualifiers=[ cim_xml.QUALIFIER('IMPISH', 'string', cim_xml.VALUE('true')) ]))
def setUp(self): super(ValueArray, self).setUp() self.xml.append(cim_xml.VALUE_ARRAY([])) self.xml.append( cim_xml.VALUE_ARRAY([cim_xml.VALUE('cat'), cim_xml.VALUE('dog')]))
def setUp(self): super(Instance, self).setUp() # Empty self.xml.append(cim_xml.INSTANCE('CIM_Foo', [])) # PROPERTY self.xml.append( cim_xml.INSTANCE('CIM_Foo', [ cim_xml.PROPERTY('Dog', 'string', cim_xml.VALUE('Spotty')), cim_xml.PROPERTY('Cat', 'string', cim_xml.VALUE('Bella')) ])) # PROPERTY + QUALIFIER self.xml.append( cim_xml.INSTANCE('CIM_Foo', properties=[ cim_xml.PROPERTY('Dog', 'string', cim_xml.VALUE('Spotty')), cim_xml.PROPERTY('Cat', 'string', cim_xml.VALUE('Bella')) ], qualifiers=[ cim_xml.QUALIFIER('IMPISH', 'string', cim_xml.VALUE('true')) ])) # PROPERTY.ARRAY self.xml.append( cim_xml.INSTANCE('CIM_Pets', [ cim_xml.PROPERTY_ARRAY( 'Dogs', 'string', cim_xml.VALUE_ARRAY( [cim_xml.VALUE('Spotty'), cim_xml.VALUE('Bronte')])), cim_xml.PROPERTY_ARRAY( 'Cats', 'string', cim_xml.VALUE_ARRAY( [cim_xml.VALUE('Bella'), cim_xml.VALUE('Faux Lily')])) ])) # PROPERTY.REFERENCE self.xml.append( cim_xml.INSTANCE('CIM_Pets', [ cim_xml.PROPERTY_REFERENCE( 'Dog', cim_xml.VALUE_REFERENCE( cim_xml.CLASSNAME('CIM_Dog'))), cim_xml.PROPERTY_REFERENCE( 'Cat', cim_xml.VALUE_REFERENCE( cim_xml.CLASSNAME('CIM_Cat'))) ]))
def setUp(self): super(ParamValue, self).setUp() # Empty self.xml.append(cim_xml.PARAMVALUE('Pet')) # VALUE self.xml.append( cim_xml.PARAMVALUE('Pet', cim_xml.VALUE('Dog'), 'string')) # VALUE.REFERENCE self.xml.append( cim_xml.PARAMVALUE( 'Pet', cim_xml.VALUE_REFERENCE( cim_xml.CLASSPATH(NAMESPACEPATH(), CLASSNAME())))) # VALUE.ARRAY self.xml.append(cim_xml.PARAMVALUE('Pet', cim_xml.VALUE_ARRAY([]))) # VALUE.REFARRAY self.xml.append(cim_xml.PARAMVALUE('Pet', cim_xml.VALUE_REFARRAY([])))
def setUp(self): super(MethodCall, self).setUp() # LOCALINSTANCEPATH self.xml.append( cim_xml.METHODCALL( 'FooMethod', cim_xml.LOCALINSTANCEPATH(LOCALNAMESPACEPATH(), INSTANCENAME()))) # LOCALCLASSPATH self.xml.append( cim_xml.METHODCALL( 'FooMethod', cim_xml.LOCALCLASSPATH(LOCALNAMESPACEPATH(), CLASSNAME()))) # PARAMVALUEs self.xml.append( cim_xml.METHODCALL( 'FooMethod', cim_xml.LOCALINSTANCEPATH(LOCALNAMESPACEPATH(), INSTANCENAME()), [cim_xml.PARAMVALUE('Dog', cim_xml.VALUE('Spottyfoot'))]))
def setUp(self): super(PropertyReference, self).setUp() # Empty self.xml.append(cim_xml.PROPERTY_REFERENCE('Dogs', None)) # VALUE.REFERENCE self.xml.append( cim_xml.PROPERTY_REFERENCE( 'Dogs', cim_xml.VALUE_REFERENCE(cim_xml.CLASSNAME('CIM_Dog')))) # VALUE.REFERENCE + attributes self.xml.append( cim_xml.PROPERTY_REFERENCE('Dogs', cim_xml.VALUE_REFERENCE( cim_xml.CLASSNAME('CIM_Dog')), reference_class='CIM_Dog', class_origin='CIM_Dog', propagated='true')) # QUALIFIER + VALUE.REFERENCE self.xml.append( cim_xml.PROPERTY_REFERENCE( 'Dogs', cim_xml.VALUE_REFERENCE(cim_xml.CLASSNAME('CIM_Dog')), qualifiers=[ cim_xml.QUALIFIER('IMPISH', 'string', cim_xml.VALUE('true')) ]))
def paramvalue(obj): """Return a cim_xml node to be used as the value for a parameter.""" if isinstance(obj, (datetime, timedelta)): obj = CIMDateTime(obj) if isinstance(obj, (cim_types.CIMType, bool, StringTypes)): return cim_xml.VALUE(cim_types.atomic_to_cim_xml(obj)) if isinstance(obj, (CIMClassName, CIMInstanceName)): return cim_xml.VALUE_REFERENCE(obj.tocimxml()) if isinstance(obj, (CIMClass, CIMInstance)): return cim_xml.VALUE(obj.tocimxml().toxml()) if isinstance(obj, list): if isinstance(obj[0], (CIMClassName, CIMInstanceName)): return cim_xml.VALUE_REFARRAY([paramvalue(x) for x in obj]) return cim_xml.VALUE_ARRAY([paramvalue(x) for x in obj]) raise TypeError('Unsupported parameter type "%s"' % type(obj))
def setUp(self): super(Class, self).setUp() # Empty self.xml.append(cim_xml.CLASS('CIM_Foo')) # PROPERTY self.xml.append( cim_xml.CLASS('CIM_Foo', properties=[ cim_xml.PROPERTY('Dog', 'string', cim_xml.VALUE('Spotty')) ])) # QUALIFIER + PROPERTY self.xml.append( cim_xml.CLASS('CIM_Foo', properties=[ cim_xml.PROPERTY('Dog', 'string', cim_xml.VALUE('Spotty')) ], qualifiers=[ cim_xml.QUALIFIER('IMPISH', 'string', cim_xml.VALUE('true')) ])) # PROPERTY.ARRAY self.xml.append( cim_xml.CLASS( 'CIM_Foo', properties=[cim_xml.PROPERTY_ARRAY('Dogs', 'string', None)])) # PROPERTY.REFERENCE self.xml.append( cim_xml.CLASS( 'CIM_Foo', properties=[cim_xml.PROPERTY_REFERENCE('Dogs', None)])) # METHOD self.xml.append( cim_xml.CLASS('CIM_Foo', methods=[cim_xml.METHOD('FooMethod')]))
def setup(self): self.xml.append(cim_xml.IMETHODCALL('FooMethod', LOCALNAMESPACEPATH())) self.xml.append( cim_xml.IMETHODCALL( 'FooMethod2', LOCALNAMESPACEPATH(), [cim_xml.IPARAMVALUE('Dog', cim_xml.VALUE('Spottyfoot'))]))
def setup(self): # VALUE self.xml.append(cim_xml.RETURNVALUE(cim_xml.VALUE('Dog'))) # VALUE.REFERENCE self.xml.append( cim_xml.RETURNVALUE( cim_xml.VALUE_REFERENCE( cim_xml.CLASSPATH(NAMESPACEPATH(), CLASSNAME()))))
def setUp(self): super(ReturnValue, self).setUp() # VALUE self.xml.append(cim_xml.RETURNVALUE(cim_xml.VALUE('Dog'))) # VALUE.REFERENCE self.xml.append( cim_xml.RETURNVALUE( cim_xml.VALUE_REFERENCE( cim_xml.CLASSPATH(NAMESPACEPATH(), CLASSNAME()))))
def setUp(self): super(IParamValue, self).setUp() # Empty self.xml.append(cim_xml.IPARAMVALUE('Bird')) # VALUE self.xml.append(cim_xml.IPARAMVALUE('Pet', cim_xml.VALUE('Dog'))) # VALUE.ARRAY self.xml.append(cim_xml.IPARAMVALUE('Pet', cim_xml.VALUE_ARRAY([]))) # VALUE.REFERENCE self.xml.append( cim_xml.IPARAMVALUE( 'Pet', cim_xml.VALUE_REFERENCE( cim_xml.CLASSPATH(NAMESPACEPATH(), CLASSNAME())))) # INSTANCENAME self.xml.append(cim_xml.IPARAMVALUE('Pet', INSTANCENAME())) # CLASSNAME self.xml.append(cim_xml.IPARAMVALUE('Pet', CLASSNAME())) # TODO: QUALIFIER.DECLARATION # CLASS self.xml.append(cim_xml.IPARAMVALUE('Pet', cim_xml.CLASS('CIM_Foo'))) # INSTANCE self.xml.append( cim_xml.IPARAMVALUE('Pet', cim_xml.INSTANCE('CIM_Pet', []))) # VALUE.NAMEDINSTANCE self.xml.append( cim_xml.IPARAMVALUE( 'Pet', cim_xml.VALUE_NAMEDINSTANCE(INSTANCENAME(), cim_xml.INSTANCE('CIM_Pet', []))))
def setup(self): # Empty self.xml.append(cim_xml.PARAMETER('arg', 'string')) # QUALIFIER self.xml.append( cim_xml.PARAMETER('arg', 'string', qualifiers=[ cim_xml.QUALIFIER('IMPISH', 'string', cim_xml.VALUE('true')) ]))
def setup(self): # Empty self.xml.append(cim_xml.EXPMETHODRESPONSE('FooMethod')) # ERROR self.xml.append( cim_xml.EXPMETHODRESPONSE('FooMethod', cim_xml.ERROR('123'))) # IRETURNVALUE self.xml.append( cim_xml.EXPMETHODRESPONSE( 'FooMethod', cim_xml.IRETURNVALUE(cim_xml.VALUE('Dog'))))
def setUp(self): super(Parameter, self).setUp() # Empty self.xml.append(cim_xml.PARAMETER('arg', 'string')) # QUALIFIER self.xml.append( cim_xml.PARAMETER('arg', 'string', qualifiers=[ cim_xml.QUALIFIER('IMPISH', 'string', cim_xml.VALUE('true')) ]))
def setup(self): # Empty self.xml.append(cim_xml.PARAMETER_REFERENCE('arg')) # QUALIFIER + attributes self.xml.append( cim_xml.PARAMETER_REFERENCE('arg', reference_class='CIM_Foo', qualifiers=[ cim_xml.QUALIFIER( 'IMPISH', 'string', cim_xml.VALUE('true')) ]))
def setup(self): # Empty self.xml.append(cim_xml.PARAMETER_ARRAY('arg', 'string')) # QUALIFIERS + attributes self.xml.append( cim_xml.PARAMETER_ARRAY('arg', 'string', array_size='0', qualifiers=[ cim_xml.QUALIFIER( 'IMPISH', 'string', cim_xml.VALUE('true')) ]))
def setUp(self): super(Method, self).setUp() # Empty self.xml.append(cim_xml.METHOD('FooMethod')) # PARAMETER self.xml.append( cim_xml.METHOD('FooMethod', [cim_xml.PARAMETER('arg', 'string')])) # PARAMETER.REFERENCE self.xml.append( cim_xml.METHOD('FooMethod', [cim_xml.PARAMETER_REFERENCE('arg', 'CIM_Foo')])) # PARAMETER.ARRAY self.xml.append( cim_xml.METHOD('FooMethod', [cim_xml.PARAMETER_ARRAY('arg', 'string')])) # PARAMETER.REFARRAY self.xml.append( cim_xml.METHOD('FooMethod', [cim_xml.PARAMETER_REFARRAY('arg', 'CIM_Foo')])) # PARAMETER + attributes self.xml.append( cim_xml.METHOD('FooMethod', [cim_xml.PARAMETER('arg', 'string')], return_type='uint32', class_origin='CIM_Foo', propagated='true')) # QUALIFIER + PARAMETER self.xml.append( cim_xml.METHOD('FooMethod', [cim_xml.PARAMETER('arg', 'string')], qualifiers=[ cim_xml.QUALIFIER('IMPISH', 'string', cim_xml.VALUE('true')) ]))
def setUp(self): super(ExpMethodResponse, self).setUp() # Empty self.xml.append(cim_xml.EXPMETHODRESPONSE('FooMethod')) # ERROR self.xml.append( cim_xml.EXPMETHODRESPONSE('FooMethod', cim_xml.ERROR('123'))) # IRETURNVALUE self.xml.append( cim_xml.EXPMETHODRESPONSE( 'FooMethod', cim_xml.IRETURNVALUE(cim_xml.VALUE('Dog'))))
def setUp(self): super(ParameterReferenceArray, self).setUp() # Empty self.xml.append(cim_xml.PARAMETER_REFARRAY('arg')) # QUALIFIERS + attributes self.xml.append( cim_xml.PARAMETER_REFARRAY('arg', reference_class='CIM_Foo', array_size='0', qualifiers=[ cim_xml.QUALIFIER( 'IMPISH', 'string', cim_xml.VALUE('true')) ]))
def setUp(self): super(PropertyArray, self).setUp() # Empty self.xml.append(cim_xml.PROPERTY_ARRAY('Dogs', 'string')) # VALUE.ARRAY self.xml.append( cim_xml.PROPERTY_ARRAY( 'Dogs', 'string', cim_xml.VALUE_ARRAY( [cim_xml.VALUE('Spotty'), cim_xml.VALUE('Bronte')]))) # VALUE.ARRAY + attributes self.xml.append( cim_xml.PROPERTY_ARRAY('Dogs', 'string', cim_xml.VALUE_ARRAY([ cim_xml.VALUE('Spotty'), cim_xml.VALUE('Bronte') ]), array_size='2', class_origin='CIM_Dog')) self.xml.append(cim_xml.PROPERTY_ARRAY('Dogs', 'string', None)) # QUALIFIER + VALUE.ARRAY self.xml.append( cim_xml.PROPERTY_ARRAY('Dogs', 'string', cim_xml.VALUE_ARRAY([ cim_xml.VALUE('Spotty'), cim_xml.VALUE('Bronte') ]), qualifiers=[ cim_xml.QUALIFIER( 'IMPISH', 'string', cim_xml.VALUE('true')) ]))
def setUp(self): super(Qualifier, self).setUp() # Note: DTD 2.2 allows qualifier to be empty # VALUE self.xml.append( cim_xml.QUALIFIER('IMPISH', 'string', cim_xml.VALUE('true'))) # VALUE + attributes self.xml.append( cim_xml.QUALIFIER('Key', 'string', cim_xml.VALUE('true'), overridable='true')) self.xml.append( cim_xml.QUALIFIER('Description', 'string', cim_xml.VALUE('blahblah'), translatable='true')) self.xml.append( cim_xml.QUALIFIER('Version', 'string', cim_xml.VALUE('foorble'), tosubclass='false', translatable='true')) # VALUE.ARRAY self.xml.append( cim_xml.QUALIFIER( 'LUCKYNUMBERS', 'uint32', cim_xml.VALUE_ARRAY([cim_xml.VALUE('1'), cim_xml.VALUE('2')])))
def setup(self): self.xml.append(cim_xml.VALUE('dog')) self.xml.append(cim_xml.VALUE(None)) self.xml.append(cim_xml.VALUE(''))
def setUp(self): super(Value, self).setUp() # The VALUE element depends on whether XML-based or CDATA-based # escaping is used. Therefore, we modify the module-level switch that # controls that and run each test twice (wth different expected XML # strings). cim_xml._CDATA_ESCAPING = True # pylint: disable=protected-access self.xml.append(cim_xml.VALUE('dog')) self.xml_str.append('<VALUE>dog</VALUE>') # self.xml.append(cim_xml.VALUE(None)) # Note: This is illegal, Value.Null should be used instead. self.xml.append(cim_xml.VALUE('')) self.xml_str.append('<VALUE></VALUE>') # Assum. not folded to <VALUE/> # Some control characters self.xml.append(cim_xml.VALUE('a\nb\rc\td')) self.xml_str.append('<VALUE>a\nb\rc\td</VALUE>') # Assuming XML 1.1 # Some XML special characters self.xml.append(cim_xml.VALUE('a&b<c>d')) self.xml_str.append('<VALUE><![CDATA[a&b<c>d]]></VALUE>') # Some XML special characters, already XML-escaped self.xml.append(cim_xml.VALUE('a&b<c>d')) self.xml_str.append('<VALUE><![CDATA[a&b<c>d]]></VALUE>') # Some XML special characters, already CDATA-escaped self.xml.append(cim_xml.VALUE('<![CDATA[a&b<c>d]]>')) self.xml_str.append( '<VALUE><![CDATA[<![CDATA[a&b<c>d]]]><![CDATA[]>]]></VALUE>') # set back to its default cim_xml._CDATA_ESCAPING = False # pylint: disable=protected-access self.xml.append(cim_xml.VALUE('dog')) self.xml_str.append('<VALUE>dog</VALUE>') # self.xml.append(cim_xml.VALUE(None)) # Note: This is illegal, Value.Null is used instead. self.xml.append(cim_xml.VALUE('')) self.xml_str.append('<VALUE></VALUE>') # Assum. not folded to <VALUE/> # Some control characters self.xml.append(cim_xml.VALUE('a\nb\rc\td')) self.xml_str.append('<VALUE>a\nb\rc\td</VALUE>') # Assuming XML 1.1 # Some XML special characters self.xml.append(cim_xml.VALUE('a&b<c>d')) self.xml_str.append('<VALUE>a&b<c>d</VALUE>') # Some XML special characters, already XML-escaped self.xml.append(cim_xml.VALUE('a&b<c>d')) self.xml_str.append('<VALUE>a&amp;b&lt;c&gt;d</VALUE>') # Some XML special characters, already CDATA-escaped self.xml.append(cim_xml.VALUE('<![CDATA[a&b<c>d]]>')) self.xml_str.append( '<VALUE><![CDATA[a&b<c>d]]></VALUE>')
def setUp(self): super(IReturnValue, self).setUp() # Empty self.xml.append(cim_xml.IRETURNVALUE(None)) # CLASSNAME self.xml.append(cim_xml.IRETURNVALUE(CLASSNAME())) # INSTANCENAME self.xml.append(cim_xml.IRETURNVALUE(INSTANCENAME())) # VALUE self.xml.append(cim_xml.IRETURNVALUE(cim_xml.VALUE('Dog'))) # VALUE.OBJECTWITHPATH self.xml.append( cim_xml.IRETURNVALUE( cim_xml.VALUE_OBJECTWITHPATH( cim_xml.CLASSPATH(NAMESPACEPATH(), CLASSNAME()), cim_xml.CLASS('CIM_Foo')))) # VALUE.OBJECTWITHLOCALPATH self.xml.append( cim_xml.IRETURNVALUE( cim_xml.VALUE_OBJECTWITHLOCALPATH( cim_xml.LOCALCLASSPATH(LOCALNAMESPACEPATH(), CLASSNAME()), cim_xml.CLASS('CIM_Foo')))) # VALUE.OBJECT self.xml.append( cim_xml.IRETURNVALUE( cim_xml.VALUE_OBJECT(cim_xml.INSTANCE('CIM_Pet', [])))) # OBJECTPATH self.xml.append( cim_xml.IRETURNVALUE( cim_xml.OBJECTPATH( cim_xml.INSTANCEPATH(NAMESPACEPATH(), INSTANCENAME())))) # TODO: QUALIFIER.DECLARATION # VALUE.ARRAY self.xml.append(cim_xml.IRETURNVALUE(cim_xml.VALUE_ARRAY([]))) # VALUE.REFERENCE self.xml.append( cim_xml.IRETURNVALUE( cim_xml.VALUE_REFERENCE( cim_xml.CLASSPATH(NAMESPACEPATH(), CLASSNAME())))) # CLASS self.xml.append(cim_xml.IRETURNVALUE(cim_xml.CLASS('CIM_Foo'))) # INSTANCE self.xml.append(cim_xml.IRETURNVALUE(cim_xml.INSTANCE('CIM_Pet', []))) # VALUE.NAMEDINSTANCE self.xml.append( cim_xml.IRETURNVALUE( cim_xml.VALUE_NAMEDINSTANCE(INSTANCENAME(), cim_xml.INSTANCE('CIM_Pet', []))))