Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement mock of WBEMConnection to create a local WBEM
server simulator for unit tests of pywbem and for users of pywbem. This implements mocks of all of the WBEMConnection methods that contact the wbem server and a local repository so that thee mocked methods that respond to the WBEM requests with data from the repository. It mocks a WBEM server so that the WBEM operations in WBEMConnection can be run against data that the mocker adds to a temporary repository. This mocker depends on the user creating classes, qualifier declarations, and instances in the temporary repository that the operations can use as the source of data to return with request responses. This is not a complete implementation of a WBEMserver and therefore creates a number of simplifications. Including: 1. For instance operations, DeepInheritance only works correctly if there are correct cim classes. A flag (repo_lite) allows the user to create instances only in the repository to simplify test building and to respond without any knowledge of subclasses since class hiearchy is available only in class definitions, not in instances. 2. We have simplified the references and associators operations. At least some of the operation will operate without haveing a full class and instance repository (repo_lite) so that tests can be created with very simplified repositories. However some of the instance operations (ex. CreateInstance) absolutely require correct classes and qualifier declarations to execute. 3. The pull operations have a limitation in that this mock WBEMConnection does not implement the filter query language (i.e. FQL) so that the filtering that would normally be provided by FQL of the returned instances is ignored and the same set of instances that the corresponding non-pull request returns are returned for the Open... and Pull... requests. The mocker includes methods to allow adding instances, classes, and qualifier declarations directly to the mock repository. They may be added directly as CIM objects with the add_cimobjects method or compiled from mof files or mof strings using the compile_mof and compile_mof_str methods. NOT DONE: 1. Full set of tests on associations and the corresponding pulls. Main paths tested but we need more tests for variations on input parameters and errors especially of associations. 2. ExecQuery - See separate issue for addition of this function. issue 871 3. InvokeMethod -We agreed to leave this until we have merged the majority of the work. The mocker for invokemethod will probably be based on a callback to a user defined function that lets the user emulate the server invokemethod. See Issue 871 4. Compiler install of objects. We are regularly using compile_str in tests but need more tests on compile_mof_file. Also needs more tests for things like multiple additive compiles, compiles with duplication errors, etc. 5. Documentation. The documentation needs review. It also needs more examples. Andy reviewing documentation 6. Pulls for references and associators do not have tests 7. Extend build from mof to create paths when compiler does not for instances going into the repository. 8. Refactor createInstance and modifyInstance to use common code.
- Loading branch information