Skip to content

Commit

Permalink
Docs: Resolved review comments on mock support chapter.
Browse files Browse the repository at this point in the history
Signed-off-by: Andreas Maier <maiera@de.ibm.com>
  • Loading branch information
andy-maier committed Apr 3, 2018
1 parent 49d410c commit 685cb57
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 71 deletions.
4 changes: 4 additions & 0 deletions docs/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,10 @@ specified when following the links to the standards:

- The ``EnumerationCount`` operation is not supported by pywbem.

- The mock support of pywbem (see :ref:`Mock support`) does not support the
``ModifyClass`` operation. Note that in its implementation of the CIM-XML
protocol, pywbem does support the ``ModifyClass`` operation.

* The CIM-XML representation of :ref:`CIM objects` as produced by their
``tocimxml()`` and ``tocimxmlstr()`` methods conforms to :term:`DSP0201`.

Expand Down
58 changes: 17 additions & 41 deletions docs/mocksupport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ The operation mode of the mock repository is selected when creating
a :class:`~pywbem_mock.FakedWBEMConnection` object, through its `repo_lite`
init parameter. Full mode is the default.

The following example demonstrates setting up a faked connection, adding some
CIM objects defined in a MOF string to its mock repository, and executing
WBEM operations on the faked connection:
The following example demonstrates setting up a faked connection, adding
several CIM objects defined in a MOF string to its mock repository, and
executing WBEM operations on the faked connection:

