Skip to content

Commit

Permalink
Change mock repo build to use the new build method
Browse files Browse the repository at this point in the history
Change the build method for the schema to use the simpler build method
that builds from a list of required classes instead of hand building the
pragma. The reason we are doing this is to be able to integrate the code
that builds wbemserver into the subscription manager test.
  • Loading branch information
KSchopmeyer authored and andy-maier committed May 17, 2018
1 parent f27a47c commit 1bdc729
Showing 1 changed file with 20 additions and 32 deletions.
52 changes: 20 additions & 32 deletions testsuite/test_wbemserverclass.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,53 +30,42 @@

from pywbem import WBEMServer, ValueMapping, CIMInstance, CIMInstanceName
from pywbem._nocasedict import NocaseDict

from dmtf_mof_schema_def import DMTF_TEST_SCHEMA_VER
from pywbem_mock import FakedWBEMConnection

from dmtf_mof_schema_def import install_test_dmtf_schema

VERBOSE = True

# location of testsuite/schema dir used by all tests as test DMTF CIM Schema
# This directory is permanent and should not be removed.
TEST_DIR = os.path.dirname(__file__)
TESTSUITE_SCHEMA_DIR = os.path.join(TEST_DIR, 'schema')


class BaseMethodsForTests(object):
"""
Common methods for test of server class. This includes methods to
build the DMTF schema and to build individual instances.
"""

@staticmethod
def build_schema_list(conn, namespace):
def build_class_repo(self, default_namespace):
"""
Build the schema qualifier and class objects in the repository.
This requires only that the leaf objects be defined in a mof
include file since the compiler finds the files for qualifiers
and dependent classes.
TODO: ks 3/18 Right now we must build a file in the schema directory
to do this because the compile_from_string does not support
include files, etc. It does not search for files. See issue 1138
"""
dmtf_schema = install_test_dmtf_schema()
class_list = """
#pragma locale ("en_US")
#pragma include ("Interop/CIM_RegisteredProfile.mof")
#pragma include ("Interop/CIM_Namespace.mof")
#pragma include ("Interop/CIM_ObjectManager.mof")
#pragma include ("Interop/CIM_ElementConformsToProfile.mof")
#pragma include ("Interop/CIM_ReferencedProfile.mof")
"""

test_schema = os.path.join(dmtf_schema.schema_root_dir,
'test_schema1.mof')

with open(test_schema, "w") as schema_file:
schema_file.write(class_list)
FakedWBEMConnection._reset_logging_config()
conn = FakedWBEMConnection(default_namespace=default_namespace)
classnames = ['CIM_Namespace',
'CIM_ObjectManager',
'CIM_RegisteredProfile',
'CIM_ElementConformsToProfile']

conn.compile_mof_file(test_schema, namespace=namespace,
search_paths=[dmtf_schema.schema_mof_dir])
conn.compile_dmtf_schema(DMTF_TEST_SCHEMA_VER,
TESTSUITE_SCHEMA_DIR,
class_names=classnames, verbose=False)

if os.path.isfile(test_schema):
os.remove(test_schema)
return
return conn

@staticmethod
def inst_from_class(klass, namespace=None,
Expand Down Expand Up @@ -316,7 +305,7 @@ def build_elementconformstoprofile_inst(self, conn, namespace,
@pytest.mark.parametrize(
"tst_namespace",
['interop', 'root/interop', 'root/PG_Interop'])
def test_server_basic(self, tst_namespace):
def test_wbemserver_basic(self, tst_namespace):
"""
Test the basic functions that access server information. This test
creates the mock repository and adds classes and instances for
Expand All @@ -326,10 +315,9 @@ def test_server_basic(self, tst_namespace):
for easily getting classes and instances into the repo and to provide
a basic test of functionality.
"""
conn = FakedWBEMConnection()
self.build_schema_list(conn, tst_namespace)
system_name = 'Mock_Test_server_class'
system_name = 'Mock_Test_subscription_mgr'
object_manager_name = 'MyFakeObjectManager'
conn = self.build_class_repo(tst_namespace)
server = WBEMServer(conn)

# Build CIM_ObjectManager instance
Expand Down

0 comments on commit 1bdc729

Please sign in to comment.