def _get_ucase_class_from_ucase(self, ucase): """ This function gets the use case class from the use case name. :type ucase: string :param ucase: use case name :rtype: object :return: use case class """ if not self._ucase_catalogs: error_msg = "No use case catalog has been found!" raise AcsConfigException(AcsConfigException.FILE_NOT_FOUND, error_msg) ucase_dic = self._ucase_catalogs.get(ucase) if not ucase_dic: error_msg = "Use case {0} not found in UC catalog!".format(ucase) raise AcsConfigException(AcsConfigException.XML_PARSING_ERROR, error_msg) # Presence of ClassName element # is already checked by CatalogParser using xsd ucase_class_name = ucase_dic.get(CatalogParser.CLASSNAME_ELEM) ucase_class = Utils.get_class(ucase_class_name) return ucase_class
def get_ucase_class(self): """ This function returns usecase class if present. """ ucase_class = None ucase_class_node = self.get_testcase_property(USECASE_CLASS_NAME_NODE, None) if ucase_class_node is not None: ucase_class = Utils.get_class(ucase_class_node) return ucase_class
# Parse Device catalog list_ClassName = [] list_UECmd = [] for root, dirnames, filenames in os.walk(Paths.DEVICE_MODELS_CATALOG): for filename in fnmatch.filter(filenames, '*.xml'): device_cfg_path = os.path.join(root, filename) device_cfg = etree.parse(device_cfg_path) list_ClassName.extend(device_cfg.xpath("//Parameter[@ClassName]")) list_UECmd.extend(device_cfg.xpath("//Parameter[@UECmd]")) # Check if all class name can be instantiate for dict_class_name in list_ClassName: class_name = dict_class_name.attrib['ClassName'] if Utils.get_class(class_name): OUTPUT = "%s is instantiate" % class_name else: bool_instantiate_all_class_name = False OUTPUT = "Test fail %s can not be instantiate" % class_name # Check if all UECmd can be instantiate for dict_ue_cmd in list_UECmd: ue_cmd = dict_ue_cmd.attrib['UECmd'] ue_cmd_factory = "%s%s" % (ue_cmd, ".Factory.Factory") if Utils.get_class(ue_cmd_factory): OUTPUT = "%s is instantiate" % ue_cmd_factory else: bool_instantiate_all_ue_cmd = False OUTPUT = "Test fail %s can not be instantiate" % ue_cmd_factory
# flake8: noqa """ Copyright (C) 2017 Intel Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache-2.0 """ # @PydevCodeAnalysisIgnore # pylint: disable=E0602,W0212 import acs.UtilitiesFWK.Utilities as Utils exceptionName = TC_PARAMETERS("EXCEPTION_NAME") # @UndefinedVariable if exceptionName is not None: ucase_class = Utils.get_class(exceptionName) raise ucase_class(ucase_class.OPERATION_FAILED, exceptionName + " has been raised")