Skip to content

Commit

Permalink
Fix issue with compile_dmtf_mof method failing tests
Browse files Browse the repository at this point in the history
Fix issue where we were using a string as parameter for mof_compiler
search_paths. Changed to use list.

Changed verbose diagnostic message that announces missing dependence in
compiler

Correct Issues from Andy, v3.

Corrected comments by Andy in the pr from 23 Apr. Also made a few other
editorial changes to documentation and cleaned up the tests slightly so
the TestDMTFClass test tests the same thing on each succes test.

Extended Error test for schema_version
  • Loading branch information
KSchopmeyer committed Apr 24, 2018
1 parent 8a0ad81 commit 800cd96
Show file tree
Hide file tree
Showing 6 changed files with 256 additions and 213 deletions.
8 changes: 5 additions & 3 deletions docs/mocksupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ with a simple callback function.
ip1 = params['IP1']
# Access the mock repository through the faked connection object.
# In case of a static CIM method, objectname is a CIMClassName object.
# In case of a static CIM method, objectname is a
:class:`~pywbem.CIMClassName` object.
cl = conn.GetClass(objectname)
# Set return value and output parameters
Expand Down Expand Up @@ -565,7 +566,7 @@ Building the mock repository
----------------------------
The mock repository should contain the CIM qualifier declarations, CIM classes,
CIMInstances, and CIM methods to be used in the mock environment. The
CIM instances, and CIM methods to be used in the mock environment. The
mock user creates a repository that contains the CIM Objects required for
the operations to be executed in the mock environment. Thus, if the user only
requires CIM_Computer system, only that class and its dependent classes need
Expand All @@ -578,7 +579,8 @@ repository.
There are two ways to build a mock repository:
* Directly from pywbem CIM objects (CIMClass. CIMInstance, etc). See
* Directly from pywbem CIM objects (:class:`~pywbem.CIMClass`,
:class:`~pywbem.CIMInstance`, etc). See
:meth:`~pywbem_mock.FakedWBEMConnection.add_cimobjects`
* From MOF definitions of the objects (which can be a string or a file, in
Expand Down
9 changes: 5 additions & 4 deletions pywbem/mof_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -637,9 +637,10 @@ def p_mp_createClass(p):
raise err
try:
if p.parser.verbose:
p.parser.log('Creating missing dependent '
'class %s:%s' %
(ns, cc.classname))
p.parser.log('Class %s namespace %s '
'depends on class %s which is '
'not in repository.' %
(cc.classname, ns, cln))
p.parser.mofcomp.compile_file(moffile, ns)
except CIMError as ce:
if ce.args[0] == CIM_ERR_NOT_FOUND:
Expand Down Expand Up @@ -2541,14 +2542,14 @@ def find_mof(self, classname):
:term:`string`: Path name of the MOF file defining the CIM class, if
it was found. `None`, if it was not found.
"""

classname = classname.lower()
for search in self.parser.search_paths:
for root, dummy_dirs, files in os.walk(search):
for file_ in files:
if file_.endswith('.mof') and \
file_[:-4].lower() == classname:
return root + '/' + file_

return None

def rollback(self, verbose=False):
Expand Down
Loading

0 comments on commit 800cd96

Please sign in to comment.