Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes, more tests and some cleanup for CIM-XML tuple parser
Details, potentially visible to pywbem users: - Fixed the issue that the VALUETYPE attribute of the KEYVALUE element was required in parse_keyvalue(). DSP0201 defines it as optional, with a default of 'string'. That is now implemented. - If both the TYPE and VALUETYPE attributes are specified on a KEYVALUE element, TYPE now takes precedence. Previously, VALUETYPE took precedence. DSP0201 leaves the precedence open in case of such discrepancies, but it seems more logical to let the more precise value take precedence. - Fixed the issue that hex representations of integers in key values returned from the server were not supported. - Fixed the issue that the tupleparser accepted characters for char16 typed values outside of the range for UCS-2 characters. Such characters are now rejected by raising ParseError. - Fixed the issue that the tupleparser tolerated invalid child elements under a INSTANCE and ERROR elements. This now results in a ParseError being raised. - Fixed the issue that the tupleparser did not default the `propagated` attribute to `False` (as required by DSP0201) when creating `CIMProperty` objects from the result of operations returning properties (e.g. GetInstance or GetClass). It does now. - Improved the message text in `ParseError` exceptions raised by the tupleparser. Details, not visible to pywbem users: - Cleaned up the fact that the tupleparser did not default the `propagated` attribute to `False` (as required by DSP0201) when creating `CIMMethod` objects from the result of operations returning methods (e.g. GetClass). The parser now explicitly sets the `propagated` attribute to `False` if it is not specified in the CIM-XML. However, this is only a cleanup change, because the default value of the corresponding `CIMMethod` init parameter was already `False`, and so this change does not result in a different attribute value. - As a consequence of the defaulting of propagated on properties, changed many test cases in the testclient yaml files to set propagated: false explicitly, on the expected objects. - Added an assertion to pcdata() that the returned data is a unicode string type. This is guaranteed by the fact that the SAX parser uses the expat reader, even in case the string offered to its parseString() method is a byte string, but this is not obvious, and we want to know when it is not a unicode string. - Changed the literal strings used for `join()` to be unicode literals, so the empty string produced when the join list is empty is also a unicode string. - Removed the use of byname() in the tupleparser because in all cases, the lists of CIM objects can now be passed on directly. - The byname() function in cim_obj.py now returns an OrderedDict that preserves the order of items in the input list. In addition, because that function is no longer used in pywbem, it now issues a DeprecationWarning (it was always in pywbem and could illegally have been used by users). - Cleaned up calls to check_node() by removing any optional arguments that were empty lists, when the default value None had the same effect. Updated the description of check_node() to clarify how None is treated for the attribute lists. - Now the test_client program preserves the order of yaml dicts when loading testcases from the yaml files. This required establishing the same order in the testcases between the pywbem API definitions and the HTTP messages. This is done using the yamlordereddictloader Pyton package. Added that package to the development dependencies. - The `NAME` attribute for a PROPERTY element was listed in both the required and optional attribute list in its parsing function. Removing it from the optional list is a cleanup that is not externally visible. - In wbem_request(), fixed the (internal) documentation about the returned type: It returns a byte string, not a unicode string. - In the parse_...() functions, clarified the description in many (not all) cases. - Moved all unpacking of numeric values into a new unpack_numeric() function. - Moved all unpacking of string, char16 and datetime values into a new unpack_string() function. Strings are now ensured to be unicode. Datetime values are now returned as CIMDateTime objects. - Added many testcases for the tupleparse parse_XXX() functions. - Changed some variable names in `parse_...()` functions to be more consistent. Signed-off-by: Andreas Maier <maiera@de.ibm.com>
- Loading branch information