.. code-block:: python
Expand Down Expand Up @@ -486,49 +486,25 @@ The faked pull operations are:
Faked iter operations
^^^^^^^^^^^^^^^^^^^^^
The faked iter operations (like the real iter operations) do not directly
issue requests and responses on the connection, but instead are simply a
layer on top of underlying operations. For example, `IterEnumerateInstances`
The iter operations on a faked connection are in fact the iter operations
on :class:`~pywbem.WBEMConnection`, because they do not directly issue requests
and responses on the connection, but instead are simply a layer on top of
underlying operations. For example, `IterEnumerateInstances`
invokes either pull operations (i.e. `OpenEnumerateInstances` followed by
`PullInstancesWithPath`) or traditional operations (i.e. `EnumerateInstances`).
The approach by which the use of pull vs. traditional operations is controlled
is the same as for the iter operations of :class:`~pywbem.WBEMConnection`,
through the `use_pull_operations` init parameter of
The use of pull vs. traditional operations is controlled via the
`use_pull_operations` init parameter of
:class:`~pywbem_mock.FakedWBEMConnection`.
Therefore, the faked iter operations behave like the iter operations of
:class:`~pywbem.WBEMConnection`, and their limitations are those of the
underlying faked traditional operations or faked pull operations.
The iter operations are:
The faked iter operations are:
- **IterEnumerateInstances**: Behaves like
:meth:`~pywbem.WBEMConnection.IterEnumerateInstances`,
with the stated exceptions.
- **IterEnumerateInstancePaths**: Behaves like
:meth:`~pywbem.WBEMConnection.IterEnumerateInstancePaths`,
with the stated exceptions.
- **IterAssociatorInstances**: Behaves like
:meth:`~pywbem.WBEMConnection.IterAssociatorInstances`,
with the stated exceptions.
- **IterAssociatorInstancePaths**: Behaves like
:meth:`~pywbem.WBEMConnection.IterAssociatorInstancePaths`,
with the stated exceptions.
- **IterReferenceInstances**: Behaves like
:meth:`~pywbem.WBEMConnection.IterReferenceInstances`,
with the stated exceptions.
- **IterReferenceInstancePaths**: Behaves like
:meth:`~pywbem.WBEMConnection.IterReferenceInstancePaths`,
with the stated exceptions.
- **IterQueryInstances**: Behaves like
:meth:`~pywbem.WBEMConnection.IterQueryInstances`,
with the stated exceptions.
- :meth:`~pywbem.WBEMConnection.IterEnumerateInstances`
- :meth:`~pywbem.WBEMConnection.IterEnumerateInstancePaths`
- :meth:`~pywbem.WBEMConnection.IterAssociatorInstances`
- :meth:`~pywbem.WBEMConnection.IterAssociatorInstancePaths`
- :meth:`~pywbem.WBEMConnection.IterReferenceInstances`
- :meth:`~pywbem.WBEMConnection.IterReferenceInstancePaths`
- :meth:`~pywbem.WBEMConnection.IterQueryInstances`
.. _`Faked class operations`:
Expand Down
42 changes: 27 additions & 15 deletions pywbem/mof_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2313,16 +2313,29 @@ def __init__(self, handle, search_paths=None, verbose=False,
not depend on existing CIM elements in the repository.
search_paths (:term:`py:iterable` of :term:`string`):
An iterable of path names of directories where compiler will search
for mof files to complete a compile operation. The compiler
searches these paths (including subdirectories) for
mof in a number of cases including: 1) find a superclass that
is not in repository while compiling a class 2) Find a
qualifier that is not in the repository (it looks for filenames
'qualifiers' and 'qualifiers_optional' in the search path, 3) find
a dependent class reference property and the
EmbeddedInstanceQualifier). Currently item 3 above is only partly
implemented. (See issue # 1138)
An iterable of directory path names where the MOF compiler will
search for MOF dependent files if the MOF element they define is
not in the target namespace of the CIM repository. The compiler
searches the specified directories and their subdirectories.
MOF dependent files are:
* The MOF file defining the superclass of a class that is compiled.
The MOF file searched for is '<classname>.mof'.
* The MOF file defining the qualifier type of a qualifier that
is specified on a MOF element that is compiled.
The MOF files searched for are 'qualifiers.mof' and
'qualifiers_optional.mof'.
* The MOF file of a class specified in a reference property or
in the `EmbeddedInstance` qualifier that is compiled.
The MOF file searched for is '<classname>.mof'.
This is only partly implemented, see issue #1138.
Note that MOF include files are not searched for; they are specified
in the ``pragma include`` directive as a file path relative to the
including file.
verbose (:class:`py:bool`):
Indicates whether to issue more detailed compiler messages.
Expand Down Expand Up @@ -2372,10 +2385,9 @@ def compile_string(self, mof, ns, filename=None):
Raises:
MOFParseError: Syntax error in the MOF.
IOError: MOF file not found.
IOError: Filename required for the compile (ex. pragma include)
cannot be found
MOFParseError: Syntax error in the MOF.
: Any exceptions that are raised by the repository connection class.
"""
Expand Down Expand Up @@ -2438,9 +2450,9 @@ def compile_file(self, filename, ns):
Raises:
MOFParseError: Syntax error in the MOF.
IOError: MOF file not found.
IOError: filename cannot be found.
MOFParseError: Syntax error in the MOF.
: Any exceptions that are raised by the repository connection class.
"""
Expand Down
45 changes: 30 additions & 15 deletions pywbem_mock/_wbemconnection_mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,11 +355,14 @@ def compile_mof_file(self, mof_file, namespace=None, search_paths=None,
If a CIM class or CIM qualifier type to be added already exists in the
target namespace with the same name (comparing case insensitively),
this method fails, and the mock repository remains unchanged.
this method raises :exc:`~pywbem.CIMError`.
If a CIM instance to be added already exists in the target namespace
with the same keybinding values, this method fails, and the mock
repository remains unchanged.
with the same keybinding values, this method raises
:exc:`~pywbem.CIMError`.
In all cases where this method raises an exception, the mock repository
remains unchanged.
Parameters:
Expand All @@ -373,19 +376,23 @@ def compile_mof_file(self, mof_file, namespace=None, search_paths=None,
used.
search_paths (:term:`py:iterable` of :term:`string`):
An iterable of path names of directories where MOF include files
will be looked up.
An iterable of directory path names where MOF dependent files will
be looked up.
See the description of the `search_path` init parameter of the
:class:`~pywbem.MOFCompiler` class for more information on MOF
dependent files.
verbose (:class:`py:bool`):
Controls whether to issue more detailed compiler messages.
Raises:
IOError: MOF file not found.
:exc:`~pywbem.MOFParseError`: Compile error in the MOF.
The mock repository remains unchanged.
:exc:`~pywbem.CIMError`: Failure related to the CIM objects in the
mock repository. The mock repository remains unchanged.
mock repository.
"""

if not namespace:
Expand Down Expand Up @@ -415,11 +422,14 @@ def compile_mof_str(self, mof_str, namespace=None, search_paths=None,
If a CIM class or CIM qualifier type to be added already exists in the
target namespace with the same name (comparing case insensitively),
this method fails, and the mock repository remains unchanged.
this method raises :exc:`~pywbem.CIMError`.
If a CIM instance to be added already exists in the target namespace
with the same keybinding values, this method fails, and the mock
repository remains unchanged.
with the same keybinding values, this method raises
:exc:`~pywbem.CIMError`.
In all cases where this method raises an exception, the mock repository
remains unchanged.
Parameters:
Expand All @@ -433,19 +443,23 @@ def compile_mof_str(self, mof_str, namespace=None, search_paths=None,
used.
search_paths (:term:`py:iterable` of :term:`string`):
An iterable of path names of directories where MOF include files
will be looked up.
An iterable of directory path names where MOF dependent files will
be looked up.
See the description of the `search_path` init parameter of the
:class:`~pywbem.MOFCompiler` class for more information on MOF
dependent files.
verbose (:class:`py:bool`):
Controls whether to issue more detailed compiler messages.
Raises:
IOError: MOF file not found.
:exc:`~pywbem.MOFParseError`: Compile error in the MOF.
The mock repository remains unchanged.
:exc:`~pywbem.CIMError`: Failure related to the CIM objects in the
mock repository. The mock repository remains unchanged.
mock repository.
"""

if not namespace:
Expand Down Expand Up @@ -477,7 +491,8 @@ def add_cimobjects(self, objects, namespace=None):
If the CIM namespace does not exist, it is created.
The method imposes very few limits on the objects added. It does
require that the superclass exist for any class added.
require that the superclass exist for any class added and that
instances added include a path component.
If a CIM class or CIM qualifier type to be added already exists in the
target namespace with the same name (comparing case insensitively),
Expand Down

0 comments on commit 685cb57

Please sign in to comment.