{"push_id":2103463208,"size":1,"distinct_size":1,"ref":"refs/heads/andy/improve-objects","head":"7cda21ab0bb02e972b64de1eb670081740e117b4","before":"d165c9a2a0400e051be7b3093b26b55c00c951bb","commits":[{"sha":"7cda21ab0bb02e972b64de1eb670081740e117b4","author":{"name":"Andreas Maier","email":"09eea454902a0a0e7ce97ef39ca648af84c1a80a@de.ibm.com"},"message":"Improved checks and conversions when setting attributes in cim_obj.py.\n\nThe motivation for this change is:\n\n1. The constructor parameters are subject to certain checks and automatic\n   conversions. The instance attributes can be modified through their setter\n   methods, but currently they only store the provided values. It would be\n   more consistent if the same checks and automatic conversions would be\n   performed by the setter methods, as in the constructor.\n   This contributes also to addressing issue 746.\n\nDetails:\n\n* Updating attributes of objects of CIM object classes (e.g. updating\n  the `value` attribute of a `CIMProperty` object) now applies the same\n  conversions and nearly the same checks as for the same-named\n  constructor parameters.\n\n* Changed parameter/attribute conversions and checks in applicable CIM\n  object classes (from `CIMInstanceName`, `CIMInstance`, `CIMClassName`,\n  `CIMClass`, `CIMProperty`, `CIMMethod`, `CIMParameter`, `CIMQualifier`,\n  `CIMQualifierDeclaration`) as follows:\n\n  - For classes with a `name` parameter/attribute (i.e. `CIMProperty`,\n    `CIMMethod`, `CIMParameter`, `CIMQualifier`,\n    `CIMQualifierDeclaration`), the requirement for the `name`\n    parameter/attribute not to be `None` that had previously been\n    documented is now enforced by raising `ValueError`.\n    Previously, this was tolerated in some cases, and `TypeError` was\n    raised in other cases.\n\n  - For classes with an optional `type` parameter and a `value` parameter\n    (i.e. `CIMProperty`, `CIMQualifier`, `CIMQualifierDeclaration`),\n    the type is now inferred from the `value` parameter, if the type is\n    `None`. If that is not possible (for example because the value is\n    a Python integer), `ValueError` is raised.\n    Previously, that was done only for `CIMProperty`. The other classes\n    tolerated that and the resulting object had a type of `None`.\n\n  - For classes with a required `type` parameter or without a `value`\n    parameter (i.e. `CIMParameter`; its `value` parameter is\n    deprecated), the `type` parameter is now enforced not to be `None`\n    and `ValueError` is raised if `None`.\n    Previously, this was tolerated and the resulting object had a type\n    of `None`.\n\n  - The `value` parameter/attribute can now be of arbitrary Python\n    types, as long as the value can be converted to the proper CIM type.\n    Previously, strings have been converted to unicode, but all other\n    values had to be a `CIMType` (and if not, the value was stored as\n    provided, resulting in values that were not CIM types).\n\n  - For classes with a `is_array` parameter/attribute (i.e.\n    `CIMProperty`, `CIMParameter`, `CIMQualifierDeclaration`, that\n    attribute is now inferred (if passed as `None`) from whether the\n    `value` attribute is a list. Previously, that was done only\n    for `CIMProperty`, and it was required to be provided for the\n    other classes.\n\n  - For parameters/attributes that are dictionaries (`properties`,\n    `keybindings`, `parameters`, `qualifiers`), the consistency between\n    the dict keys and the names of the CIM elements that are the dict\n    values is now enforced (case insensitively) and `ValueError` is\n    raised in case of inconsistencies. Added `_cim_keybinding()`,\n    `_cim_property_value()`, `_cim_property_decl()`, `_cim_method()`,\n    and `_cim_qualifier()` in support of that.\n    Previously, such inconsistencies were tolerated.\n\n  - Boolean parameters/attributes (e.g. `is_array`) are now converted\n    to `bool` type unless they are `None`. Added `_ensure_bool()` in\n    support of that.\n    Previously, the provided value was stored, resulting in non-bool values\n    for these attributes.\n\n* For `CIMInstanceName`, specifying input keybindings as Python numeric types\n  (`int`, `float`) has been deprecated, and an according deprecation warning\n  will now be raised. These types had previously been documented to be\n  invalid.\n\n* For `CIMInstanceName`, the keybindings can now be specified as\n  `CIMProperty` objects from which their value will be used (this is in\n  addition to specfying the values of keybindings as CIM data types).\n\n* Added static `from_wbem_uri()` methods to `CIMInstanceName` and\n  `CIMClassName`, that create a new object of these classes from a\n  WBEM URI string.\n\n* Docs: Added examples for constructing `CIMQualifier` objects\n  to the documentation of its init function.\n\n* Test: Added and changed testcases in test_cim_obj.py to accomodate\n  the new behaviors of CIM object classes.\n\n* Test: Added the examples documented for `CIMProperty` and `CIMQualifier`\n  as tests.\n\n* Test: Improved the assertion output in unittest_extensions.py by removing\n  the fixed messages that did not really help.\n\n* Test: In test_cim_obj.py, now using unittest2 because we started\n  using `assertRaises()` as a context manager. This was introduced\n  into unittest only in Python 2.7.\n\nSigned-off-by: Andreas Maier <maiera@de.ibm.com>","distinct":true,"url":"https://api.github.com/repos/pywbem/pywbem/commits/7cda21ab0bb02e972b64de1eb670081740e117b4"}]}
{"actor":{"display_login":"andy-maier"}}