def __init__(self): self.lock = threading.RLock() from arjuna.tpi import Arjuna from arjuna.tpi.enums import ArjunaOption self.path = Arjuna.get_central_config().get_arjuna_option_value( ArjunaOption.UNITEE_PROJECT_RUN_REPORT_DIR).as_str( ) + "/ArjunaTestReport.xls"
def __init__(self): self.pkg = None self.module = None self.func = None self.qname = None self.__tvars = None self.__threads = None self.__deps = None self.__drefs = None self.__dsources = [] self.__instances = [] self.__skipped = False self.__skip_code = None self.selected = False self.__unpicked = True self.__unpick_code = None self.consumed = False from arjuna.tpi import Arjuna self.console = Arjuna.get_console() self.logger = Arjuna.get_logger() self.central_config = Arjuna.get_central_config()
def configure_fixture(fixdef, ftypestr, mname, fname): from arjuna.tpi import Arjuna fix_prefix = Arjuna.get_central_config().get_arjuna_option_value( ArjunaOption.UNITEE_PROJECT_FIXTURES_IMPORT_PREFIX).as_str() module = importlib.import_module(fix_prefix + mname) func = getattr(module, fname) fixdef.add_fixture_func(FixtureTypeEnum[ftypestr.upper()], kfactory.create_fixture(ftypestr, func))
def __load_pick_all(gconfs): from arjuna.tpi import Arjuna central_config = Arjuna.get_central_config() arjuna_root_dir = central_config.get_arjuna_option_value(ArjunaOption.ARJUNA_ROOT_DIR).as_str() fpath = os.path.join( arjuna_root_dir, "res/st/magroup.xml" ) group_xml = ETree.parse(fpath).getroot() group_name = group_xml.attrib['name'] gconfs[group_name] = GroupConf(group_name, group_xml, fpath)
def load_session(self, session_name): from arjuna.tpi import Arjuna from arjuna.unitee.test.defs.session import UserDefinedSessionDef sdir = Arjuna.get_central_config().get_arjuna_option_value( ArjunaOption.UNITEE_PROJECT_SESSIONS_DIR).as_str() session_file_path = os.path.join(sdir, session_name + ".xml") if not file_utils.is_file(session_file_path): Arjuna.get_console().display_error( "Not able to find session file {}.xml at {}".format( session_name, sdir)) sys_utils.fexit() sdef = UserDefinedSessionDef(session_name, session_file_path) sdef.process() self.__session = sdef.pick() self.__session.context = self.__create_test_context() self.__session.load()
def execute(self, arg_dict): for parent in self.parents: parent.process(arg_dict) from arjuna.tpi import Arjuna project_root_dir = arg_dict["project.root.dir"] del arg_dict["project.root.dir"] Arjuna.init(project_root_dir, CliArgsConfig(arg_dict)) import sys proj_dir = Arjuna.get_central_arjuna_option(ArjunaOption.PROJECT_ROOT_DIR).as_str() sys.path.append(proj_dir + "/..") py_3rdparty_dir = Arjuna.get_central_config().get_arjuna_option_value(ArjunaOption.ARJUNA_EXTERNAL_IMPORTS_DIR).as_str() sys.path.append(py_3rdparty_dir) self.unitee = Arjuna.get_unitee_instance() self.unitee.load_testdb()
def __init__(self, path=None, delimiter="\t"): super().__init__() self.path = path self.delimiter = delimiter data_dir = Arjuna.get_central_config().get_arjuna_option_value(ArjunaOption.DATA_SOURCES_DIR).as_str() if file_utils.is_absolute_path(self.path): if not file_utils.is_file(self.path): if file_utils.is_dir(self.path): raise Exception("Not a file: {}".format(self.path)) else: raise Exception("File does not exist: {}".format(self.path)) else: self.path = os.path.abspath(os.path.join(data_dir, self.path)) if not file_utils.is_file(self.path): if file_utils.is_dir(self.path): raise Exception("Not a file: {}".format(self.path)) else: raise Exception("File does not exist: {}".format(self.path))
def __init__(self, fpath, gname, pickers_node): self.gname = gname self.fpath = fpath self.root = pickers_node # Although using a set would give better performance, using a list so that pickers are evaluated # in the order they are specified. self._rule_dict = CIStringDict({ 'cm': [], 'im': [], 'cf': [], 'if': [] }) self.__module_matcher = None self.__function_matcher = None from arjuna.tpi import Arjuna self.console = Arjuna.get_console() self.tm_prefix = Arjuna.get_central_config().get_arjuna_option_value( ArjunaOption.UNITEE_PROJECT_TEST_MODULE_IMPORT_PREFIX).as_str() self.__process()
def __load_user_gconfs(gconfs): from arjuna.tpi import Arjuna console = Arjuna.get_console() central_config = Arjuna.get_central_config() ugcdir = central_config.get_arjuna_option_value(ArjunaOption.CONFIG_DIR).as_str() ugfpath = os.path.join(ugcdir, "groups.xml") def display_err_and_exit(msg): console.display_error((msg + " Fix groups template file: {}").format(ugfpath)) sys_utils.fexit() if not os.path.exists(ugfpath) or not os.path.isfile(ugfpath): return try: tree = ETree.parse(ugfpath) except Exception as e: print(e) display_err_and_exit("Groups definition file could not be loaded because of errors in XML.") else: root = tree.getroot() if root.tag != 'groups': display_err_and_exit("Invalid groups template file. Root element tag should be >>groups<<.") node_dict = etree_utils.convert_to_cidict(root) # Validate only group keys exist. if node_dict.keys() != {'group'}: display_err_and_exit(">>groups<< element can contain only one or more >>group<< elements.") elif not node_dict: display_err_and_exit(">>groups<< element must contain atleast one >>group<< element.") else: for group in list(root): run_conf_utils.validate_group_xml_child("session", ugfpath, group) group_attrs = etree_utils.convert_attribs_to_cidict(group) name = group_attrs['name'].strip() if not name: display_err_and_exit(">>name<< attribute in group definition can not be empty.") gconfs[name] = GroupConf(name, group, ugfpath)
def __init__(self): from arjuna.tpi import Arjuna self.logger = Arjuna.get_logger() self.console = Arjuna.get_console() self.central_config = Arjuna.get_central_config() self.unitee = Arjuna.get_unitee_instance()