Skip to content

Commit

Permalink
Accomodate recent pywbem 1.0.0 changes
Browse files Browse the repository at this point in the history
Details:

* Removed the use of the 'property_list' init parameter for CIMInstance
  in create_ciminstance().

* In test_common.py, accomodated the fact that CIMInstanceName.to_wbem_uri()
  now by default sorts the keybindings.

Signed-off-by: Andreas Maier <andreas.r.maier@gmx.de>
  • Loading branch information
andy-maier committed Jun 22, 2020
1 parent c21ad59 commit b28b117
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
10 changes: 2 additions & 8 deletions pywbemtools/pywbemcli/_common.py
Expand Up @@ -659,7 +659,7 @@ def create_ciminstancename(cim_class, kv_keys):
return instance_path


def create_ciminstance(cim_class, kv_properties, property_list=None):
def create_ciminstance(cim_class, kv_properties):
"""
Create a CIMInstance object from the input parameters.
Expand All @@ -672,10 +672,6 @@ def create_ciminstance(cim_class, kv_properties, property_list=None):
A tuple of name/value pairs representing the properties and their
values that are to be constructed for the instance. Required
property_list (list):
a list of properties that is to be the list that is supplied
when the instance is created. Optional
Returns:
CIMInstance
Expand Down Expand Up @@ -706,9 +702,7 @@ def create_ciminstance(cim_class, kv_properties, property_list=None):
cl_prop.is_array,
value_str, ex))

new_inst = CIMInstance(cim_class.classname,
properties=properties,
property_list=property_list)
new_inst = CIMInstance(cim_class.classname, properties=properties)

return new_inst

Expand Down
30 changes: 16 additions & 14 deletions tests/unit/test_common.py
Expand Up @@ -70,6 +70,8 @@
# pywbem 1.0.0b1 or later
PYWBEM_1_0_0B1 = _PYWBEM_VERSION.release >= (1, 0, 0) and \
_PYWBEM_VERSION.dev is None
# pywbem 1.0.0 (dev, beta, final) or later
PYWBEM_1_0_0 = _PYWBEM_VERSION.release >= (1, 0, 0)


TESTCASES_ISCLASSNAME = [
Expand Down Expand Up @@ -281,14 +283,23 @@ def test_valid_output_format(testcase, fmt, default, groups, exp_rtn):
exp_rtn='kEY1="Ham and eggs",key2="More eggs"'),
None, None, True),

('Verify multiple keys binding multiple key types',
('Verify multiple unsorted keys binding multiple key types, pywbem >=1.0',
dict(kb=[('Name', 'Foo'),
('Number', Uint8(42)),
('Boolean', False),
('Ref', CIMInstanceName('CIM_Bar'))],
width=100,
exp_rtn='Boolean=FALSE,Name="Foo",Number=42,Ref="/:CIM_Bar"'),
None, None, PYWBEM_1_0_0),

('Verify multiple unsorted keys binding multiple key types, pywbem <1.0',
dict(kb=[('Name', 'Foo'),
('Number', Uint8(42)),
('Boolean', False),
('Ref', CIMInstanceName('CIM_Bar'))],
width=100,
exp_rtn='Name="Foo",Number=42,Boolean=FALSE,Ref="/:CIM_Bar"'),
None, None, True),
None, None, not PYWBEM_1_0_0),

('Verify mutliple keys that fold into multiple lines',
dict(kb=[('kEY1', u'Ham'), ('key2', 3)],
Expand Down Expand Up @@ -324,15 +335,6 @@ def test_valid_output_format(testcase, fmt, default, groups, exp_rtn):
exp_rtn=('k1=1,k2=2\nk3=3,k4=4\nk5=5,k6=6\nk7=7,k8=8')),
None, None, False),

('Verify multiple keys binding with spaces in keys',
dict(kb=[('Name', 'Foo'),
('Number', Uint8(42)),
('Boolean', False),
('Ref', CIMInstanceName('CIM_Bar'))],
width=4,
exp_rtn='Name="Foo"\nNumber=42\nBoolean=FALSE\nRef="/:CIM_Bar"'),
None, None, True),

# Test no keys
('Verify no keys',
dict(kb=[],
Expand Down Expand Up @@ -439,13 +441,13 @@ def test_format_keybindings(testcase, kb, width, exp_rtn):
None, None, True),

('Verify multiple keys binding multiple key types',
dict(kb=[('Name', 'Foo'),
dict(kb=[('Boolean', False),
('Name', 'Foo'),
('Number', Uint8(42)),
('Boolean', False),
('Ref', CIMInstanceName('CIM_Bar'))],
rpl={},
fp=False,
exp_rtn='/:cln.Name="Foo",Number=42,Boolean=FALSE,Ref="/:CIM_Bar"'),
exp_rtn='/:cln.Boolean=FALSE,Name="Foo",Number=42,Ref="/:CIM_Bar"'),
None, None, True),
]

Expand Down

0 comments on commit b28b117

Please sign in to comment.