Skip to content

Commit

Permalink
Improved and converted more of test_cim_obj to py.test; Fixes in cim_obj
Browse files Browse the repository at this point in the history
Details:
- Converted all test classes for `__str__()` and `__repr__()`
  of CIM object classes to py.test.
- Converted most test classes for `__init__()` of CIM object classes to
  py.test and for those, added tests for the position of init arguments,
  and improved the test cases.
- Fixed a bug in cim_obj where setting the `qualifiers` attribute of
  `CIMProperty`, `CIMMethod` and `CIMParameter` did not ensure that the
  items in the input dictionary were converted to `CIMQualifier` objects.
  It now ensures that. Adjusted the test cases accordingly. Note that
  that conversion had already been done for `CIMClass` and `CIMInstance`.
- Fixed a bug in cim_obj where the `DeprecationWarning` when setting the
  deprecated `value` attribute of `CIMParameter` was always issued even
  when the new value was `None` (which is the default value, so the warning
  was issued even when the `value` attribute was not used at all).
  Now, the warning is only issued when the new value is not `None`.
  Adjusted the test cases accordingly.
- The getter method for the deprecated `value` attribute of `CIMParameter`
  also issued a `DeprecationWarning`. Removed that warning because issuing
  it in the setter method is sufficient (the setter method is also used
  when initializing an object). Adjusted the test cases accordingly.

Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Dec 18, 2017
1 parent e7510d1 commit ebe3499
Show file tree
Hide file tree
Showing 2 changed files with 2,786 additions and 985 deletions.
32 changes: 23 additions & 9 deletions pywbem/cim_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -3202,8 +3202,13 @@ def qualifiers(self):
@qualifiers.setter
def qualifiers(self, qualifiers):
"""Setter method; for a description see the getter method."""
# We make sure that the dictionary is a NocaseDict object, and that the
# property values are CIMQualifier objects:
# pylint: disable=attribute-defined-outside-init
self._qualifiers = NocaseDict(qualifiers)
self._qualifiers = NocaseDict()
if qualifiers:
for key, value in qualifiers.items():
self._qualifiers[key] = _cim_qualifier(key, value)

def copy(self):
"""
Expand Down Expand Up @@ -3734,8 +3739,13 @@ def qualifiers(self):
@qualifiers.setter
def qualifiers(self, qualifiers):
"""Setter method; for a description see the getter method."""
# We make sure that the dictionary is a NocaseDict object, and that the
# property values are CIMQualifier objects:
# pylint: disable=attribute-defined-outside-init
self._qualifiers = NocaseDict(qualifiers)
self._qualifiers = NocaseDict()
if qualifiers:
for key, value in qualifiers.items():
self._qualifiers[key] = _cim_qualifier(key, value)

def _cmp(self, other):
"""
Expand Down Expand Up @@ -4108,8 +4118,13 @@ def qualifiers(self):
@qualifiers.setter
def qualifiers(self, qualifiers):
"""Setter method; for a description see the getter method."""
# We make sure that the dictionary is a NocaseDict object, and that the
# property values are CIMQualifier objects:
# pylint: disable=attribute-defined-outside-init
self._qualifiers = NocaseDict(qualifiers)
self._qualifiers = NocaseDict()
if qualifiers:
for key, value in qualifiers.items():
self._qualifiers[key] = _cim_qualifier(key, value)

@property
def value(self):
Expand All @@ -4118,17 +4133,16 @@ def value(self):
this attribute does not make any sense. Accessing it will cause a
:term:`DeprecationWarning` to be issued.
"""
warnings.warn(
"The value attribute of CIMParameter is deprecated",
DeprecationWarning)
return self._value

@value.setter
def value(self, value):
"""Setter method; for a description see the getter method."""
warnings.warn(
"The value attribute of CIMParameter is deprecated",
DeprecationWarning)
if value is not None:
warnings.warn(
"The value attribute of CIMParameter (name=%r) is deprecated" %
self.name,
DeprecationWarning)
# pylint: disable=attribute-defined-outside-init
self._value = cimvalue(value, self.type)

Expand Down
Loading

0 comments on commit ebe3499

Please sign in to comment.